Context
Noticed when going to use cs-fixer locally the latest version showed our rules are deprecated...
PHP CS Fixer 2.19.0 Testament by Fabien Potencier and Dariusz Ruminski (d5b8a9d)
Runtime: PHP 7.4.3
Loaded config default from "/home/user/.php-cs-fixer.php".
Paths from configuration file have been overridden by paths provided as command arguments.
F
Legend: ?-unknown, I-invalid file syntax (file ignored), S-skipped (cached or empty file), .-no changes, F-fixed, E-error
1) /home/user/PhpstormProjects/test.php (indentation_type, class_definition, braces, void_return, declare_strict_types, blank_line_after_opening_tag, no_unreachable_default_argument_value, psr_autoloading, blank_line_before_statement, header_comment)
Fixed all files in 0.017 seconds, 12.000 MB memory used
Detected deprecations in use:
- Given configuration is deprecated and will be removed in 3.0. Use configuration ['operators' => []] as replacement for ['align_double_arrow' => null, 'align_equals' => null].
- Rule "blank_line_before_return" is deprecated. Use "blank_line_before_statement" instead.
- Rule "no_extra_consecutive_blank_lines" is deprecated. Use "no_extra_blank_lines" instead.
- Rule "trailing_comma_in_multiline_array" is deprecated. Use "trailing_comma_in_multiline" instead.
Changes
Grabbed the brand new v3 configuration template from: https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/3.0/.php_cs.dist
And spliced in rules in the new format and syntax as outlined in. https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/3.0/doc/config.rst https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/v3.0.0/UPGRADE-v3.md#changed-options
Considerations
The main thing that seems to be different is this one. Original
'binary_operator_spaces' => [
'align_double_arrow' => null,
'align_equals' => null,
],
New
'binary_operator_spaces' => [
'operators' => [
'=' => null,
'=>' => null,
],
],
I believe I converted this but would really appreciate some confirmation cause it was kinda hard to lookup what it would do. i referenced the below links. https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/3.0/doc/rules/operator/binary_operator_spaces.rst https://stackoverflow.com/questions/58121806/possible-to-align-sequence-of-align-operators https://gitter.im/FriendsOfPHP/PHP-CS-Fixer?at=5891c1fe1e4d4bd962bdc956 ( last reply on this page scroll down)
I tested the new set with latest v3 release and v2(2.19.0) and it seems to work for me without issues in phpstorm and vscode. I was looking to use the same rules locally
For VScode you can use the same file with hardcoded path on local/remote or relative to the remote/workspace.
/usr/local/src/cs-fixer/config/.php-cs-fixer.php,/home/user/.php-cs-fixer.php
Or the global one on both dev servers:
Config file:
/usr/local/src/cs-fixer/config/.php-cs-fixer.php
Executable path(Optional as VS Code has its own copy in ${extensionPath}/php-cs-fixer.phar
):
/usr/local/src/cs-fixer/php-cs-fixer