3.3.41. Phpcsfixer¶
3.3.41.1. Phpcsfixer¶
The Phpcsfixer report provides a configuration file for php-cs-fixer, that automatically fixes issues found in related analysis in exakat.
This report builds a configuration file for php-cs-fixer.
Use === null : is_null
Else If Versus Elseif : elseif
Multiple Unset() : combine_consecutive_unsets
Classes/DontUnsetProperties: no_unset_on_property
Use Constant Instead Of Function : function_to_constant
PHP7 Dirname : combine_nested_dirname
Could Use __DIR__ : dir_constant
Isset Multiple Arguments : combine_consecutive_issets
Logical Should Use Symbolic Operators : logical_operators
Not Not : no_short_bool_cast
PHP-cs-fixer is a tool to automatically fix PHP Coding Standards issues. Some of the modifications are more than purely coding standards, such has replacing dirname(dirname($path))
with dirname($path, 2)
.
Exakat builds a configuration file for php-cs-fixer, that will automatically fix a number of results from the audit. Here is the process :
Run exakat audit
Get Phpcsfixer report from exakat :
php exakat.phar report -p <project> -format Phpcsfixer
Update the target repository in the generated code
Save this new configuration in a file called ‘.php_cs’
Run php-cs-fixer on your code :
php php-cs-fixer.phar fix /path/to/code --dry-run
Fixed your code with php-cs-fixer :
php php-cs-fixer.phar fix /path/to/code
Run a new exakat audit
This configuration file should be reviewed before being used. In particular, the target files should be updated with the actual repository : this is the first part of the configuration.
It is also recommended to use the option ‘–dry-run’ with php-cs-fixer to check the first run.
Php-cs-fixer runs fixes for coding standards : this reports focuses on potential fixes. It is recommended to complete this base report with extra coding conventions fixes. The building of a coding convention is outside the scope of this report.
Exakat may find different issues than php-cs-fixer : using this report reduces the number of reported issues, but may leave some issues unsolved. In that case, manual fixing is recommended.
3.3.41.2. Specs¶
Short name |
Phpcsfixer |
Rulesets |
php-cs-fixable. |
Type |
JSON |
Target |
This report is written in ‘phpcsfixer.exakat.php’. |
Available in |