This is guide for upgrade from version 2.x to 3.x of this package.
The 3.x version of this package was created to support Laravel 8.x and later, not for previous Laravel versions. It is implemented with the PHP-CS-Fixer version 3.x, which has some special changes compared to 2.x. Therefore, this package must also be changed to be compatible. Here are some notable ones:
2.x | 3.x | Description |
---|---|---|
.php_cs |
.php-cs-fixer.dist.php |
Published Fixer configuration file |
.php_cs.cache |
.php-cs-fixer.cache |
Cache file |
2.x | 3.x |
---|---|
use static ::create() method. |
use constructor |
Example:
Before (in 2.x):
<?php
use PhpCsFixer\Config;
// ...
return Config::create()
->setFinder($finder)
->setRules($rules)
->setUsingCache(true);
Now (in 3.x):
<?php
use PhpCsFixer\Config;
// ...
$config = new Config;
return $config
->setFinder($finder)
->setRules($rules)
->setUsingCache(true);
2.x | 3.x |
---|---|
@Symfony + some overrides |
@PhpCsFixer + some overrides |
Note:
- It should be noted that the
@PhpCsFixer
rule set includes the@Symfony
rule set. - The
@Symfony
rule set now uses the PSR-12 coding standard as the default.
If you want to learn more about the changes of the PHP-CS-Fixer 3.x, please see here