The overall idea:
In core, we stop using array(1, 2, 3) in favor of [1, 2, 3].
Example:
$x = [
'key' => 'val',
];
function ($x = []) {}
return l('foo', 'bar', ['attributes' => ['class' => 'fun']]);
Previous work
@quicksketch has already created a working proof of concept for a rapid conversion to short syntax: backdrop/backdrop#4936
In case the blog post he mentioned disappears one day, here is what it said to do:
- Require code sniffer in your project (you are using composer, right?)
composer require --dev squizlabs/php_codesniffer
- Run CBF using the DisallowLongArraySyntax sniff
vendor/bin/phpcbf . --standard=Generic --sniffs=Generic.Arrays.DisallowLongArraySyntax
That will apply to everything in the current directory, so simply change the . to whichever specific files/folders you want to affect.
-- from https://philipjohn.blog/2023/02/10/convert-php-arrays-to-short-array-syntax-in-seconds/
The overall idea:
In core, we stop using
array(1, 2, 3)in favor of[1, 2, 3].Example:
Previous work
@quicksketch has already created a working proof of concept for a rapid conversion to short syntax: backdrop/backdrop#4936
In case the blog post he mentioned disappears one day, here is what it said to do:
composer require --dev squizlabs/php_codesniffervendor/bin/phpcbf . --standard=Generic --sniffs=Generic.Arrays.DisallowLongArraySyntaxThat will apply to everything in the current directory, so simply change the . to whichever specific files/folders you want to affect.
-- from https://philipjohn.blog/2023/02/10/convert-php-arrays-to-short-array-syntax-in-seconds/