For configuration or updating questions please read the README and UPGRADE documentation,
or visit: https://gitter.im/PHP-CS-Fixer
When reporting an issue (bug) please provide the following information:
$ php -v):=> 7.2
$ php-cs-fixer -V):=> 2.14.0
=> vendor/bin/php
$finder = PhpCsFixer\Finder::create()
->in('app')
->in('shell')
;
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'ordered_imports' => true,
'no_unused_imports' => true,
'psr0' => true,
'array_syntax' => ['syntax' => 'short'],
'no_superfluous_phpdoc_tags' => true,
'linebreak_after_opening_tag' => true,
'logical_operators' => true,
])
->setFinder($finder)
;
<?php
class Foo
{
public function export()
{
return array(
'visits_keyword',
'visits_count');
}
}
<?php
class Foo
{
public function export()
{
return [
'visits_keyword',
'visits_count', ];
}
}
<?php
class Foo
{
public function export()
{
return [
'visits_keyword',
'visits_count',
];
}
}
To be clear:
return [
'visits_keyword',
- 'visits_count', ];
+ 'visits_count',
+ ];
This is not the responsibility of array_syntax as that only switches between array() and [].
I don't think there currently is a fixer that does what you want.
Ok but couldn’t it be so hard to let the fixer do this?
couldn’t it be so hard to let the fixer do this?
It's not, but that is besides the point. Just like other code, fixers (should) follow the Single Responsibility Principle (SRP, the S in SOLID).
As I said before, the single responsibility of named fixer is to switch between syntax styles, and alignment has nothing to do with that, so it does not belong in that fixer.
Most helpful comment
This is not the responsibility of
array_syntaxas that only switches betweenarray()and[].I don't think there currently is a fixer that does what you want.