Questions tagged [php-cs-fixer]
87 questions
3
votes
1 answer
Is there any way to set rule for removing trailing comma using PHP-CS-Fixer?
I'm using PHP-CS-Fixer to set up linting in project. There is a rule trailing_comma_in_multiline. It lets you to check whether all multiple-lines arrays have trailing commas.
Is it possible to reverse this logic and check whether all multiple-lines…

trckster
- 430
- 1
- 6
- 11
3
votes
1 answer
The options "align_double_arrow", "align_equals" do not exist. Defined options are: "default", "operators"
In my php-cs-fixer.php I have this line:
'binary_operator_spaces' => ['align_equals' => false, 'align_double_arrow' => true],
And it is giving me an error saying:
The options "align_double_arrow", "align_equals" do not exist. Defined options are:…

unitSphere
- 241
- 3
- 17
3
votes
0 answers
PhpStorm and PHP CS Fixer: shows errors but does not fix
TIA and this is driving me insane and resources on the web don't appear to be my specific issue.
I have installed PHP CS Fixer globally via Composer:
php-cs-fixer --version = PHP CS Fixer 2.14.2 Sunrise by Fabien Potencier and Darius…

Ray
- 773
- 9
- 21
3
votes
2 answers
PHP CS Fixer: spawn php-cs-fixer ENOENT. executablePath not found
My configuration / steps to reproduce the error:
Installed Visual Studio Code Version 1.22.1
Installed PHP CS Fixer Globally by:
composer global require friendsofphp/php-cs-fixer
Added Environment Variable:…

zarpio
- 10,380
- 8
- 58
- 71
3
votes
1 answer
PHP CS Fixer File Watcher causes File Cache Conflict in PHPStorm
I use a File Watcher defined as this
Here is my watchers.xml file:
3
votes
1 answer
How to use php-cs-fixer with vim for laravel?
I have installed php-cs-fixer & using with vim plugin https://github.com/stephpy/vim-php-cs-fixer. I am using custom config file from https://github.com/laravel/framework/blob/5.4/.php_cs. But I am having this issue where extra space after @param…

Ganesh
- 3,128
- 2
- 17
- 27
3
votes
1 answer
PHP CS Fixer Symfony & PSR2 rule do not exist
I'm using grumphp to check my code before committing and it's telling me:
F [UnexpectedValueException]
Rule "symfony" does not exist.
Exception trace:
() at…

DevJ3rry
- 666
- 6
- 22
2
votes
2 answers
php-cs-fixer doesn't indent HTML inside PHP control structures
I'm trying to use php-cs-fixer with a WordPress project, which means I (unfortunately) have files with a mix of PHP and HTML. I'm using the @PSR12 ruleset.
I'm having trouble with getting HTML within PHP control structures to indent correctly. Take…

gregdev
- 1,863
- 3
- 23
- 28
2
votes
1 answer
Space after named argument colon
I am looking for a PHP CS Fixer rule that requires a single space after a named argument, going from this:
array_key_exists(
key:'test',
array:$array,
);
to this:
array_key_exists(
key: 'test',
array: $array,
);
Any ideas?

Keith Brink
- 139
- 11
2
votes
0 answers
PHP CS Fixer - Force associative array multi line based on max line length
I'm looking for a rule (or a combination of a multiple rules) to wrap super long associative arrays. Maybe based on max line length? (I'm not a CS Fixer expert, sorry if its a dumb idea)
// Remains Untouched
$foo = ['bar' => $bar, 'biz' =>…

slowFooMovement
- 498
- 5
- 14
2
votes
1 answer
VSCode: php-cs-fixer setRules not applied while setIndent is applied
I'm using VSCode with PHP CS Fixer v3.1.0, but rules don't seem to be applied.
When I comment/uncomment setIndent("\t"), this setting is automatically applied and can be tested, but all rules in setRules() are not applied. For instance, arrays like…

DevonDahon
- 7,460
- 6
- 69
- 114
2
votes
0 answers
How to lint Namespace based on folder's name?
I know PHP CS Fixer and Psalm to lint PHP. I've been using both of them. But I can't find a way to lint / validate my namespace name based on the folder.
For example, in folder Tests/Controllers/V1, I have MyControllerTest.php, and it has the…

rhzs
- 516
- 7
- 24
2
votes
1 answer
How to replicate PHPStorm's "Align fields in columns" in PHP-CS-Fixer?
I would like to know if it is possible to replicate the Align fields in columns behavior from PHPStorm to PHP-CS-Fixer
For having this :
var $numbers = ["one", "two", "three", "four", "five", "six"];
var $v = 0;
…

Mathieu Ferre
- 4,246
- 1
- 14
- 31
2
votes
2 answers
How to limit PhpCsFixer to staged files?
I'm using PhpCsFixer on a project using Composer and Git for the version control.
When I launch PhpCsFixer, the tool updates all files. I'm searching solutions :
to limit fixes on the modified files,
to limit fixes on the staged files.
I already…

Alexandre Tranchant
- 4,426
- 4
- 43
- 70
2
votes
1 answer
New line on function argument list while using php-cs-fixer and PHPCodeSniffer
We are using both php-cs-fixer and PHPCodeSniffer tools for our coding standards. Both can be conflicted when having different rules. We were able to get a balanced result except for one rule. Warning thrown by PHP Code Sniffer :
phpcs: Opening…

wlarcheveque
- 894
- 1
- 10
- 28