Hello,
The php-cs-fixer-v2.phar file doesn't seem up to date.
I got this error Fatal error: Uncaught Error: Call to undefined method PhpCsFixer\Finder::ignoreVCSIgnored(). Indeed, vendor/symfony/finder/Finder.php (inside the .phar) doesn't contain ignoreVCSIgnored(). The version of this Symfony Component doesn't seem up to date.
$ php -v):=> 7.3.3
$ php-cs-fixer -V):=> 2.15.1
=> php-cs-fixer fix
$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->name('*.php')
->ignoreVCSIgnored(true)
->path('/^src\//')
;
return PhpCsFixer\Config::create()
->setRules([
'@PSR1' => true,
'@PSR2' => true,
'@Symfony' => true,
'cast_spaces' => ['space'=>'none'],
'concat_space' => ['spacing'=>'one'],
'phpdoc_align' => ['align'=>'left'],
'yoda_style' => null,
'array_syntax' => ['syntax' => 'short'],
'array_indentation' => true,
'multiline_whitespace_before_semicolons' => ['strategy' => 'new_line_for_chained_calls'],
])
->setIndent("\t")
->setFinder($finder)
;
ignoreVCSIgnored was added in symfony/finder#4.3, which requires PHP ^7.1 ( https://github.com/symfony/finder/blob/v4.3.0/composer.json#L19 )
PHP CS Fixer supports v5 as well ( https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/2.15/composer.json#L17 ), thus phar file can not contain symfony/finder#4.3
closing as answered, but feel free to discuss more about this : )
Will v3 still support php 5, or is it an idea to up to 7.1? (I don't know anything about the planning for 3.0)
I don't understand, what's the solution ?
@mrleblanc101 what is the issue or question you have?
@mrleblanc101 I believe the best solution is to install php-cs-fixer trough composer instead of using the .phar:
composer global require friendsofphp/php-cs-fixer
@SpacePossum May you confirm?
But this is not ideal for everyone. PHP5 is deprecated from a long time ago, maybe time to move with a new major release?
IMO, using Composer is indeed a better way to install PHP CS Fixer but installing it globally is probably a bad solution too: if you have different projects with different PHP CS Fixer configs, those might not all be compatible with the global version that you install (e.g. a config enabling a rule that does not exist in the installed version yet).
Installing it via each project's composer.json prevents that. Even better is to use a dedicated composer.json to avoid conflicts with the project's dependencies:
$ composer require --working-dir=tools/php-cs-fixer friendsofphp/php-cs-fixer
@julienfalque I didn't know for the --working-dir option, looks like a replacement for composer-bin plugin? Great thing.
For my case, I prefer the global install for a prettier like company project: https://gitlab.com/nexylan/pretty
But indeed, for other case, your argument is valid. :+1: