Merge pull request #9473 from dhensby/pulls/short-array-docs

Use short array syntax across the framework's codebase
This commit is contained in:
Daniel Hensby 2020-05-16 10:46:05 +01:00 committed by GitHub
commit 295fc7c2ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
43 changed files with 217 additions and 217 deletions

View File

@ -6,7 +6,7 @@ use SilverStripe\Dev\Install\MySQLDatabaseConfigurationHelper;
// Register MySQLi as a database adapter (listed as second option in Dev/Install/config-form.html) // Register MySQLi as a database adapter (listed as second option in Dev/Install/config-form.html)
DatabaseAdapterRegistry::register( DatabaseAdapterRegistry::register(
array( [
/** @skipUpgrade */ /** @skipUpgrade */
'class' => 'MySQLDatabase', 'class' => 'MySQLDatabase',
'module' => 'framework', 'module' => 'framework',
@ -17,12 +17,12 @@ DatabaseAdapterRegistry::register(
'missingExtensionText' => 'missingExtensionText' =>
'The <a href="http://www.php.net/manual/en/book.mysqli.php">MySQLi</a> 'The <a href="http://www.php.net/manual/en/book.mysqli.php">MySQLi</a>
PHP extension is not available. Please install or enable it and refresh this page.' PHP extension is not available. Please install or enable it and refresh this page.'
) ]
); );
// Register MySQL PDO as a database adapter (listed as first option in Dev/Install/config-form.html) // Register MySQL PDO as a database adapter (listed as first option in Dev/Install/config-form.html)
DatabaseAdapterRegistry::register( DatabaseAdapterRegistry::register(
array( [
/** @skipUpgrade */ /** @skipUpgrade */
'class' => 'MySQLPDODatabase', 'class' => 'MySQLPDODatabase',
'module' => 'framework', 'module' => 'framework',
@ -34,5 +34,5 @@ DatabaseAdapterRegistry::register(
'Either the <a href="http://www.php.net/manual/en/book.pdo.php">PDO Extension</a> or 'Either the <a href="http://www.php.net/manual/en/book.pdo.php">PDO Extension</a> or
the <a href="http://www.php.net/manual/en/ref.pdo-mysql.php">MySQL PDO Driver</a> the <a href="http://www.php.net/manual/en/ref.pdo-mysql.php">MySQL PDO Driver</a>
are unavailable. Please install or enable these and refresh this page.' are unavailable. Please install or enable these and refresh this page.'
) ]
); );

View File

@ -481,10 +481,10 @@ $players = Player::get()->exclude([
`Exclude` follows the same pattern as filter, so for removing only Sam Minnée from the list: `Exclude` follows the same pattern as filter, so for removing only Sam Minnée from the list:
```php ```php
$players = Player::get()->exclude(array( $players = Player::get()->exclude([
'FirstName' => 'Sam', 'FirstName' => 'Sam',
'Surname' => 'Minnée', 'Surname' => 'Minnée',
)); ]);
// SELECT * FROM Player WHERE (FirstName != 'Sam' OR LastName != 'Minnée') // SELECT * FROM Player WHERE (FirstName != 'Sam' OR LastName != 'Minnée')
``` ```

View File

@ -209,7 +209,7 @@ If you're using the default scaffolded form fields with multiple `has_one` relat
public function getCMSFields() public function getCMSFields()
{ {
$fields = parent::getCMSFields(); $fields = parent::getCMSFields();
$fields->removeByName(array('ManagerID', 'CleanerID')); $fields->removeByName(['ManagerID', 'CleanerID']);
return $fields; return $fields;
} }
``` ```

View File

@ -51,11 +51,11 @@ A map is an array where the array indexes contain data as well as the values. Yo
```php ```php
$members = Member::get()->map('ID', 'FirstName'); $members = Member::get()->map('ID', 'FirstName');
// $members = array( // $members = [
// 1 => 'Sam' // 1 => 'Sam'
// 2 => 'Sig' // 2 => 'Sig'
// 3 => 'Will' // 3 => 'Will'
// ); // ];
``` ```
This functionality is provided by the [Map](api:SilverStripe\ORM\Map) class, which can be used to build a map around any `SS_List`. This functionality is provided by the [Map](api:SilverStripe\ORM\Map) class, which can be used to build a map around any `SS_List`.
@ -72,11 +72,11 @@ $members = Member::get();
echo $members->column('Email'); echo $members->column('Email');
// returns array( // returns [
// 'sam@silverstripe.com', // 'sam@silverstripe.com',
// 'sig@silverstripe.com', // 'sig@silverstripe.com',
// 'will@silverstripe.com' // 'will@silverstripe.com'
// ); // ];
``` ```
## ArrayList ## ArrayList

View File

@ -62,7 +62,7 @@ class Car extends DataObject
{ {
private static $db = [ private static $db = [
'Wheels' => 'Int', 'Wheels' => 'Int',
'Condition' => 'Enum(array("New","Fair","Junk"))' 'Condition' => 'Enum(["New","Fair","Junk"])'
]; ];
private static $defaults = [ private static $defaults = [
@ -93,7 +93,7 @@ class Car extends DataObject
{ {
private static $db = [ private static $db = [
'Wheels' => 'Int(4)', 'Wheels' => 'Int(4)',
'Condition' => 'Enum(array("New","Fair","Junk"), "New")', 'Condition' => 'Enum(["New","Fair","Junk"], "New")',
'Make' => 'Varchar(["default" => "Honda"])', 'Make' => 'Varchar(["default" => "Honda"])',
); );
} }
@ -229,7 +229,7 @@ use SilverStripe\ORM\DataObject;
class Player extends DataObject class Player extends DataObject
{ {
private static $db = [ private static $db = [
"Status" => "Enum(array('Active', 'Injured', 'Retired'))" "Status" => "Enum(['Active', 'Injured', 'Retired'])"
]; ];
public function getStatus() public function getStatus()

View File

@ -147,10 +147,10 @@ API methods:
but also supports SQL expressions as values if necessary but also supports SQL expressions as values if necessary
* `setAssignments` - Replaces all existing assignments with the specified list * `setAssignments` - Replaces all existing assignments with the specified list
* `getAssignments` - Returns all currently given assignments, as an associative array * `getAssignments` - Returns all currently given assignments, as an associative array
in the format `array('Column' => array('SQL' => array('parameters)))` in the format `['Column' => ['SQL' => ['parameters]]]`
* `assign` - Singular form of addAssignments, but only assigns a single column value * `assign` - Singular form of addAssignments, but only assigns a single column value
* `assignSQL` - Assigns a column the value of a specified SQL expression without parameters * `assignSQL` - Assigns a column the value of a specified SQL expression without parameters
`assignSQL('Column', 'SQL)` is shorthand for `assign('Column', array('SQL' => array()))` `assignSQL('Column', 'SQL)` is shorthand for `assign('Column', ['SQL' => []])`
SQLUpdate also includes the following API methods: SQLUpdate also includes the following API methods:
@ -225,7 +225,7 @@ $insert->assign('"Content"', '<p>This is about us</p>');
$insert->addRow(['"Title"' => 'Contact Us']); $insert->addRow(['"Title"' => 'Contact Us']);
$columns = $insert->getColumns(); $columns = $insert->getColumns();
// $columns will be array('"Title"', '"Content"', '"ClassName"'); // $columns will be ['"Title"', '"Content"', '"ClassName"'];
$insert->execute(); $insert->execute();
``` ```

View File

@ -93,7 +93,7 @@ If your caching logic is complex or re-usable, you can define a method on your c
fragment. fragment.
For example, a block that shows a collection of rotating slides needs to update whenever the relationship For example, a block that shows a collection of rotating slides needs to update whenever the relationship
`Page::$many_many = array('Slides' => 'Slide')` changes. In `PageController`: `Page::$many_many = ['Slides' => 'Slide']` changes. In `PageController`:
```php ```php

View File

@ -41,10 +41,10 @@ You can define subclasses of [Member](api:SilverStripe\Security\Member) to add e
use SilverStripe\Security\Member; use SilverStripe\Security\Member;
class MyMember extends Member { class MyMember extends Member {
private static $db = array( private static $db = [
"Age" => "Int", "Age" => "Int",
"Address" => "Text", "Address" => "Text",
); ];
} }
``` ```

View File

@ -72,7 +72,7 @@ echo $session->get('MyValue');
// returns 6 // returns 6
$data = $session->get('MyArrayOfValues'); $data = $session->get('MyArrayOfValues');
// $data = array(1,2,3) // $data = [1,2,3]
$object = unserialize($session->get('MyObject', $object)); $object = unserialize($session->get('MyObject', $object));
// $object = Object() // $object = Object()

View File

@ -371,12 +371,12 @@ E.g.
:::php :::php
class MyObject extends DataObject class MyObject extends DataObject
{ {
private static $has_one = array( private static $has_one = [
"ImageObject" => "Image" "ImageObject" => "Image"
); ];
private static $db = array( private static $db = [
"ImageField" => "DBFile('image/supported')" "ImageField" => "DBFile('image/supported')"
); ];
} }
@ -518,12 +518,12 @@ The below describes the minimum amount of effort required to implement a composi
class MyAddressField extends DBComposite class MyAddressField extends DBComposite
{ {
private static $composite_db = array( private static $composite_db = [
'Street' => 'Varchar(200)', 'Street' => 'Varchar(200)',
'Suburb' => 'Varchar(100)', 'Suburb' => 'Varchar(100)',
'City' => 'Varchar(100)', 'City' => 'Varchar(100)',
'Country' => 'Varchar(100)' 'Country' => 'Varchar(100)'
); ];
public function scaffoldFormField($title = null) public function scaffoldFormField($title = null)
{ {

View File

@ -362,7 +362,7 @@ class Email extends ViewableData
* Set recipient(s) of the email * Set recipient(s) of the email
* *
* To send to many, pass an array: * To send to many, pass an array:
* array('me@example.com' => 'My Name', 'other@example.com'); * ['me@example.com' => 'My Name', 'other@example.com'];
* *
* @param string|array $address The message recipient(s) - if sending to multiple, use an array of address => name * @param string|array $address The message recipient(s) - if sending to multiple, use an array of address => name
* @param string|null $name The name of the recipient (if one) * @param string|null $name The name of the recipient (if one)

View File

@ -57,19 +57,19 @@ abstract class BulkLoader extends ViewableData
* <code> * <code>
* <?php * <?php
* // simple example * // simple example
* array( * [
* 'Title', * 'Title',
* 'Birthday' * 'Birthday'
* ) * ]
* *
* // complex example * // complex example
* array( * [
* 'first name' => 'FirstName', // custom column name * 'first name' => 'FirstName', // custom column name
* null, // ignored column * null, // ignored column
* 'RegionID', // direct has_one/has_many ID setting * 'RegionID', // direct has_one/has_many ID setting
* 'OrganisationTitle', // create has_one relation to existing record using $relationCallbacks * 'OrganisationTitle', // create has_one relation to existing record using $relationCallbacks
* 'street' => 'Organisation.StreetName', // match an existing has_one or create one and write property. * 'street' => 'Organisation.StreetName', // match an existing has_one or create one and write property.
* ); * ];
* ?> * ?>
* </code> * </code>
* *
@ -82,12 +82,12 @@ abstract class BulkLoader extends ViewableData
* *
* <code> * <code>
* <?php * <?php
* array( * [
* 'OrganisationTitle' => array( * 'OrganisationTitle' => [
* 'relationname' => 'Organisation', // relation accessor name * 'relationname' => 'Organisation', // relation accessor name
* 'callback' => 'getOrganisationByTitle', * 'callback' => 'getOrganisationByTitle',
* ); * ];
* ); * ];
* ?> * ?>
* </code> * </code>
* *
@ -111,12 +111,12 @@ abstract class BulkLoader extends ViewableData
* *
* <code> * <code>
* <?php * <?php
* array( * [
* 'customernumber' => 'ID', * 'customernumber' => 'ID',
* 'phonenumber' => array( * 'phonenumber' => [
* 'callback' => 'getByImportedPhoneNumber' * 'callback' => 'getByImportedPhoneNumber'
* ) * ]
* ); * ];
* ?> * ?>
* </code> * </code>
* *
@ -211,10 +211,10 @@ abstract class BulkLoader extends ViewableData
* *
* Return Format: * Return Format:
* <code> * <code>
* array( * [
* 'fields' => array('myFieldName'=>'myDescription'), * 'fields' => ['myFieldName'=>'myDescription'],
* 'relations' => array('myRelationName'=>'myDescription'), * 'relations' => ['myRelationName'=>'myDescription'],
* ) * ]
* </code> * </code>
* *
* @todo Mix in custom column mappings * @todo Mix in custom column mappings

View File

@ -30,7 +30,7 @@ class BulkLoader_Result implements \Countable
* *
* Example: * Example:
* <code> * <code>
* array(array('ID'=>1, 'ClassName'=>'Member', 'Message'=>'Updated existing record based on ParentID relation')) * [['ID'=>1, 'ClassName'=>'Member', 'Message'=>'Updated existing record based on ParentID relation']]
* </code> * </code>
* *
* @var array * @var array

View File

@ -31,7 +31,7 @@ use SilverStripe\ORM\DataObjectInterface;
* $actions = new FieldList( * $actions = new FieldList(
* new FormAction('doUpload', 'Upload file') * new FormAction('doUpload', 'Upload file')
* ); * );
* $validator = new RequiredFields(array('MyName', 'MyFile')); * $validator = new RequiredFields(['MyName', 'MyFile']);
* *
* return new Form($this, 'Form', $fields, $actions, $validator); * return new Form($this, 'Form', $fields, $actions, $validator);
* } * }

View File

@ -44,7 +44,7 @@ trait FileUploadReceiver
public $relationAutoSetting = true; public $relationAutoSetting = true;
/** /**
* Parent data record. Will be infered from parent form or controller if blank. * Parent data record. Will be inferred from parent form or controller if blank.
* *
* @var DataObject * @var DataObject
*/ */

View File

@ -13,7 +13,7 @@ use SilverStripe\View\HTML;
* button is selected. Each item is defined through {@link SelectionGroup_Item}. * button is selected. Each item is defined through {@link SelectionGroup_Item}.
* *
* @example <code> * @example <code>
* $items = array( * $items = [
* new SelectionGroup_Item( * new SelectionGroup_Item(
* 'one', * 'one',
* new LiteralField('one', 'one view'), * new LiteralField('one', 'one view'),
@ -24,7 +24,7 @@ use SilverStripe\View\HTML;
* new LiteralField('two', 'two view'), * new LiteralField('two', 'two view'),
* 'two title' * 'two title'
* ), * ),
* ); * ];
* $field = new SelectionGroup('MyGroup', $items); * $field = new SelectionGroup('MyGroup', $items);
* </code> * </code>
* *

View File

@ -26,7 +26,7 @@ class TextareaField extends FormField
*/ */
private static $casting = [ private static $casting = [
'Value' => 'Text', 'Value' => 'Text',
'ValueEntities' => 'HTMLFragment(array(\'shortcodes\' => false))', 'ValueEntities' => 'HTMLFragment([\'shortcodes\' => false])',
]; ];
protected $schemaDataType = FormField::SCHEMA_DATA_TYPE_TEXT; protected $schemaDataType = FormField::SCHEMA_DATA_TYPE_TEXT;

View File

@ -122,7 +122,7 @@ class DBQueryBuilder
foreach ($columns as $column) { foreach ($columns as $column) {
// Check if this column has a value for this row // Check if this column has a value for this row
if (isset($assignments[$column])) { if (isset($assignments[$column])) {
// Assigment is a single item array, expand with a loop here // Assignment is a single item array, expand with a loop here
foreach ($assignments[$column] as $assignmentSQL => $assignmentParameters) { foreach ($assignments[$column] as $assignmentSQL => $assignmentParameters) {
$parts[] = $assignmentSQL; $parts[] = $assignmentSQL;
$parameters = array_merge($parameters, $assignmentParameters); $parameters = array_merge($parameters, $assignmentParameters);
@ -220,7 +220,7 @@ class DBQueryBuilder
// Join SET components together, considering parameters // Join SET components together, considering parameters
$parts = []; $parts = [];
foreach ($query->getAssignments() as $column => $assignment) { foreach ($query->getAssignments() as $column => $assignment) {
// Assigment is a single item array, expand with a loop here // Assignment is a single item array, expand with a loop here
foreach ($assignment as $assignmentSQL => $assignmentParameters) { foreach ($assignment as $assignmentSQL => $assignmentParameters) {
$parts[] = "$column = $assignmentSQL"; $parts[] = "$column = $assignmentSQL";
$parameters = array_merge($parameters, $assignmentParameters); $parameters = array_merge($parameters, $assignmentParameters);

View File

@ -345,7 +345,7 @@ abstract class DBSchemaManager
* @param array $indexSchema A list of indexes to create. See {@link requireIndex()} * @param array $indexSchema A list of indexes to create. See {@link requireIndex()}
* The values of the array can be one of: * The values of the array can be one of:
* - true: Create a single column index on the field named the same as the index. * - true: Create a single column index on the field named the same as the index.
* - array('fields' => array('A','B','C'), 'type' => 'index/unique/fulltext'): This gives you full * - ['fields' => ['A','B','C'], 'type' => 'index/unique/fulltext']: This gives you full
* control over the index. * control over the index.
* @param boolean $hasAutoIncPK A flag indicating that the primary key on this table is an autoincrement type * @param boolean $hasAutoIncPK A flag indicating that the primary key on this table is an autoincrement type
* @param array $options Create table options (ENGINE, etc.) * @param array $options Create table options (ENGINE, etc.)
@ -478,7 +478,7 @@ MESSAGE
* The keys of the array are the names of the index. * The keys of the array are the names of the index.
* The values of the array can be one of: * The values of the array can be one of:
* - true: Create a single column index on the field named the same as the index. * - true: Create a single column index on the field named the same as the index.
* - array('type' => 'index|unique|fulltext', 'value' => 'FieldA, FieldB'): This gives you full * - ['type' => 'index|unique|fulltext', 'value' => 'FieldA, FieldB']: This gives you full
* control over the index. * control over the index.
* *
* @param string $table The table name. * @param string $table The table name.
@ -536,7 +536,7 @@ MESSAGE
$containedSpec = preg_replace('/(.*\(\s*)|(\s*\).*)/', '', $spec); $containedSpec = preg_replace('/(.*\(\s*)|(\s*\).*)/', '', $spec);
// Split potentially quoted modifiers // Split potentially quoted modifiers
// E.g. 'Title, "QuotedColumn"' => array('Title', 'QuotedColumn') // E.g. 'Title, "QuotedColumn"' => ['Title', 'QuotedColumn']
return preg_split('/"?\s*,\s*"?/', trim($containedSpec, '(") ')); return preg_split('/"?\s*,\s*"?/', trim($containedSpec, '(") '));
} }

View File

@ -729,7 +729,7 @@ class DataObjectSchema
* *
* Standard many_many return type is: * Standard many_many return type is:
* *
* array( * [
* <manyManyClass>, Name of class for relation. E.g. "Categories" * <manyManyClass>, Name of class for relation. E.g. "Categories"
* <classname>, The class that relation is defined in e.g. "Product" * <classname>, The class that relation is defined in e.g. "Product"
* <candidateName>, The target class of the relation e.g. "Category" * <candidateName>, The target class of the relation e.g. "Category"
@ -738,7 +738,7 @@ class DataObjectSchema
* <joinTableOrRelation> The join table between the two classes e.g. "Product_Categories". * <joinTableOrRelation> The join table between the two classes e.g. "Product_Categories".
* If the class name is 'ManyManyThroughList' then this is the name of the * If the class name is 'ManyManyThroughList' then this is the name of the
* has_many relation. * has_many relation.
* ) * ]
* *
* @param string $class Name of class to get component for * @param string $class Name of class to get component for
* @param string $component The component name * @param string $component The component name

View File

@ -38,12 +38,12 @@ class DataQuery
* Map of all field names to an array of conflicting column SQL * Map of all field names to an array of conflicting column SQL
* *
* E.g. * E.g.
* array( * [
* 'Title' => array( * 'Title' => [
* '"MyTable"."Title"', * '"MyTable"."Title"',
* '"AnotherTable"."Title"', * '"AnotherTable"."Title"',
* ) * ]
* ) * ]
* *
* @var array * @var array
*/ */

View File

@ -56,7 +56,7 @@ class DBEnum extends DBString
* "MyField" => "Enum('Val1, Val2, Val3')" // First item 'Val1' is default implicitly * "MyField" => "Enum('Val1, Val2, Val3')" // First item 'Val1' is default implicitly
* "MyField" => "Enum('Val1, Val2, Val3', 'Val2')" // 'Val2' is default explicitly * "MyField" => "Enum('Val1, Val2, Val3', 'Val2')" // 'Val2' is default explicitly
* "MyField" => "Enum('Val1, Val2, Val3', null)" // Force empty (no) default * "MyField" => "Enum('Val1, Val2, Val3', null)" // Force empty (no) default
* "MyField" => "Enum(array('Val1', 'Val2', 'Val3'), 'Val1')" // Supports array notation as well * "MyField" => "Enum(['Val1', 'Val2', 'Val3'], 'Val1')" // Supports array notation as well
* </code> * </code>
* *
* @param string $name * @param string $name

View File

@ -7,10 +7,10 @@ namespace SilverStripe\ORM\FieldType;
* *
* Example instantiation in {@link DataObject::$db}: * Example instantiation in {@link DataObject::$db}:
* <code> * <code>
* static $db = array( * static $db = [
* "SuccessRatio" => "Percentage", * "SuccessRatio" => "Percentage",
* "ReallyAccurate" => "Percentage(6)", * "ReallyAccurate" => "Percentage(6)",
* ); * ];
* </code> * </code>
*/ */
class DBPercentage extends DBDecimal class DBPercentage extends DBDecimal

View File

@ -14,12 +14,12 @@ class SQLAssignmentRow
* List of field values to store for this query * List of field values to store for this query
* *
* Each item in this array will be in the form of a single-length array * Each item in this array will be in the form of a single-length array
* in the format array('sql' => array($parameters)). * in the format ['sql' => [$parameters]].
* The field name is stored as the key * The field name is stored as the key
* *
* E.g. * E.g.
* *
* <code>$assignments['ID'] = array('?' => array(1));</code> * <code>$assignments['ID'] = ['?' => [1]];</code>
* *
* This allows for complex, parameterised updates, or explict field values set * This allows for complex, parameterised updates, or explict field values set
* without any prameters * without any prameters
@ -45,7 +45,7 @@ class SQLAssignmentRow
* *
* @param mixed $value Either a literal field value, or an array with * @param mixed $value Either a literal field value, or an array with
* placeholder => parameter(s) as a pair * placeholder => parameter(s) as a pair
* @return array A single item array in the format array($sql => array($parameters)) * @return array A single item array in the format [$sql => [$parameters]]
*/ */
protected function parseAssignment($value) protected function parseAssignment($value)
{ {
@ -57,7 +57,7 @@ class SQLAssignmentRow
// If given as array then extract and check both the SQL as well as the parameter(s) // If given as array then extract and check both the SQL as well as the parameter(s)
// Note that there could be multiple parameters, e.g. // Note that there could be multiple parameters, e.g.
// array('MAX(?,?)' => array(1,2)) although the container should // ['MAX(?,?)' => [1,2]] although the container should
// have a single item // have a single item
if (count($value) == 1) { if (count($value) == 1) {
foreach ($value as $sql => $parameters) { foreach ($value as $sql => $parameters) {
@ -76,13 +76,13 @@ class SQLAssignmentRow
throw new InvalidArgumentException( throw new InvalidArgumentException(
"Nested field assignments should be given as a single parameterised item array in " "Nested field assignments should be given as a single parameterised item array in "
. "array('?' => array('value')) format)" . "['?' => ['value']] format)"
); );
} }
/** /**
* Given a list of assignments in any user-acceptible format, normalise the * Given a list of assignments in any user-acceptible format, normalise the
* value to a common array('SQL' => array(parameters)) format * value to a common ['SQL' => [parameters]] format
* *
* @param array $assignments List of assignments. * @param array $assignments List of assignments.
* The key of this array should be the field name, and the value the assigned * The key of this array should be the field name, and the value the assigned
@ -107,27 +107,27 @@ class SQLAssignmentRow
* <code> * <code>
* *
* // Basic assignments * // Basic assignments
* $query->addAssignments(array( * $query->addAssignments([
* '"Object"."Title"' => 'Bob', * '"Object"."Title"' => 'Bob',
* '"Object"."Description"' => 'Bob was here' * '"Object"."Description"' => 'Bob was here'
* )) * ])
* *
* // Parameterised assignments * // Parameterised assignments
* $query->addAssignments(array( * $query->addAssignments([
* '"Object"."Title"' => array('?' => 'Bob')), * '"Object"."Title"' => ['?' => 'Bob'],
* '"Object"."Description"' => array('?' => null)) * '"Object"."Description"' => ['?' => null]
* )) * ])
* *
* // Complex parameters * // Complex parameters
* $query->addAssignments(array( * $query->addAssignments([
* '"Object"."Score"' => array('MAX(?,?)' => array(1, 3)) * '"Object"."Score"' => ['MAX(?,?)' => [1, 3]]
* )); * ]);
* *
* // Assigment of literal SQL for a field. The empty array is * // Assignment of literal SQL for a field. The empty array is
* // important to denote the zero-number paramater list * // important to denote the zero-number paramater list
* $query->addAssignments(array( * $query->addAssignments([
* '"Object"."Score"' => array('NOW()' => array()) * '"Object"."Score"' => ['NOW()' => []]
* )); * ]);
* *
* </code> * </code>
* *
@ -157,9 +157,9 @@ class SQLAssignmentRow
/** /**
* Retrieves the list of assignments in parameterised format * Retrieves the list of assignments in parameterised format
* *
* @return array List of assigments. The key of this array will be the * @return array List of assignments. The key of this array will be the
* column to assign, and the value a parameterised array in the format * column to assign, and the value a parameterised array in the format
* array('SQL' => array(parameters)); * ['SQL' => [parameters]];
*/ */
public function getAssignments() public function getAssignments()
{ {
@ -176,10 +176,10 @@ class SQLAssignmentRow
* $query->assign('"Object"."Description"', 'lorum ipsum'); * $query->assign('"Object"."Description"', 'lorum ipsum');
* *
* // Single parameter * // Single parameter
* $query->assign('"Object"."Title"', array('?' => 'Bob')); * $query->assign('"Object"."Title"', ['?' => 'Bob']);
* *
* // Complex parameters * // Complex parameters
* $query->assign('"Object"."Score"', array('MAX(?,?)' => array(1, 3)); * $query->assign('"Object"."Score"', ['MAX(?,?)' => [1, 3]]);
* </code> * </code>
* *
* @param string $field The field name to update * @param string $field The field name to update

View File

@ -194,7 +194,7 @@ class SQLInsert extends SQLExpression implements SQLWriteExpression
} }
/** /**
* Clears all currently set assigment values on the current row * Clears all currently set assignment values on the current row
* *
* @return $this The self reference to this query * @return $this The self reference to this query
*/ */

View File

@ -31,7 +31,7 @@ class SQLSelect extends SQLConditionalExpression
/** /**
* An array of having clauses. * An array of having clauses.
* Each item in this array will be in the form of a single-length array * Each item in this array will be in the form of a single-length array
* in the format array('predicate' => array($parameters)) * in the format ['predicate' => [$parameters]]
* *
* @var array * @var array
*/ */
@ -124,13 +124,13 @@ class SQLSelect extends SQLConditionalExpression
* *
* <code> * <code>
* // pass fields to select as single parameter array * // pass fields to select as single parameter array
* $query->setSelect(array('"Col1"', '"Col2"'))->setFrom('"MyTable"'); * $query->setSelect(['"Col1"', '"Col2"'])->setFrom('"MyTable"');
* *
* // pass fields to select as multiple parameters * // pass fields to select as multiple parameters
* $query->setSelect('"Col1"', '"Col2"')->setFrom('"MyTable"'); * $query->setSelect('"Col1"', '"Col2"')->setFrom('"MyTable"');
* *
* // Set a list of selected fields as aliases * // Set a list of selected fields as aliases
* $query->setSelect(array('Name' => '"Col1"', 'Details' => '"Col2"')->setFrom('"MyTable"'); * $query->setSelect(['Name' => '"Col1"', 'Details' => '"Col2"'])->setFrom('"MyTable"');
* </code> * </code>
* *
* @param string|array $fields Field names should be ANSI SQL quoted. Array keys should be unquoted. * @param string|array $fields Field names should be ANSI SQL quoted. Array keys should be unquoted.
@ -293,7 +293,7 @@ class SQLSelect extends SQLConditionalExpression
* @example $sql->setOrderBy("Column DESC"); * @example $sql->setOrderBy("Column DESC");
* @example $sql->setOrderBy("Column DESC, ColumnTwo ASC"); * @example $sql->setOrderBy("Column DESC, ColumnTwo ASC");
* @example $sql->setOrderBy("Column", "DESC"); * @example $sql->setOrderBy("Column", "DESC");
* @example $sql->setOrderBy(array("Column" => "ASC", "ColumnTwo" => "DESC")); * @example $sql->setOrderBy(["Column" => "ASC", "ColumnTwo" => "DESC"]);
* *
* @param string|array $clauses Clauses to add (escaped SQL statement) * @param string|array $clauses Clauses to add (escaped SQL statement)
* @param string $direction Sort direction, ASC or DESC * @param string $direction Sort direction, ASC or DESC
@ -313,7 +313,7 @@ class SQLSelect extends SQLConditionalExpression
* @example $sql->addOrderBy("Column DESC"); * @example $sql->addOrderBy("Column DESC");
* @example $sql->addOrderBy("Column DESC, ColumnTwo ASC"); * @example $sql->addOrderBy("Column DESC, ColumnTwo ASC");
* @example $sql->addOrderBy("Column", "DESC"); * @example $sql->addOrderBy("Column", "DESC");
* @example $sql->addOrderBy(array("Column" => "ASC", "ColumnTwo" => "DESC")); * @example $sql->addOrderBy(["Column" => "ASC", "ColumnTwo" => "DESC"]);
* *
* @param string|array $clauses Clauses to add (escaped SQL statements) * @param string|array $clauses Clauses to add (escaped SQL statements)
* @param string $direction Sort direction, ASC or DESC * @param string $direction Sort direction, ASC or DESC
@ -388,7 +388,7 @@ class SQLSelect extends SQLConditionalExpression
* *
* @param string $value * @param string $value
* @param string $defaultDirection * @param string $defaultDirection
* @return array A two element array: array($column, $direction) * @return array A two element array: [$column, $direction]
*/ */
private function getDirectionFromString($value, $defaultDirection = null) private function getDirectionFromString($value, $defaultDirection = null)
{ {

View File

@ -97,7 +97,7 @@ class SQLUpdate extends SQLConditionalExpression implements SQLWriteExpression
} }
/** /**
* Clears all currently set assigment values * Clears all currently set assignment values
* *
* @return $this The self reference to this query * @return $this The self reference to this query
*/ */

View File

@ -20,27 +20,27 @@ interface SQLWriteExpression
* <code> * <code>
* *
* // Basic assignments * // Basic assignments
* $query->addAssignments(array( * $query->addAssignments([
* '"Object"."Title"' => 'Bob', * '"Object"."Title"' => 'Bob',
* '"Object"."Description"' => 'Bob was here' * '"Object"."Description"' => 'Bob was here'
* )) * ])
* *
* // Parameterised assignments * // Parameterised assignments
* $query->addAssignments(array( * $query->addAssignments([
* '"Object"."Title"' => array('?' => 'Bob')), * '"Object"."Title"' => ['?' => 'Bob'],
* '"Object"."Description"' => array('?' => null)) * '"Object"."Description"' => ['?' => null]
* )) * ])
* *
* // Complex parameters * // Complex parameters
* $query->addAssignments(array( * $query->addAssignments([
* '"Object"."Score"' => array('MAX(?,?)' => array(1, 3)) * '"Object"."Score"' => ['MAX(?,?)' => [1, 3]]
* )); * ]);
* *
* // Assigment of literal SQL for a field. The empty array is * // Assignment of literal SQL for a field. The empty array is
* // important to denote the zero-number paramater list * // important to denote the zero-number paramater list
* $query->addAssignments(array( * $query->addAssignments([
* '"Object"."Score"' => array('NOW()' => array()) * '"Object"."Score"' => ['NOW()' => []]
* )); * ]);
* *
* </code> * </code>
* *
@ -66,9 +66,9 @@ interface SQLWriteExpression
* *
* For multi-row objects returns assignments for the current row. * For multi-row objects returns assignments for the current row.
* *
* @return array List of assigments. The key of this array will be the * @return array List of assignments. The key of this array will be the
* column to assign, and the value a parameterised array in the format * column to assign, and the value a parameterised array in the format
* array('SQL' => array(parameters)); * ['SQL' => [parameters]];
*/ */
public function getAssignments(); public function getAssignments();
@ -84,10 +84,10 @@ interface SQLWriteExpression
* $query->assign('"Object"."Description"', 'lorum ipsum')); * $query->assign('"Object"."Description"', 'lorum ipsum'));
* *
* // Single parameter * // Single parameter
* $query->assign('"Object"."Title"', array('?' => 'Bob')); * $query->assign('"Object"."Title"', ['?' => 'Bob']);
* *
* // Complex parameters * // Complex parameters
* $query->assign('"Object"."Score"', array('MAX(?,?)' => array(1, 3)); * $query->assign('"Object"."Score"', ['MAX(?,?)' => [1, 3]]);
* </code> * </code>
* *
* @param string $field The field name to update * @param string $field The field name to update

View File

@ -84,30 +84,30 @@ class SSTemplateParser extends Parser implements TemplateParser
/** /**
* Stores the user-supplied closed block extension rules in the form: * Stores the user-supplied closed block extension rules in the form:
* array( * [
* 'name' => function (&$res) {} * 'name' => function (&$res) {}
* ) * ]
* See SSTemplateParser::ClosedBlock_Handle_Loop for an example of what the callable should look like * See SSTemplateParser::ClosedBlock_Handle_Loop for an example of what the callable should look like
* @var array * @var array
*/ */
protected $closedBlocks = array(); protected $closedBlocks = [];
/** /**
* Stores the user-supplied open block extension rules in the form: * Stores the user-supplied open block extension rules in the form:
* array( * [
* 'name' => function (&$res) {} * 'name' => function (&$res) {}
* ) * ]
* See SSTemplateParser::OpenBlock_Handle_Base_tag for an example of what the callable should look like * See SSTemplateParser::OpenBlock_Handle_Base_tag for an example of what the callable should look like
* @var array * @var array
*/ */
protected $openBlocks = array(); protected $openBlocks = [];
/** /**
* Allow the injection of new closed & open block callables * Allow the injection of new closed & open block callables
* @param array $closedBlocks * @param array $closedBlocks
* @param array $openBlocks * @param array $openBlocks
*/ */
public function __construct($closedBlocks = array(), $openBlocks = array()) public function __construct($closedBlocks = [], $openBlocks = [])
{ {
parent::__construct(null); parent::__construct(null);
$this->setClosedBlocks($closedBlocks); $this->setClosedBlocks($closedBlocks);
@ -136,7 +136,7 @@ class SSTemplateParser extends Parser implements TemplateParser
*/ */
public function setClosedBlocks($closedBlocks) public function setClosedBlocks($closedBlocks)
{ {
$this->closedBlocks = array(); $this->closedBlocks = [];
foreach ((array) $closedBlocks as $name => $callable) { foreach ((array) $closedBlocks as $name => $callable) {
$this->addClosedBlock($name, $callable); $this->addClosedBlock($name, $callable);
} }
@ -152,7 +152,7 @@ class SSTemplateParser extends Parser implements TemplateParser
*/ */
public function setOpenBlocks($openBlocks) public function setOpenBlocks($openBlocks)
{ {
$this->openBlocks = array(); $this->openBlocks = [];
foreach ((array) $openBlocks as $name => $callable) { foreach ((array) $openBlocks as $name => $callable) {
$this->addOpenBlock($name, $callable); $this->addOpenBlock($name, $callable);
} }
@ -270,7 +270,7 @@ class SSTemplateParser extends Parser implements TemplateParser
function Lookup__construct(&$res) function Lookup__construct(&$res)
{ {
$res['php'] = '$scope->locally()'; $res['php'] = '$scope->locally()';
$res['LookupSteps'] = array(); $res['LookupSteps'] = [];
} }
/** /**
@ -285,7 +285,7 @@ class SSTemplateParser extends Parser implements TemplateParser
$property = $sub['Call']['Method']['text']; $property = $sub['Call']['Method']['text'];
if (isset($sub['Call']['CallArguments']) && $arguments = $sub['Call']['CallArguments']['php']) { if (isset($sub['Call']['CallArguments']) && $arguments = $sub['Call']['CallArguments']['php']) {
$res['php'] .= "->$method('$property', array($arguments), true)"; $res['php'] .= "->$method('$property', [$arguments], true)";
} else { } else {
$res['php'] .= "->$method('$property', null, true)"; $res['php'] .= "->$method('$property', null, true)";
} }
@ -346,7 +346,7 @@ class SSTemplateParser extends Parser implements TemplateParser
function InjectionVariables__construct(&$res) function InjectionVariables__construct(&$res)
{ {
$res['php'] = "array("; $res['php'] = "[";
} }
function InjectionVariables_InjectionName(&$res, $sub) function InjectionVariables_InjectionName(&$res, $sub)
@ -364,7 +364,7 @@ class SSTemplateParser extends Parser implements TemplateParser
if (substr($res['php'], -1) == ',') { if (substr($res['php'], -1) == ',') {
$res['php'] = substr($res['php'], 0, -1); //remove last comma in the array $res['php'] = substr($res['php'], 0, -1); //remove last comma in the array
} }
$res['php'] .= ')'; $res['php'] .= ']';
} }
@ -873,7 +873,7 @@ class SSTemplateParser extends Parser implements TemplateParser
*/ */
function Include__construct(&$res) function Include__construct(&$res)
{ {
$res['arguments'] = array(); $res['arguments'] = [];
} }
function Include_Template(&$res, $sub) function Include_Template(&$res, $sub)
@ -892,8 +892,8 @@ class SSTemplateParser extends Parser implements TemplateParser
$arguments = $res['arguments']; $arguments = $res['arguments'];
// Note: 'type' here is important to disable subTemplates in SSViewer::getSubtemplateFor() // Note: 'type' here is important to disable subTemplates in SSViewer::getSubtemplateFor()
$res['php'] = '$val .= \\SilverStripe\\View\\SSViewer::execute_template([["type" => "Includes", '.$template.'], '.$template.'], $scope->getItem(), array(' . $res['php'] = '$val .= \\SilverStripe\\View\\SSViewer::execute_template([["type" => "Includes", '.$template.'], '.$template.'], $scope->getItem(), [' .
implode(',', $arguments)."), \$scope, true);\n"; implode(',', $arguments)."], \$scope, true);\n";
if ($this->includeDebuggingComments) { // Add include filename comments on dev sites if ($this->includeDebuggingComments) { // Add include filename comments on dev sites
$res['php'] = $res['php'] =
@ -946,7 +946,7 @@ class SSTemplateParser extends Parser implements TemplateParser
function ClosedBlock_BlockArguments(&$res, $sub) function ClosedBlock_BlockArguments(&$res, $sub)
{ {
if (isset($sub['Argument']['ArgumentMode'])) { if (isset($sub['Argument']['ArgumentMode'])) {
$res['Arguments'] = array($sub['Argument']); $res['Arguments'] = [$sub['Argument']];
$res['ArgumentCount'] = 1; $res['ArgumentCount'] = 1;
} else { } else {
$res['Arguments'] = $sub['Argument']; $res['Arguments'] = $sub['Argument'];
@ -1037,7 +1037,7 @@ class SSTemplateParser extends Parser implements TemplateParser
function OpenBlock_BlockArguments(&$res, $sub) function OpenBlock_BlockArguments(&$res, $sub)
{ {
if (isset($sub['Argument']['ArgumentMode'])) { if (isset($sub['Argument']['ArgumentMode'])) {
$res['Arguments'] = array($sub['Argument']); $res['Arguments'] = [$sub['Argument']];
$res['ArgumentCount'] = 1; $res['ArgumentCount'] = 1;
} else { } else {
$res['Arguments'] = $sub['Argument']; $res['Arguments'] = $sub['Argument'];

View File

@ -63,30 +63,30 @@ class SSTemplateParser extends Parser implements TemplateParser
/** /**
* Stores the user-supplied closed block extension rules in the form: * Stores the user-supplied closed block extension rules in the form:
* array( * [
* 'name' => function (&$res) {} * 'name' => function (&$res) {}
* ) * ]
* See SSTemplateParser::ClosedBlock_Handle_Loop for an example of what the callable should look like * See SSTemplateParser::ClosedBlock_Handle_Loop for an example of what the callable should look like
* @var array * @var array
*/ */
protected $closedBlocks = array(); protected $closedBlocks = [];
/** /**
* Stores the user-supplied open block extension rules in the form: * Stores the user-supplied open block extension rules in the form:
* array( * [
* 'name' => function (&$res) {} * 'name' => function (&$res) {}
* ) * ]
* See SSTemplateParser::OpenBlock_Handle_Base_tag for an example of what the callable should look like * See SSTemplateParser::OpenBlock_Handle_Base_tag for an example of what the callable should look like
* @var array * @var array
*/ */
protected $openBlocks = array(); protected $openBlocks = [];
/** /**
* Allow the injection of new closed & open block callables * Allow the injection of new closed & open block callables
* @param array $closedBlocks * @param array $closedBlocks
* @param array $openBlocks * @param array $openBlocks
*/ */
public function __construct($closedBlocks = array(), $openBlocks = array()) public function __construct($closedBlocks = [], $openBlocks = [])
{ {
parent::__construct(null); parent::__construct(null);
$this->setClosedBlocks($closedBlocks); $this->setClosedBlocks($closedBlocks);
@ -115,7 +115,7 @@ class SSTemplateParser extends Parser implements TemplateParser
*/ */
public function setClosedBlocks($closedBlocks) public function setClosedBlocks($closedBlocks)
{ {
$this->closedBlocks = array(); $this->closedBlocks = [];
foreach ((array) $closedBlocks as $name => $callable) { foreach ((array) $closedBlocks as $name => $callable) {
$this->addClosedBlock($name, $callable); $this->addClosedBlock($name, $callable);
} }
@ -131,7 +131,7 @@ class SSTemplateParser extends Parser implements TemplateParser
*/ */
public function setOpenBlocks($openBlocks) public function setOpenBlocks($openBlocks)
{ {
$this->openBlocks = array(); $this->openBlocks = [];
foreach ((array) $openBlocks as $name => $callable) { foreach ((array) $openBlocks as $name => $callable) {
$this->addOpenBlock($name, $callable); $this->addOpenBlock($name, $callable);
} }
@ -743,7 +743,7 @@ class SSTemplateParser extends Parser implements TemplateParser
function Lookup__construct(&$res) function Lookup__construct(&$res)
{ {
$res['php'] = '$scope->locally()'; $res['php'] = '$scope->locally()';
$res['LookupSteps'] = array(); $res['LookupSteps'] = [];
} }
/** /**
@ -758,7 +758,7 @@ class SSTemplateParser extends Parser implements TemplateParser
$property = $sub['Call']['Method']['text']; $property = $sub['Call']['Method']['text'];
if (isset($sub['Call']['CallArguments']) && $arguments = $sub['Call']['CallArguments']['php']) { if (isset($sub['Call']['CallArguments']) && $arguments = $sub['Call']['CallArguments']['php']) {
$res['php'] .= "->$method('$property', array($arguments), true)"; $res['php'] .= "->$method('$property', [$arguments], true)";
} else { } else {
$res['php'] .= "->$method('$property', null, true)"; $res['php'] .= "->$method('$property', null, true)";
} }
@ -980,7 +980,7 @@ class SSTemplateParser extends Parser implements TemplateParser
function InjectionVariables__construct(&$res) function InjectionVariables__construct(&$res)
{ {
$res['php'] = "array("; $res['php'] = "[";
} }
function InjectionVariables_InjectionName(&$res, $sub) function InjectionVariables_InjectionName(&$res, $sub)
@ -998,7 +998,7 @@ class SSTemplateParser extends Parser implements TemplateParser
if (substr($res['php'], -1) == ',') { if (substr($res['php'], -1) == ',') {
$res['php'] = substr($res['php'], 0, -1); //remove last comma in the array $res['php'] = substr($res['php'], 0, -1); //remove last comma in the array
} }
$res['php'] .= ')'; $res['php'] .= ']';
} }
@ -3481,7 +3481,7 @@ class SSTemplateParser extends Parser implements TemplateParser
function Include__construct(&$res) function Include__construct(&$res)
{ {
$res['arguments'] = array(); $res['arguments'] = [];
} }
function Include_Template(&$res, $sub) function Include_Template(&$res, $sub)
@ -3500,8 +3500,8 @@ class SSTemplateParser extends Parser implements TemplateParser
$arguments = $res['arguments']; $arguments = $res['arguments'];
// Note: 'type' here is important to disable subTemplates in SSViewer::getSubtemplateFor() // Note: 'type' here is important to disable subTemplates in SSViewer::getSubtemplateFor()
$res['php'] = '$val .= \\SilverStripe\\View\\SSViewer::execute_template([["type" => "Includes", '.$template.'], '.$template.'], $scope->getItem(), array(' . $res['php'] = '$val .= \\SilverStripe\\View\\SSViewer::execute_template([["type" => "Includes", '.$template.'], '.$template.'], $scope->getItem(), [' .
implode(',', $arguments)."), \$scope, true);\n"; implode(',', $arguments)."], \$scope, true);\n";
if ($this->includeDebuggingComments) { // Add include filename comments on dev sites if ($this->includeDebuggingComments) { // Add include filename comments on dev sites
$res['php'] = $res['php'] =
@ -3833,7 +3833,7 @@ class SSTemplateParser extends Parser implements TemplateParser
function ClosedBlock_BlockArguments(&$res, $sub) function ClosedBlock_BlockArguments(&$res, $sub)
{ {
if (isset($sub['Argument']['ArgumentMode'])) { if (isset($sub['Argument']['ArgumentMode'])) {
$res['Arguments'] = array($sub['Argument']); $res['Arguments'] = [$sub['Argument']];
$res['ArgumentCount'] = 1; $res['ArgumentCount'] = 1;
} else { } else {
$res['Arguments'] = $sub['Argument']; $res['Arguments'] = $sub['Argument'];
@ -3981,7 +3981,7 @@ class SSTemplateParser extends Parser implements TemplateParser
function OpenBlock_BlockArguments(&$res, $sub) function OpenBlock_BlockArguments(&$res, $sub)
{ {
if (isset($sub['Argument']['ArgumentMode'])) { if (isset($sub['Argument']['ArgumentMode'])) {
$res['Arguments'] = array($sub['Argument']); $res['Arguments'] = [$sub['Argument']];
$res['ArgumentCount'] = 1; $res['ArgumentCount'] = 1;
} else { } else {
$res['Arguments'] = $sub['Argument']; $res['Arguments'] = $sub['Argument'];

View File

@ -27,7 +27,7 @@ interface TemplateGlobalProvider
* @return array Returns an array of items. Each key => value pair is one of three forms: * @return array Returns an array of items. Each key => value pair is one of three forms:
* - template name (no key) * - template name (no key)
* - template name => method name * - template name => method name
* - template name => array(), where the array can contain these key => value pairs * - template name => [], where the array can contain these key => value pairs
* - "method" => method name * - "method" => method name
* - "casting" => casting class to use (i.e., Varchar, HTMLFragment, etc) * - "casting" => casting class to use (i.e., Varchar, HTMLFragment, etc)
*/ */

View File

@ -42,12 +42,12 @@ function checkenv($envs)
return true; return true;
} }
$opts = getopt('', array( $opts = getopt('', [
'artifacts-path:', 'artifacts-path:',
'target-path:', 'target-path:',
'if-env:', 'if-env:',
'artifacts-base-url:', 'artifacts-base-url:',
)); ]);
// --if-env=BEHAT_TEST means that this script will only be executed if the given environment var is set // --if-env=BEHAT_TEST means that this script will only be executed if the given environment var is set
if (empty($opts['if-env'])) { if (empty($opts['if-env'])) {

View File

@ -3,11 +3,11 @@
// Fake the script name and base // Fake the script name and base
global $_SERVER; global $_SERVER;
if (!$_SERVER) { if (!$_SERVER) {
$_SERVER = array(); $_SERVER = [];
} }
// We update the $_SERVER variable to contain data consistent with the rest of the application. // We update the $_SERVER variable to contain data consistent with the rest of the application.
$_SERVER = array_merge(array( $_SERVER = array_merge([
'SERVER_PROTOCOL' => 'HTTP/1.1', 'SERVER_PROTOCOL' => 'HTTP/1.1',
'HTTP_ACCEPT' => 'text/plain;q=0.5', 'HTTP_ACCEPT' => 'text/plain;q=0.5',
'HTTP_ACCEPT_LANGUAGE' => '*;q=0.5', 'HTTP_ACCEPT_LANGUAGE' => '*;q=0.5',
@ -20,7 +20,7 @@ $_SERVER = array_merge(array(
'REMOTE_ADDR' => '127.0.0.1', 'REMOTE_ADDR' => '127.0.0.1',
'REQUEST_METHOD' => 'GET', 'REQUEST_METHOD' => 'GET',
'HTTP_USER_AGENT' => 'CLI', 'HTTP_USER_AGENT' => 'CLI',
), $_SERVER); ], $_SERVER);
$frameworkPath = dirname(dirname(__FILE__)); $frameworkPath = dirname(dirname(__FILE__));
$frameworkDir = basename($frameworkPath); $frameworkDir = basename($frameworkPath);
@ -32,16 +32,16 @@ $_SERVER['SCRIPT_NAME'] = '.' . DIRECTORY_SEPARATOR . $frameworkDir . DIRECTORY_
if (isset($_SERVER['argv'][2])) { if (isset($_SERVER['argv'][2])) {
$args = array_slice($_SERVER['argv'], 2); $args = array_slice($_SERVER['argv'], 2);
if (!isset($_GET)) { if (!isset($_GET)) {
$_GET = array(); $_GET = [];
} }
if (!isset($_REQUEST)) { if (!isset($_REQUEST)) {
$_REQUEST = array(); $_REQUEST = [];
} }
foreach ($args as $arg) { foreach ($args as $arg) {
if (strpos($arg, '=') == false) { if (strpos($arg, '=') == false) {
$_GET['args'][] = $arg; $_GET['args'][] = $arg;
} else { } else {
$newItems = array(); $newItems = [];
parse_str((substr($arg, 0, 2) == '--') ? substr($arg, 2) : $arg, $newItems); parse_str((substr($arg, 0, 2) == '--') ? substr($arg, 2) : $arg, $newItems);
$_GET = array_merge($_GET, $newItems); $_GET = array_merge($_GET, $newItems);
} }

View File

@ -10,7 +10,7 @@ class UnsecuredController extends Controller implements TestOnly
private static $url_segment = 'UnsecuredController'; private static $url_segment = 'UnsecuredController';
// Not defined, allow access to all // Not defined, allow access to all
// static $allowed_actions = array(); // static $allowed_actions = [];
// Granted for all // Granted for all
public function method1() public function method1()

View File

@ -441,7 +441,7 @@ class ObjectTest extends SapphireTest
// True, false and null values // True, false and null values
$this->assertEquals( $this->assertEquals(
['ClassName', ['string', true, ['string', false]]], ['ClassName', ['string', true, ['string', false]]],
ClassInfo::parse_class_spec('ClassName("string", true, array("string", false))') ClassInfo::parse_class_spec('ClassName("string", true, ["string", false])')
); );
$this->assertEquals( $this->assertEquals(
['ClassName', [true, false, null]], ['ClassName', [true, false, null]],
@ -451,7 +451,7 @@ class ObjectTest extends SapphireTest
// Array // Array
$this->assertEquals( $this->assertEquals(
['Enum', [['Accepted', 'Pending', 'Declined', 'Unsubmitted'], 'Unsubmitted']], ['Enum', [['Accepted', 'Pending', 'Declined', 'Unsubmitted'], 'Unsubmitted']],
ClassInfo::parse_class_spec("Enum(array('Accepted', 'Pending', 'Declined', 'Unsubmitted'), 'Unsubmitted')") ClassInfo::parse_class_spec("Enum(['Accepted', 'Pending', 'Declined', 'Unsubmitted'], 'Unsubmitted')")
); );
// Nested array // Nested array
$this->assertEquals( $this->assertEquals(
@ -463,7 +463,7 @@ class ObjectTest extends SapphireTest
] ]
], ],
ClassInfo::parse_class_spec( ClassInfo::parse_class_spec(
"Enum(array('Accepted', 'Pending', 'Declined', array('UnsubmittedA','UnsubmittedB')), 'Unsubmitted')" "Enum(['Accepted', 'Pending', 'Declined', ['UnsubmittedA','UnsubmittedB']], 'Unsubmitted')"
) )
); );
// 5.4 Shorthand Array // 5.4 Shorthand Array
@ -488,12 +488,12 @@ class ObjectTest extends SapphireTest
// Associative array // Associative array
$this->assertEquals( $this->assertEquals(
['Varchar', [255, ['nullifyEmpty' => false]]], ['Varchar', [255, ['nullifyEmpty' => false]]],
ClassInfo::parse_class_spec("Varchar(255, array('nullifyEmpty' => false))") ClassInfo::parse_class_spec("Varchar(255, ['nullifyEmpty' => false])")
); );
// Nested associative array // Nested associative array
$this->assertEquals( $this->assertEquals(
['Test', ['string', ['nested' => ['foo' => 'bar']]]], ['Test', ['string', ['nested' => ['foo' => 'bar']]]],
ClassInfo::parse_class_spec("Test('string', array('nested' => array('foo' => 'bar')))") ClassInfo::parse_class_spec("Test('string', ['nested' => ['foo' => 'bar']])")
); );
// 5.4 shorthand associative array // 5.4 shorthand associative array
$this->assertEquals( $this->assertEquals(

View File

@ -446,7 +446,7 @@ class ArrayListTest extends SapphireTest
['Name' => 'John'], ['Name' => 'John'],
['Name' => 'bonny'], ['Name' => 'bonny'],
['Name' => 'bonny1'], ['Name' => 'bonny1'],
//array('Name' => 'bonny10'), //['Name' => 'bonny10'],
['Name' => 'bonny2'], ['Name' => 'bonny2'],
]; ];
@ -456,7 +456,7 @@ class ArrayListTest extends SapphireTest
(object) ['Name' => 'Bob'], (object) ['Name' => 'Bob'],
['Name' => 'bonny'], ['Name' => 'bonny'],
['Name' => 'bonny1'], ['Name' => 'bonny1'],
//array('Name' => 'bonny10'), //['Name' => 'bonny10'],
['Name' => 'bonny2'], ['Name' => 'bonny2'],
['Name' => 'John'], ['Name' => 'John'],
['Name' => 'Steve'], ['Name' => 'Steve'],
@ -756,7 +756,7 @@ class ArrayListTest extends SapphireTest
} }
/** /**
* $list->filter('Name', array('Steve', 'John'); // Steve and John in list * $list->filter('Name', ['Steve', 'John']; // Steve and John in list
*/ */
public function testSimpleFilterWithMultiple() public function testSimpleFilterWithMultiple()
{ {
@ -777,7 +777,7 @@ class ArrayListTest extends SapphireTest
} }
/** /**
* $list->filter('Name', array('Steve', 'John'); // negative version * $list->filter('Name', ['Steve', 'John']; // negative version
*/ */
public function testSimpleFilterWithMultipleNoMatch() public function testSimpleFilterWithMultipleNoMatch()
{ {
@ -793,7 +793,7 @@ class ArrayListTest extends SapphireTest
} }
/** /**
* $list->filter(array('Name'=>'bob, 'Age'=>21)); // bob with the Age 21 in list * $list->filter(['Name'=>'bob, 'Age'=>21]); // bob with the Age 21 in list
*/ */
public function testMultipleFilter() public function testMultipleFilter()
{ {
@ -813,7 +813,7 @@ class ArrayListTest extends SapphireTest
} }
/** /**
* $list->filter(array('Name'=>'bob, 'Age'=>21)); // negative version * $list->filter(['Name'=>'bob, 'Age'=>21]); // negative version
*/ */
public function testMultipleFilterNoMatch() public function testMultipleFilterNoMatch()
{ {
@ -829,7 +829,7 @@ class ArrayListTest extends SapphireTest
} }
/** /**
* $list->filter(array('Name'=>'Steve', 'Age'=>array(21, 43))); // Steve with the Age 21 or 43 * $list->filter(['Name'=>'Steve', 'Age'=>[21, 43]]); // Steve with the Age 21 or 43
*/ */
public function testMultipleWithArrayFilter() public function testMultipleWithArrayFilter()
{ {
@ -853,7 +853,7 @@ class ArrayListTest extends SapphireTest
} }
/** /**
* $list->filter(array('Name'=>array('aziz','bob'), 'Age'=>array(21, 43))); * $list->filter(['Name'=>['aziz','bob'], 'Age'=>[21, 43]]);
*/ */
public function testMultipleWithArrayFilterAdvanced() public function testMultipleWithArrayFilterAdvanced()
{ {
@ -900,7 +900,7 @@ class ArrayListTest extends SapphireTest
$this->assertContains($bob, $filteredList); $this->assertContains($bob, $filteredList);
// azis or bob in the list // azis or bob in the list
//$list = $list->filterAny('Name', array('aziz', 'bob'); //$list = $list->filterAny('Name', ['aziz', 'bob']);
$filteredList = $list->filterAny('Name', ['Aziz', 'Bob'])->toArray(); $filteredList = $list->filterAny('Name', ['Aziz', 'Bob'])->toArray();
$this->assertCount(1, $filteredList); $this->assertCount(1, $filteredList);
$this->assertContains($bob, $filteredList); $this->assertContains($bob, $filteredList);
@ -911,7 +911,7 @@ class ArrayListTest extends SapphireTest
$this->assertContains($bob, $filteredList); $this->assertContains($bob, $filteredList);
// bob or anyone aged 21 in the list // bob or anyone aged 21 in the list
//$list = $list->filterAny(array('Name'=>'bob, 'Age'=>21)); //$list = $list->filterAny(['Name'=>'bob, 'Age'=>21]);
$filteredList = $list->filterAny(['Name' => 'Bob', 'Age' => 21])->toArray(); $filteredList = $list->filterAny(['Name' => 'Bob', 'Age' => 21])->toArray();
$this->assertCount(4, $filteredList); $this->assertCount(4, $filteredList);
$this->assertContains($bob, $filteredList); $this->assertContains($bob, $filteredList);
@ -920,7 +920,7 @@ class ArrayListTest extends SapphireTest
$this->assertContains($phil, $filteredList); $this->assertContains($phil, $filteredList);
// bob or anyone aged 21 or 43 in the list // bob or anyone aged 21 or 43 in the list
// $list = $list->filterAny(array('Name'=>'bob, 'Age'=>array(21, 43))); // $list = $list->filterAny(['Name'=>'bob, 'Age'=>[21, 43]]);
$filteredList = $list->filterAny(['Name' => 'Bob', 'Age' => [21, 43]])->toArray(); $filteredList = $list->filterAny(['Name' => 'Bob', 'Age' => [21, 43]])->toArray();
$this->assertCount(5, $filteredList); $this->assertCount(5, $filteredList);
$this->assertContains($bob, $filteredList); $this->assertContains($bob, $filteredList);
@ -930,7 +930,7 @@ class ArrayListTest extends SapphireTest
$this->assertContains($phil, $filteredList); $this->assertContains($phil, $filteredList);
// all bobs, phils or anyone aged 21 or 43 in the list // all bobs, phils or anyone aged 21 or 43 in the list
//$list = $list->filterAny(array('Name'=>array('bob','phil'), 'Age'=>array(21, 43))); //$list = $list->filterAny(['Name'=>['bob','phil'], 'Age'=>[21, 43]]);
$filteredList = $list->filterAny(['Name' => ['Bob', 'Phil'], 'Age' => [21, 43]])->toArray(); $filteredList = $list->filterAny(['Name' => ['Bob', 'Phil'], 'Age' => [21, 43]])->toArray();
$this->assertCount(5, $filteredList); $this->assertCount(5, $filteredList);
$this->assertContains($bob, $filteredList); $this->assertContains($bob, $filteredList);

View File

@ -774,7 +774,7 @@ class DataListTest extends SapphireTest
} }
/** /**
* $list->filter('Name', array('aziz', 'bob'); // aziz and bob in list * $list->filter('Name', ['aziz', 'bob']); // aziz and bob in list
*/ */
public function testSimpleFilterWithMultiple() public function testSimpleFilterWithMultiple()
{ {
@ -794,7 +794,7 @@ class DataListTest extends SapphireTest
} }
/** /**
* $list->filter(array('Name'=>'bob, 'Age'=>21)); // bob with the age 21 * $list->filter(['Name'=>'bob, 'Age'=>21]); // bob with the age 21
*/ */
public function testFilterMultipleArray() public function testFilterMultipleArray()
{ {
@ -833,7 +833,7 @@ class DataListTest extends SapphireTest
} }
/** /**
* $list->filter(array('Name'=>array('aziz','bob'), 'Age'=>array(21, 43))); * $list->filter(['Name'=>['aziz','bob'], 'Age'=>[21, 43]]);
*/ */
public function testFilterArrayInArray() public function testFilterArrayInArray()
{ {
@ -1499,7 +1499,7 @@ class DataListTest extends SapphireTest
} }
// //
/** /**
* $list->exclude('Name', array('aziz', 'bob'); // exclude aziz and bob from list * $list->exclude('Name', ['aziz', 'bob']); // exclude aziz and bob from list
*/ */
public function testSimpleExcludeWithMultiple() public function testSimpleExcludeWithMultiple()
{ {
@ -1510,7 +1510,7 @@ class DataListTest extends SapphireTest
} }
/** /**
* $list->exclude(array('Name'=>'bob, 'Age'=>21)); // negative version * $list->exclude(['Name'=>'bob, 'Age'=>21]); // negative version
*/ */
public function testMultipleExcludeWithMiss() public function testMultipleExcludeWithMiss()
{ {
@ -1520,7 +1520,7 @@ class DataListTest extends SapphireTest
} }
/** /**
* $list->exclude(array('Name'=>'bob, 'Age'=>21)); // exclude bob that has Age 21 * $list->exclude(['Name'=>'bob, 'Age'=>21]); // exclude bob that has Age 21
*/ */
public function testMultipleExclude() public function testMultipleExclude()
{ {
@ -1531,7 +1531,7 @@ class DataListTest extends SapphireTest
/** /**
* Test doesn't exclude if only matches one * Test doesn't exclude if only matches one
* $list->exclude(array('Name'=>'bob, 'Age'=>21)); // exclude bob that has Age 21 * $list->exclude(['Name'=>'bob, 'Age'=>21]); // exclude bob that has Age 21
*/ */
public function testMultipleExcludeMultipleMatches() public function testMultipleExcludeMultipleMatches()
{ {
@ -1711,7 +1711,7 @@ class DataListTest extends SapphireTest
} }
/** /**
* $list->exclude(array('Name'=>'bob, 'Age'=>array(21, 43))); // exclude bob with Age 21 or 43 * $list->exclude(['Name'=>'bob, 'Age'=>[21, 43]]); // exclude bob with Age 21 or 43
*/ */
public function testMultipleExcludeWithMultipleThatCheersEitherTeam() public function testMultipleExcludeWithMultipleThatCheersEitherTeam()
{ {
@ -1729,7 +1729,7 @@ class DataListTest extends SapphireTest
} }
/** /**
* $list->exclude(array('Name'=>'bob, 'Age'=>array(21, 43))); // negative version * $list->exclude(['Name'=>'bob, 'Age'=>[21, 43]]); // negative version
*/ */
public function testMultipleExcludeWithMultipleThatCheersOnNonExistingTeam() public function testMultipleExcludeWithMultipleThatCheersOnNonExistingTeam()
{ {
@ -1739,7 +1739,7 @@ class DataListTest extends SapphireTest
} }
/** /**
* $list->exclude(array('Name'=>array('bob','phil'), 'Age'=>array(21, 43))); //negative version * $list->exclude(['Name'=>['bob','phil'], 'Age'=>[21, 43]]); //negative version
*/ */
public function testMultipleExcludeWithNoExclusion() public function testMultipleExcludeWithNoExclusion()
{ {

View File

@ -173,7 +173,7 @@ class DataObjectTest extends SapphireTest
); );
// assertEquals doesn't verify the order of array elements, so access keys manually to check order: // assertEquals doesn't verify the order of array elements, so access keys manually to check order:
// expected: array('Name' => 'Varchar', 'Comment' => 'HTMLText') // expected: ['Name' => 'Varchar', 'Comment' => 'HTMLText']
$this->assertEquals( $this->assertEquals(
[ [
'Name', 'Name',
@ -594,7 +594,7 @@ class DataObjectTest extends SapphireTest
// Test the IDs on the DataObjects are set correctly // Test the IDs on the DataObjects are set correctly
$this->assertListEquals($team1Comments, $team1->Comments()); $this->assertListEquals($team1Comments, $team1->Comments());
// Test that has_many can be infered from the has_one via getNonReciprocalComponent // Test that has_many can be inferred from the has_one via getNonReciprocalComponent
$this->assertListEquals( $this->assertListEquals(
$team1Comments, $team1Comments,
$team1->inferReciprocalComponent(DataObjectTest\TeamComment::class, 'Team') $team1->inferReciprocalComponent(DataObjectTest\TeamComment::class, 'Team')
@ -1704,7 +1704,7 @@ class DataObjectTest extends SapphireTest
$this->assertInstanceOf(ManyManyList::class, $teamWithoutSponsor->Sponsors()); $this->assertInstanceOf(ManyManyList::class, $teamWithoutSponsor->Sponsors());
$this->assertEquals(0, $teamWithoutSponsor->Sponsors()->count()); $this->assertEquals(0, $teamWithoutSponsor->Sponsors()->count());
// Test that belongs_many_many can be infered from with getNonReciprocalComponent // Test that belongs_many_many can be inferred from with getNonReciprocalComponent
$this->assertListEquals( $this->assertListEquals(
[ [
['Name' => 'Company corp'], ['Name' => 'Company corp'],
@ -1713,7 +1713,7 @@ class DataObjectTest extends SapphireTest
$team->inferReciprocalComponent(DataObjectTest\EquipmentCompany::class, 'SponsoredTeams') $team->inferReciprocalComponent(DataObjectTest\EquipmentCompany::class, 'SponsoredTeams')
); );
// Test that many_many can be infered from getNonReciprocalComponent // Test that many_many can be inferred from getNonReciprocalComponent
$this->assertListEquals( $this->assertListEquals(
[ [
['Title' => 'Team 1'], ['Title' => 'Team 1'],
@ -2149,20 +2149,20 @@ class DataObjectTest extends SapphireTest
$this->assertEquals($company->ID, $ceo->Company()->ID, 'belongs_to returns the right results.'); $this->assertEquals($company->ID, $ceo->Company()->ID, 'belongs_to returns the right results.');
// Test belongs_to can be infered via getNonReciprocalComponent // Test belongs_to can be inferred via getNonReciprocalComponent
// Note: Will be returned as has_many since the belongs_to is ignored. // Note: Will be returned as has_many since the belongs_to is ignored.
$this->assertListEquals( $this->assertListEquals(
[['Name' => 'New Company']], [['Name' => 'New Company']],
$ceo->inferReciprocalComponent(DataObjectTest\Company::class, 'CEO') $ceo->inferReciprocalComponent(DataObjectTest\Company::class, 'CEO')
); );
// Test has_one to a belongs_to can be infered via getNonReciprocalComponent // Test has_one to a belongs_to can be inferred via getNonReciprocalComponent
$this->assertEquals( $this->assertEquals(
$ceo->ID, $ceo->ID,
$company->inferReciprocalComponent(DataObjectTest\CEO::class, 'Company')->ID $company->inferReciprocalComponent(DataObjectTest\CEO::class, 'Company')->ID
); );
// Test automatic creation of class where no assigment exists // Test automatic creation of class where no assignment exists
$ceo = new DataObjectTest\CEO(); $ceo = new DataObjectTest\CEO();
$ceo->write(); $ceo->write();
@ -2443,7 +2443,7 @@ class DataObjectTest extends SapphireTest
$root->CycleID = $grandchild->ID; $root->CycleID = $grandchild->ID;
$root->write(); $root->write();
// Our count will have been set while loading our fixtures, let's reset eveything back to 0 // Our count will have been set while loading our fixtures, let's reset everything back to 0
TreeNode::singleton()->resetCounts(); TreeNode::singleton()->resetCounts();
$root = TreeNode::get()->byID($root->ID); $root = TreeNode::get()->byID($root->ID);
$child = TreeNode::get()->byID($child->ID); $child = TreeNode::get()->byID($child->ID);
@ -2487,7 +2487,7 @@ class DataObjectTest extends SapphireTest
$root->CycleID = $grandchild->ID; $root->CycleID = $grandchild->ID;
$root->write(); $root->write();
// Our count will have been set while loading our fixtures, let's reset eveything back to 0 // Our count will have been set while loading our fixtures, let's reset everything back to 0
TreeNode::singleton()->resetCounts(); TreeNode::singleton()->resetCounts();
$root = TreeNode::get()->byID($root->ID); $root = TreeNode::get()->byID($root->ID);
$child = TreeNode::get()->byID($child->ID); $child = TreeNode::get()->byID($child->ID);

View File

@ -10,6 +10,6 @@ class CastingClass extends ViewableData implements TestOnly
private static $casting = [ private static $casting = [
'Field' => 'CastingType', 'Field' => 'CastingType',
'Argument' => 'ArgumentType(Argument)', 'Argument' => 'ArgumentType(Argument)',
'ArrayArgument' => 'ArrayArgumentType(array(foo, bar))' 'ArrayArgument' => 'ArrayArgumentType([foo, bar])'
]; ];
} }

View File

@ -5,7 +5,7 @@ use SilverStripe\ORM\DataExtension;
class i18nTestModuleExtension extends DataExtension class i18nTestModuleExtension extends DataExtension
{ {
public static $db = array( public static $db = [
'MyExtraField' => 'Varchar' 'MyExtraField' => 'Varchar'
); ];
} }

View File

@ -5,9 +5,9 @@ use SilverStripe\Dev\TestOnly;
class i18nTestModule extends DataObject implements TestOnly class i18nTestModule extends DataObject implements TestOnly
{ {
private static $db = array( private static $db = [
'MyField' => 'Varchar', 'MyField' => 'Varchar',
); ];
public function myMethod() public function myMethod()
{ {

View File

@ -388,11 +388,11 @@ PHP;
$php = <<<PHP $php = <<<PHP
_t('i18nTestModule.NEWMETHODSIG',"New _t method signature test"); _t('i18nTestModule.NEWMETHODSIG',"New _t method signature test");
_t('i18nTestModule.INJECTIONS2', "Hello {name} {greeting}. But it is late, {goodbye}", _t('i18nTestModule.INJECTIONS2', "Hello {name} {greeting}. But it is late, {goodbye}",
array("name"=>"Paul", "greeting"=>"good you are here", "goodbye"=>"see you")); ["name"=>"Paul", "greeting"=>"good you are here", "goodbye"=>"see you"]);
_t("i18nTestModule.INJECTIONS3", "Hello {name} {greeting}. But it is late, {goodbye}", _t("i18nTestModule.INJECTIONS3", "Hello {name} {greeting}. But it is late, {goodbye}",
"New context (this should be ignored)", "New context (this should be ignored)",
array("name"=>"Steffen", "greeting"=>"willkommen", "goodbye"=>"wiedersehen")); ["name"=>"Steffen", "greeting"=>"willkommen", "goodbye"=>"wiedersehen"]);
_t('i18nTestModule.INJECTIONS4', array("name"=>"Cat", "greeting"=>"meow", "goodbye"=>"meow")); _t('i18nTestModule.INJECTIONS4', ["name"=>"Cat", "greeting"=>"meow", "goodbye"=>"meow"]);
_t('i18nTestModule.INJECTIONS6', "Hello {name} {greeting}. But it is late, {goodbye}", _t('i18nTestModule.INJECTIONS6', "Hello {name} {greeting}. But it is late, {goodbye}",
["name"=>"Paul", "greeting"=>"good you are here", "goodbye"=>"see you"]); ["name"=>"Paul", "greeting"=>"good you are here", "goodbye"=>"see you"]);
_t("i18nTestModule.INJECTIONS7", "Hello {name} {greeting}. But it is late, {goodbye}", _t("i18nTestModule.INJECTIONS7", "Hello {name} {greeting}. But it is late, {goodbye}",
@ -429,7 +429,7 @@ PHP;
$this->expectExceptionMessage('Missing localisation default for key i18nTestModule.INJECTIONS4'); $this->expectExceptionMessage('Missing localisation default for key i18nTestModule.INJECTIONS4');
$php = <<<PHP $php = <<<PHP
_t('i18nTestModule.INJECTIONS4', array("name"=>"Cat", "greeting"=>"meow", "goodbye"=>"meow")); _t('i18nTestModule.INJECTIONS4', ["name"=>"Cat", "greeting"=>"meow", "goodbye"=>"meow"]);
PHP; PHP;
$c->setWarnOnEmptyDefault(true); $c->setWarnOnEmptyDefault(true);
$c->collectFromCode($php, null, $mymodule); $c->collectFromCode($php, null, $mymodule);

View File

@ -10,12 +10,12 @@ if (!empty($_SERVER['argv'][1])) {
die("Usage: php {$_SERVER['argv'][0]} <file>\n"); die("Usage: php {$_SERVER['argv'][0]} <file>\n");
} }
$result = array('comments' => array()); $result = ['comments' => []];
$extension = pathinfo($path, PATHINFO_EXTENSION); $extension = pathinfo($path, PATHINFO_EXTENSION);
// Whitelist of extensions to check (default phpcs list) // Whitelist of extensions to check (default phpcs list)
if (in_array($extension, array('php', 'js', 'inc', 'css'))) { if (in_array($extension, ['php', 'js', 'inc', 'css'])) {
// Run each sniff // Run each sniff
// phpcs --encoding=utf-8 --standard=framework/tests/phpcs/tabs.xml // phpcs --encoding=utf-8 --standard=framework/tests/phpcs/tabs.xml
@ -42,11 +42,11 @@ function run_sniff($standard, $path, array &$result, $extraFlags = '')
$sanePath = str_replace('/', '_', $path); $sanePath = str_replace('/', '_', $path);
foreach ($errors as $error) { foreach ($errors as $error) {
$attributes = $error->attributes(); $attributes = $error->attributes();
$result['comments'][] = array( $result['comments'][] = [
'line' => (int)strval($attributes->line), 'line' => (int)strval($attributes->line),
'id' => $standard . '-' . $sanePath . '-' . $attributes->line . '-' . $attributes->column, 'id' => $standard . '-' . $sanePath . '-' . $attributes->line . '-' . $attributes->column,
'message' => strval($error) 'message' => strval($error)
); ];
} }
} }
} }