Skip to content

Commit

Permalink
Convert array delcarations to short array syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
dhensby committed Apr 20, 2020
1 parent 6367c3b commit 237b2d5
Show file tree
Hide file tree
Showing 588 changed files with 5,029 additions and 5,029 deletions.
6 changes: 3 additions & 3 deletions src/Control/CLIRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static function cleanEnvironment(array $variables)
}

// We update the $_SERVER variable to contain data consistent with the rest of the application.
$variables['_SERVER'] = array_merge(array(
$variables['_SERVER'] = array_merge([
'SERVER_PROTOCOL' => 'HTTP/1.1',
'HTTP_ACCEPT' => 'text/plain;q=0.5',
'HTTP_ACCEPT_LANGUAGE' => '*;q=0.5',
Expand All @@ -31,7 +31,7 @@ public static function cleanEnvironment(array $variables)
'REMOTE_ADDR' => '127.0.0.1',
'REQUEST_METHOD' => 'GET',
'HTTP_USER_AGENT' => 'CLI',
), $variables['_SERVER']);
], $variables['_SERVER']);

/**
* Process arguments and load them into the $_GET and $_REQUEST arrays
Expand All @@ -51,7 +51,7 @@ public static function cleanEnvironment(array $variables)
if (strpos($arg, '=') == false) {
$variables['_GET']['args'][] = $arg;
} else {
$newItems = array();
$newItems = [];
parse_str((substr($arg, 0, 2) == '--') ? substr($arg, 2) : $arg, $newItems);
$variables['_GET'] = array_merge($variables['_GET'], $newItems);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Control/CliController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
abstract class CliController extends Controller
{

private static $allowed_actions = array(
private static $allowed_actions = [
'index'
);
];

protected function init()
{
Expand Down
12 changes: 6 additions & 6 deletions src/Control/ContentNegotiator.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ public static function process(HTTPResponse $response)
return;
}

$mimes = array(
$mimes = [
"xhtml" => "application/xhtml+xml",
"html" => "text/html",
);
$q = array();
];
$q = [];
if (headers_sent()) {
$chosenFormat = static::config()->get('default_format');
} elseif (isset($_GET['forceFormat'])) {
Expand All @@ -140,7 +140,7 @@ public static function process(HTTPResponse $response)
$chosenFormat = "xhtml";
} else {
foreach ($mimes as $format => $mime) {
$regExp = '/' . str_replace(array('+', '/'), array('\+', '\/'), $mime) . '(;q=(\d+\.\d+))?/i';
$regExp = '/' . str_replace(['+', '/'], ['\+', '\/'], $mime) . '(;q=(\d+\.\d+))?/i';
if (isset($_SERVER['HTTP_ACCEPT']) && preg_match($regExp, $_SERVER['HTTP_ACCEPT'], $matches)) {
$preference = isset($matches[2]) ? $matches[2] : 1;
if (!isset($q[$preference])) {
Expand Down Expand Up @@ -237,8 +237,8 @@ public function html(HTTPResponse $response)

$content = preg_replace("#<\\?xml[^>]+\\?>\n?#", '', $content);
$content = str_replace(
array('/>', 'xml:lang', 'application/xhtml+xml'),
array('>', 'lang', 'text/html'),
['/>', 'xml:lang', 'application/xhtml+xml'],
['>', 'lang', 'text/html'],
$content
);

Expand Down
20 changes: 10 additions & 10 deletions src/Control/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Controller extends RequestHandler implements TemplateGlobalProvider
*
* @var array
*/
protected static $controller_stack = array();
protected static $controller_stack = [];

/**
* Assign templates for this controller.
Expand Down Expand Up @@ -83,17 +83,17 @@ class Controller extends RequestHandler implements TemplateGlobalProvider
*
* @var array
*/
private static $url_handlers = array(
private static $url_handlers = [
'$Action//$ID/$OtherID' => 'handleAction',
);
];

/**
* @var array
*/
private static $allowed_actions = array(
private static $allowed_actions = [
'handleAction',
'handleIndex',
);
];

/**
* Initialisation function that is run before any action on the controller is called.
Expand Down Expand Up @@ -495,7 +495,7 @@ public function hasActionTemplate($action)
}

$parentClass = static::class;
$templates = array();
$templates = [];

while ($parentClass != __CLASS__) {
$templates[] = strtok($parentClass, '_') . '_' . $action;
Expand Down Expand Up @@ -583,7 +583,7 @@ public function can($perm, $member = null)
$member = Security::getCurrentUser();
}
if (is_array($perm)) {
$perm = array_map(array($this, 'can'), $perm, array_fill(0, count($perm), $member));
$perm = array_map([$this, 'can'], $perm, array_fill(0, count($perm), $member));
return min($perm);
}
if ($this->hasMethod($methodName = 'can' . $perm)) {
Expand Down Expand Up @@ -672,7 +672,7 @@ public static function join_links($arg = null)
$args = func_get_args();
}
$result = "";
$queryargs = array();
$queryargs = [];
$fragmentIdentifier = null;

foreach ($args as $arg) {
Expand Down Expand Up @@ -712,8 +712,8 @@ public static function join_links($arg = null)
*/
public static function get_template_global_variables()
{
return array(
return [
'CurrentPage' => 'curr',
);
];
}
}
10 changes: 5 additions & 5 deletions src/Control/CookieJar.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ class CookieJar implements Cookie_Backend
*
* @var array Existing cookies sent by the browser
*/
protected $existing = array();
protected $existing = [];

/**
* Hold the current cookies (ie: a mix of those that were sent to us and we
* have set without the ones we've cleared)
*
* @var array The state of cookies once we've sent the response
*/
protected $current = array();
protected $current = [];

/**
* Hold any NEW cookies that were set by the application and will be sent
* in the next response
*
* @var array New cookies set by the application
*/
protected $new = array();
protected $new = [];

/**
* When creating the backend we want to store the existing cookies in our
Expand All @@ -51,10 +51,10 @@ class CookieJar implements Cookie_Backend
* @param array $cookies The existing cookies to load into the cookie jar.
* Omit this to default to $_COOKIE
*/
public function __construct($cookies = array())
public function __construct($cookies = [])
{
$this->current = $this->existing = func_num_args()
? ($cookies ?: array()) // Convert empty values to blank arrays
? ($cookies ?: []) // Convert empty values to blank arrays
: $_COOKIE;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Control/Cookie_Backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface Cookie_Backend
*
* @param array $cookies The existing cookies to load into the cookie jar
*/
public function __construct($cookies = array());
public function __construct($cookies = []);

/**
* Set a cookie
Expand Down
18 changes: 9 additions & 9 deletions src/Control/Director.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Director implements TemplateGlobalProvider
* @config
* @var array
*/
private static $rules = array();
private static $rules = [];

/**
* Set current page
Expand Down Expand Up @@ -122,11 +122,11 @@ public function __construct()
public static function test(
$url,
$postVars = [],
$session = array(),
$session = [],
$httpMethod = null,
$body = null,
$headers = array(),
$cookies = array(),
$headers = [],
$cookies = [],
&$request = null
) {
return static::mockRequest(
Expand Down Expand Up @@ -226,7 +226,7 @@ public static function mockRequest(
// Setup cookies
$cookieJar = $cookies instanceof Cookie_Backend
? $cookies
: Injector::inst()->createWithArgs(Cookie_Backend::class, array($cookies ?: []));
: Injector::inst()->createWithArgs(Cookie_Backend::class, [$cookies ?: []]);
$newVars['_COOKIE'] = $cookieJar->getAll(false);
Cookie::config()->update('report_errors', false);
Injector::inst()->registerService($cookieJar, Cookie_Backend::class);
Expand Down Expand Up @@ -326,9 +326,9 @@ public function handleRequest(HTTPRequest $request)
// Normalise route rule
if (is_string($controllerOptions)) {
if (substr($controllerOptions, 0, 2) == '->') {
$controllerOptions = array('Redirect' => substr($controllerOptions, 2));
$controllerOptions = ['Redirect' => substr($controllerOptions, 2)];
} else {
$controllerOptions = array('Controller' => $controllerOptions);
$controllerOptions = ['Controller' => $controllerOptions];
}
}
$request->setRouteParams($controllerOptions);
Expand Down Expand Up @@ -1131,13 +1131,13 @@ public static function isTest()
*/
public static function get_template_global_variables()
{
return array(
return [
'absoluteBaseURL',
'baseURL',
'is_ajax',
'isAjax' => 'is_ajax',
'BaseHref' => 'absoluteBaseURL', //@deprecated 3.0
);
];
}

/**
Expand Down
14 changes: 7 additions & 7 deletions src/Control/Email/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,25 @@ class Email extends ViewableData
* @var array
* @config
*/
private static $send_all_emails_to = array();
private static $send_all_emails_to = [];

/**
* @var array
* @config
*/
private static $cc_all_emails_to = array();
private static $cc_all_emails_to = [];

/**
* @var array
* @config
*/
private static $bcc_all_emails_to = array();
private static $bcc_all_emails_to = [];

/**
* @var array
* @config
*/
private static $send_all_emails_from = array();
private static $send_all_emails_from = [];

/**
* This will be set in the config on a site-by-site basis
Expand Down Expand Up @@ -80,12 +80,12 @@ class Email extends ViewableData
* @var array|ViewableData Additional data available in a template.
* Used in the same way than {@link ViewableData->customize()}.
*/
private $data = array();
private $data = [];

/**
* @var array
*/
private $failedRecipients = array();
private $failedRecipients = [];

/**
* Checks for RFC822-valid email format.
Expand Down Expand Up @@ -188,7 +188,7 @@ public static function obfuscate($email, $method = 'visible')

return '<span class="codedirection">' . strrev($email) . '</span>';
case 'visible':
$obfuscated = array('@' => ' [at] ', '.' => ' [dot] ', '-' => ' [dash] ');
$obfuscated = ['@' => ' [at] ', '.' => ' [dot] ', '-' => ' [dash] '];

return strtr($email, $obfuscated);
case 'hex':
Expand Down
6 changes: 3 additions & 3 deletions src/Control/Email/SwiftMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class SwiftMailer implements Mailer
* @var array
* @config
*/
private static $swift_plugins = array(
private static $swift_plugins = [
SwiftPlugin::class,
);
];

/**
* @var Swift_Mailer
Expand All @@ -38,7 +38,7 @@ class SwiftMailer implements Mailer
public function send($message)
{
$swiftMessage = $message->getSwiftMessage();
$failedRecipients = array();
$failedRecipients = [];
$result = $this->sendSwift($swiftMessage, $failedRecipients);
$message->setFailedRecipients($failedRecipients);

Expand Down
Loading

0 comments on commit 237b2d5

Please sign in to comment.