PHP arrays should be declared using the configured syntax.
Whether to use the long
or short
array syntax.
Allowed values: 'long'
and 'short'
Default value: 'short'
Default configuration.
--- Original
+++ New
<?php
-array(1,2);
+[1,2];
With configuration: ['syntax' => 'long']
.
--- Original
+++ New
<?php
-[1,2];
+array(1,2);
The rule is part of the following rule sets:
- @PHP54Migration
- @PHP70Migration
- @PHP71Migration
- @PHP73Migration
- @PHP74Migration
- @PHP80Migration
- @PHP81Migration
- @PHP82Migration
- @PHP83Migration
- @PHP84Migration
- @PhpCsFixer
- @Symfony
- Fixer class: PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer
- Test class: PhpCsFixer\Tests\Fixer\ArrayNotation\ArraySyntaxFixerTest
The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.