diff --git a/application/bootstrap.php b/application/bootstrap.php index 47ee145..ea6fdef 100644 --- a/application/bootstrap.php +++ b/application/bootstrap.php @@ -36,7 +36,7 @@ * @link http://kohanaframework.org/guide/using.autoloading * @link http://www.php.net/manual/function.spl-autoload-register */ -spl_autoload_register(array('Kohana', 'auto_load')); +spl_autoload_register(['Kohana', 'auto_load']); /** * Optionally, you can enable a compatibility auto-loader for use with @@ -44,7 +44,7 @@ * * It is recommended to not enable this unless absolutely necessary. */ -//spl_autoload_register(array('Kohana', 'auto_load_lowercase')); +//spl_autoload_register(['Kohana', 'auto_load_lowercase']); /** * Enable the Kohana auto-loader for unserialization. @@ -98,9 +98,9 @@ * - boolean caching enable or disable internal caching FALSE * - boolean expose set the X-Powered-By header FALSE */ -Kohana::init(array( +Kohana::init([ 'base_url' => '/kohana/', -)); +]); /** * Attach the file write to logging. Multiple writers are supported. @@ -115,7 +115,7 @@ /** * Enable modules. Modules are referenced by a relative or absolute path. */ -Kohana::modules(array( +Kohana::modules([ // 'auth' => MODPATH.'auth', // Basic authentication // 'cache' => MODPATH.'cache', // Caching with multiple backends // 'codebench' => MODPATH.'codebench', // Benchmarking tool @@ -125,12 +125,12 @@ // 'orm' => MODPATH.'orm', // Object Relationship Mapping // 'unittest' => MODPATH.'unittest', // Unit testing // 'userguide' => MODPATH.'userguide', // User guide and API documentation -)); +]); /** * Cookie Salt * @see http://kohanaframework.org/3.3/guide/kohana/cookies - * + * * If you have not defined a cookie salt in your Cookie class then * uncomment the line below and define a preferrably long salt. */ @@ -141,7 +141,7 @@ * defaults for the URI. */ Route::set('default', '((/(/)))') - ->defaults(array( + ->defaults([ 'controller' => 'welcome', 'action' => 'index', - )); + ]); diff --git a/modules/codebench/classes/Bench/MDDoBaseURL.php b/modules/codebench/classes/Bench/MDDoBaseURL.php index 4244382..e4be24f 100644 --- a/modules/codebench/classes/Bench/MDDoBaseURL.php +++ b/modules/codebench/classes/Bench/MDDoBaseURL.php @@ -12,8 +12,7 @@ class Bench_MDDoBaseURL extends Codebench public $description = 'Optimization for the doBaseURL() method of Kohana_Kodoc_Markdown for the Kohana Userguide.'; public $loops = 10000; - public $subjects = array - ( + public $subjects = [ // Valid matches '[filesystem](about.filesystem)', '[filesystem](about.filesystem "Optional title")', @@ -22,7 +21,7 @@ class Bench_MDDoBaseURL extends Codebench // Invalid matches '![this is image syntax](about.filesystem)', '[filesystem](about.filesystem', - ); + ]; public function bench_original($subject) { diff --git a/modules/codebench/classes/Bench/MDDoImageURL.php b/modules/codebench/classes/Bench/MDDoImageURL.php index d6775b1..5057558 100644 --- a/modules/codebench/classes/Bench/MDDoImageURL.php +++ b/modules/codebench/classes/Bench/MDDoImageURL.php @@ -12,8 +12,7 @@ class Bench_MDDoImageURL extends Codebench public $description = 'Optimization for the doImageURL() method of Kohana_Kodoc_Markdown for the Kohana Userguide.'; public $loops = 10000; - public $subjects = array - ( + public $subjects = [ // Valid matches '![Alt text](http://img.skitch.com/20091019-rud5mmqbf776jwua6hx9nm1n.png)', '![Alt text](https://img.skitch.com/20091019-rud5mmqbf776jwua6hx9nm1n.png)', @@ -23,7 +22,7 @@ class Bench_MDDoImageURL extends Codebench '![Empty src]()', // Invalid matches '![Alt text](img/install.png "No closing parenthesis"', - ); + ]; public function bench_original($subject) { diff --git a/modules/codebench/classes/Kohana/Codebench.php b/modules/codebench/classes/Kohana/Codebench.php index 1bb7aa0..348d76e 100644 --- a/modules/codebench/classes/Kohana/Codebench.php +++ b/modules/codebench/classes/Kohana/Codebench.php @@ -32,15 +32,14 @@ abstract class Kohana_Codebench /** * @var array Grade letters with their maximum scores. Used to color the graphs. */ - public $grades = array - ( + public $grades = [ 125 => 'A', 150 => 'B', 200 => 'C', 300 => 'D', 500 => 'E', 'default' => 'F', - ); + ]; /** * Constructor. @@ -70,18 +69,16 @@ public function run() } // Initialize benchmark output - $codebench = array - ( + $codebench = [ 'class' => get_class($this), 'description' => $this->description, - 'loops' => array - ( + 'loops' => [ 'base' => (int) $this->loops, 'total' => (int) $this->loops * count($this->subjects) * count($methods), - ), + ], 'subjects' => $this->subjects, 'benchmarks' => [], - ); + ]; // Benchmark each method foreach ($methods as $method) { @@ -111,12 +108,11 @@ public function run() $benchmark = Profiler::total($token); // Benchmark output specific to the current method and subject - $codebench['benchmarks'][$method]['subjects'][$subject_key] = array - ( + $codebench['benchmarks'][$method]['subjects'][$subject_key] = [ 'return' => $return, 'time' => $benchmark[0], 'memory' => $benchmark[1], - ); + ]; // Update method totals $codebench['benchmarks'][$method]['time'] += $benchmark[0]; diff --git a/modules/image/classes/Kohana/Image/GD.php b/modules/image/classes/Kohana/Image/GD.php index 0fde947..55a865f 100644 --- a/modules/image/classes/Kohana/Image/GD.php +++ b/modules/image/classes/Kohana/Image/GD.php @@ -316,12 +316,11 @@ protected function _do_sharpen($amount) $amount = round(abs(-18 + ($amount * 0.08)), 2); // Gaussian blur matrix - $matrix = array - ( + $matrix = [ [-1, -1, -1], [-1, $amount, -1], [-1, -1, -1], - ); + ]; // Perform the sharpen if (imageconvolution($this->_image, $matrix, $amount - 8, 0)) { diff --git a/modules/orm/classes/Kohana/ORM.php b/modules/orm/classes/Kohana/ORM.php index e53df2d..35c0b5b 100644 --- a/modules/orm/classes/Kohana/ORM.php +++ b/modules/orm/classes/Kohana/ORM.php @@ -1075,11 +1075,10 @@ protected function run_filter($field, $value) $filters = empty($filters[$field]) ? $wildcards : array_merge($wildcards, $filters[$field]); // Bind the field name and model so they can be used in the filter method - $_bound = array - ( + $_bound = [ ':field' => $field, ':model' => $this, - ); + ]; foreach ($filters as $array) { // Value needs to be bound inside the loop so we are always using the diff --git a/modules/orm/classes/Kohana/ORM/Validation/Exception.php b/modules/orm/classes/Kohana/ORM/Validation/Exception.php index d8283b7..5d43e6a 100644 --- a/modules/orm/classes/Kohana/ORM/Validation/Exception.php +++ b/modules/orm/classes/Kohana/ORM/Validation/Exception.php @@ -50,14 +50,12 @@ public function __construct($alias, Validation $object, $message = 'Failed to va * // inside the exception for a user model. * $e->add_object('profile', $validation); * // The errors array will now look something like this - * // array - * // ( - * // 'username' => 'This field is required', - * // 'profile' => array - * // ( - * // 'first_name' => 'This field is required', - * // ), - * // ); + * // [ + * // 'username' => 'This field is required' + * // 'profile' => [ + * // 'first_name' => 'This field is required' + * // ] + * // ]; * * @param string $alias The relationship alias from the model * @param Validation $object The Validation object to merge diff --git a/modules/orm/classes/Model/Auth/Role.php b/modules/orm/classes/Model/Auth/Role.php index 73f51c5..b4ddf3f 100644 --- a/modules/orm/classes/Model/Auth/Role.php +++ b/modules/orm/classes/Model/Auth/Role.php @@ -13,22 +13,22 @@ class Model_Auth_Role extends ORM { // Relationships - protected $_has_many = array( - 'users' => array('model' => 'User', 'through' => 'roles_users'), - ); + protected $_has_many = [ + 'users' => ['model' => 'User', 'through' => 'roles_users'], + ]; public function rules() { - return array( - 'name' => array( - array('not_empty'), - array('min_length', array(':value', 4)), - array('max_length', array(':value', 32)), - ), - 'description' => array( - array('max_length', array(':value', 255)), - ) - ); + return [ + 'name' => [ + ['not_empty'], + ['min_length', [':value', 4]], + ['max_length', [':value', 32]], + ], + 'description' => [ + ['max_length', [':value', 255]], + ] + ]; } } diff --git a/modules/orm/classes/Model/Auth/User.php b/modules/orm/classes/Model/Auth/User.php index 1136764..0b209d2 100644 --- a/modules/orm/classes/Model/Auth/User.php +++ b/modules/orm/classes/Model/Auth/User.php @@ -17,10 +17,10 @@ class Model_Auth_User extends ORM * * @var array Relationhips */ - protected $_has_many = array( - 'user_tokens' => array('model' => 'User_Token'), - 'roles' => array('model' => 'Role', 'through' => 'roles_users'), - ); + protected $_has_many = [ + 'user_tokens' => ['model' => 'User_Token'], + 'roles' => ['model' => 'Role', 'through' => 'roles_users'], + ]; /** * Rules for the user model. Because the password is _always_ a hash @@ -32,21 +32,21 @@ class Model_Auth_User extends ORM */ public function rules() { - return array( - 'username' => array( - array('not_empty'), - array('max_length', array(':value', 32)), - array(array($this, 'unique'), array('username', ':value')), - ), - 'password' => array( - array('not_empty'), - ), - 'email' => array( - array('not_empty'), - array('email'), - array(array($this, 'unique'), array('email', ':value')), - ), - ); + return [ + 'username' => [ + ['not_empty'], + ['max_length', [':value', 32]], + [[$this, 'unique'], ['username', ':value']], + ], + 'password' => [ + ['not_empty'], + ], + 'email' => [ + ['not_empty'], + ['email'], + [[$this, 'unique'], ['email', ':value']], + ], + ]; } /** @@ -57,11 +57,11 @@ public function rules() */ public function filters() { - return array( - 'password' => array( - array(array(Auth::instance(), 'hash')) - ) - ); + return [ + 'password' => [ + [[Auth::instance(), 'hash']] + ] + ]; } /** @@ -71,11 +71,11 @@ public function filters() */ public function labels() { - return array( + return [ 'username' => 'username', 'email' => 'email address', 'password' => 'password', - ); + ]; } /** @@ -111,7 +111,7 @@ public function unique_key_exists($value, $field = NULL) $field = $this->unique_key($value); } - return (bool) DB::select(array(DB::expr('COUNT(*)'), 'total_count')) + return (bool) DB::select([DB::expr('COUNT(*)'), 'total_count']) ->from($this->_table_name) ->where($field, '=', $value) ->where($this->_primary_key, '!=', $this->pk()) @@ -139,8 +139,11 @@ public function unique_key($value) public static function get_password_validation($values) { return Validation::factory($values) - ->rule('password', 'min_length', array(':value', 8)) - ->rule('password_confirm', 'matches', array(':validation', ':field', 'password')); + ->rule('password', 'min_length', [':value', 8]) + ->rule('password_confirm', 'matches', [ + ':validation', + ':field', 'password' + ]); } /** @@ -148,11 +151,11 @@ public static function get_password_validation($values) * * Example usage: * ~~~ - * $user = ORM::factory('User')->create_user($_POST, array( - * 'username', - * 'password', - * 'email', - * ); + * $user = ORM::factory('User')->create_user($_POST, [ + * 'username', + * 'password', + * 'email', + * ]); * ~~~ * * @param array $values @@ -176,13 +179,13 @@ public function create_user($values, $expected) * Example usage: * ~~~ * $user = ORM::factory('User') - * ->where('username', '=', 'kiall') - * ->find() - * ->update_user($_POST, array( - * 'username', - * 'password', - * 'email', - * ); + * ->where('username', '=', 'kiall') + * ->find() + * ->update_user($_POST, [ + * 'username', + * 'password', + * 'email', + * ]); * ~~~ * * @param array $values diff --git a/modules/orm/classes/Model/Auth/User/Token.php b/modules/orm/classes/Model/Auth/User/Token.php index 7710844..edf7ee1 100644 --- a/modules/orm/classes/Model/Auth/User/Token.php +++ b/modules/orm/classes/Model/Auth/User/Token.php @@ -13,13 +13,13 @@ class Model_Auth_User_Token extends ORM { // Relationships - protected $_belongs_to = array( - 'user' => array('model' => 'User'), - ); - protected $_created_column = array( + protected $_belongs_to = [ + 'user' => ['model' => 'User'], + ]; + protected $_created_column = [ 'column' => 'created', 'format' => TRUE, - ); + ]; /** * Handles garbage collection and deleting of expired objects. @@ -67,7 +67,7 @@ protected function create_token() { do { $token = sha1(uniqid(Text::random('alnum', 32), TRUE)); - } while (ORM::factory('User_Token', array('token' => $token))->loaded()); + } while (ORM::factory('User_Token', ['token' => $token])->loaded()); return $token; } diff --git a/public/index.php b/public/index.php index d2b198f..c0c4d03 100644 --- a/public/index.php +++ b/public/index.php @@ -97,9 +97,10 @@ // Bootstrap the application require APPPATH . 'bootstrap' . EXT; -if (PHP_SAPI == 'cli') { // Try and load minion +if (PHP_SAPI == 'cli') { + // Try and load minion class_exists('Minion_Task') OR die('Please enable the Minion module for CLI support.'); - set_exception_handler(array('Minion_Exception', 'handler')); + set_exception_handler(['Minion_Exception', 'handler']); Minion_Task::factory(Minion_CLI::options())->execute(); } else { @@ -107,7 +108,7 @@ class_exists('Minion_Task') OR die('Please enable the Minion module for CLI supp * Execute the main request. A source of the URI can be passed, eg: $_SERVER['PATH_INFO']. * If no source is specified, the URI will be automatically detected. */ - echo Request::factory(TRUE, array(), FALSE) + echo Request::factory(TRUE, [], FALSE) ->execute() ->send_headers(TRUE) ->body(); diff --git a/system/classes/Kohana/Arr.php b/system/classes/Kohana/Arr.php index 75c505c..aa3efe9 100644 --- a/system/classes/Kohana/Arr.php +++ b/system/classes/Kohana/Arr.php @@ -22,7 +22,7 @@ class Kohana_Arr * Tests if an array is associative or not. * * // Returns TRUE - * Arr::is_assoc(array('username' => 'john.doe')); + * Arr::is_assoc(['username' => 'john.doe']); * * // Returns FALSE * Arr::is_assoc('foo', 'bar'); @@ -78,7 +78,7 @@ public static function is_array($value) * $colors = Arr::path($array, 'theme.*.color'); * * // Using an array of keys - * $colors = Arr::path($array, array('theme', '*', 'color')); + * $colors = Arr::path($array, ['theme', '*', 'color']); * * @param array $array array to search * @param mixed $path key path string (delimiter separated) or array of keys @@ -386,7 +386,7 @@ public static function map($callbacks, $array, $keys = null) * $john = Arr::merge($john, $mary); * * // The output of $john will now be: - * array('name' => 'mary', 'children' => array('fred', 'paul', 'sally', 'jane')) + * ['name' => 'mary', 'children' => ['fred', 'paul', 'sally', 'jane']] * * @param array $array1 initial array * @param array $array2,... array to merge @@ -450,7 +450,7 @@ public static function merge($array1, $array2) * $array = Arr::overwrite($a1, $a2); * * // The output of $array will now be: - * array('name' => 'jack', 'mood' => 'happy', 'food' => 'tacos') + * ['name' => 'jack', 'mood' => 'happy', 'food' => 'tacos'] * * @param array $array1 master array * @param array $array2 input arrays that will overwrite existing values @@ -523,7 +523,7 @@ public static function callback($str) * $array = Arr::flatten($array); * * // The array will now be - * array('one' => 'something', 'two' => 'other'); + * ['one' => 'something', 'two' => 'other']; * * [!!] The keys of array values will be discarded. * diff --git a/system/classes/Kohana/Date.php b/system/classes/Kohana/Date.php index 8f4dc0e..56dbb74 100644 --- a/system/classes/Kohana/Date.php +++ b/system/classes/Kohana/Date.php @@ -248,17 +248,17 @@ public static function days($month, $year = false) * By default a mirrored array of $month_number => $month_number is returned * * Date::months(); - * // aray(1 => 1, 2 => 2, 3 => 3, ..., 12 => 12) + * // [1 => 1, 2 => 2, 3 => 3, ..., 12 => 12] * * But you can customise this by passing in either Date::MONTHS_LONG * * Date::months(Date::MONTHS_LONG); - * // array(1 => 'January', 2 => 'February', ..., 12 => 'December') + * // [1 => 'January', 2 => 'February', ..., 12 => 'December'] * * Or Date::MONTHS_SHORT * * Date::months(Date::MONTHS_SHORT); - * // array(1 => 'Jan', 2 => 'Feb', ..., 12 => 'Dec') + * // [1 => 'Jan', 2 => 'Feb', ..., 12 => 'Dec'] * * @uses Date::hours * @param string $format The format to use for months @@ -310,7 +310,7 @@ public static function years($start = false, $end = false) * If the second timestamp is not given, the current time will be used. * Also consider using [Date::fuzzy_span] when displaying a span. * - * $span = Date::span(60, 182, 'minutes,seconds'); // array('minutes' => 2, 'seconds' => 2) + * $span = Date::span(60, 182, 'minutes,seconds'); // ['minutes' => 2, 'seconds' => 2] * $span = Date::span(60, 182, 'minutes'); // 2 * * @param integer $remote timestamp to find the span of diff --git a/system/classes/Kohana/HTTP/Exception/Expected.php b/system/classes/Kohana/HTTP/Exception/Expected.php index f8c9cc5..4c918cd 100644 --- a/system/classes/Kohana/HTTP/Exception/Expected.php +++ b/system/classes/Kohana/HTTP/Exception/Expected.php @@ -24,8 +24,9 @@ abstract class Kohana_HTTP_Exception_Expected extends HTTP_Exception /** * Creates a new translated exception. * - * throw new Kohana_Exception('Something went terrible wrong, :user', - * array(':user' => $user)); + * throw new Kohana_Exception('Something went terrible wrong, :user', [ + * ':user' => $user + * ]); * * @param string $message status message, custom content to display with error * @param array $variables translation variables diff --git a/system/classes/Kohana/Log.php b/system/classes/Kohana/Log.php index 7377f9a..1e1c02f 100644 --- a/system/classes/Kohana/Log.php +++ b/system/classes/Kohana/Log.php @@ -82,11 +82,10 @@ public function attach(Log_Writer $writer, $levels = [], $min_level = 0) $levels = range($min_level, $levels); } - $this->_writers["{$writer}"] = array - ( + $this->_writers["{$writer}"] = [ 'object' => $writer, 'levels' => $levels - ); + ]; return $this; } @@ -148,8 +147,7 @@ public function add($level, $message, array $values = null, array $additional = } // Create a new message - $this->_messages[] = array - ( + $this->_messages[] = [ 'time' => time(), 'level' => $level, 'body' => $message, @@ -159,7 +157,7 @@ public function add($level, $message, array $values = null, array $additional = 'class' => isset($trace[0]['class']) ? $trace[0]['class'] : null, 'function' => isset($trace[0]['function']) ? $trace[0]['function'] : null, 'additional' => $additional, - ); + ]; if (Log::$write_on_add) { // Write logs as they are added diff --git a/system/classes/Kohana/Num.php b/system/classes/Kohana/Num.php index d08b544..e4a4614 100644 --- a/system/classes/Kohana/Num.php +++ b/system/classes/Kohana/Num.php @@ -22,8 +22,7 @@ class Kohana_Num /** * @var array Valid byte units => power of 2 that defines the unit's size */ - public static $byte_units = array - ( + public static $byte_units = [ 'B' => 0, 'K' => 10, 'Ki' => 10, @@ -57,7 +56,7 @@ class Kohana_Num 'Yi' => 80, 'YB' => 80, 'YiB' => 80, - ); + ]; /** * Returns the English ordinal suffix (th, st, nd, etc) of a number. diff --git a/system/classes/Kohana/Profiler.php b/system/classes/Kohana/Profiler.php index 895e020..cd7cf02 100644 --- a/system/classes/Kohana/Profiler.php +++ b/system/classes/Kohana/Profiler.php @@ -43,8 +43,7 @@ public static function start($group, $name) // Create a unique token based on the counter $token = 'kp/' . base_convert($counter++, 10, 32); - Profiler::$_marks[$token] = array - ( + Profiler::$_marks[$token] = [ 'group' => strtolower($group), 'name' => (string) $name, // Start the benchmark @@ -53,7 +52,7 @@ public static function start($group, $name) // Set the stop keys without values 'stop_time' => false, 'stop_memory' => false, - ); + ]; return $token; } @@ -276,13 +275,12 @@ public static function total($token) $mark['stop_memory'] = memory_get_usage(); } - return array - ( + return [ // Total time in seconds $mark['stop_time'] - $mark['start_time'], // Amount of memory in bytes $mark['stop_memory'] - $mark['start_memory'], - ); + ]; } /** diff --git a/system/classes/Kohana/Validation.php b/system/classes/Kohana/Validation.php index 3f10156..f8cb59b 100644 --- a/system/classes/Kohana/Validation.php +++ b/system/classes/Kohana/Validation.php @@ -322,14 +322,13 @@ public function check() $value = $this[$field]; // Bind the field name and value to :field and :value respectively - $this->bind(array - ( + $this->bind([ ':field' => $field, ':value' => $value, - )); + ]); foreach ($set as $array) { - // Rules are defined as array($rule, $params) + // Rules are defined as [$rule, $params] list($rule, $params) = $array; foreach ($params as $key => $param) { diff --git a/system/koharness.php b/system/koharness.php index 8c2a792..9c62369 100644 --- a/system/koharness.php +++ b/system/koharness.php @@ -1,9 +1,9 @@ array( +return [ + 'modules' => [ 'unittest' => __DIR__ . '/vendor/kohana/unittest' - ), + ], 'syspath' => __DIR__, -); +]; diff --git a/system/messages/tests/validation/error_type_check.php b/system/messages/tests/validation/error_type_check.php index 98e6de9..2b93425 100644 --- a/system/messages/tests/validation/error_type_check.php +++ b/system/messages/tests/validation/error_type_check.php @@ -2,8 +2,8 @@ defined('SYSPATH') OR die('No direct script access.'); -return array( - 'email' => array( +return [ + 'email' => [ 'custom' => 'very nice email address you have there', - ), -); + ], +]; diff --git a/system/messages/validation.php b/system/messages/validation.php index 171a9dd..0387af1 100644 --- a/system/messages/validation.php +++ b/system/messages/validation.php @@ -2,7 +2,7 @@ defined('SYSPATH') OR die('No direct script access.'); -return array( +return [ 'alpha' => ':field must contain only letters', 'alpha_dash' => ':field must contain only numbers, letters and dashes', 'alpha_numeric' => ':field must contain only letters and numbers', @@ -26,4 +26,4 @@ 'range' => ':field must be within the range of :param2 to :param3', 'regex' => ':field does not match the required format', 'url' => ':field must be a url', -); +];