PHP-CS-Fixer: The rules contain unknown fixers

When executing php-cs-fixer I always receive the following error:

In ConfigurationResolver.php line 745:

  The rules contain unknown fixers: "php_unit_fqcn_annotation", "phpdoc_types" (did you mean "phpdoc_order"?).

The problem only occurs when I use the “@Symfony” rule set. With the “@PSR2” rule set everything is working. Also in other projects the configuration is working as expected.

The PHP version you are using ($ php -v):

PHP 7.1.9-1+0~20170902060604.8+jessie~1.gbpebe5d6 (cli) (built: Sep 2 2017 06:21:43) ( NTS ) Copyright © 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright © 1998-2017 Zend Technologies with Zend OPcache v7.1.9-1+0~20170902060604.8+jessie~1.gbpebe5d6, Copyright © 1999-2017, by Zend Technologies with Xdebug v2.5.5, Copyright © 2002-2017, by Derick Rethans

PHP CS Fixer version you are using ($ php-cs-fixer -V):

PHP CS Fixer 2.9.0 Speechless by Fabien Potencier and Dariusz Ruminski

The command you use to run PHP CS Fixer:

php-cs-fixer fix --dry-run

The configuration file you are using, if any:

<?php

$finder = PhpCsFixer\Finder::create()
    ->in(__DIR__.'/src')
;

return PhpCsFixer\Config::create()
    ->setRules([
        '@Symfony' => true,
    ])
    ->setUsingCache(false)
    ->setFinder($finder)
    ;

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 29 (14 by maintainers)

Most upvoted comments

I removed now every dependency and created a single directory with only one file. Still the same error.

composer.json

{
    "autoload": {
        "psr-4": {
            "App\\": "app"
        }
    },
    },
    "require": {
        "php": ">=7.0"
    },
    "require-dev": {
        "friendsofphp/php-cs-fixer": "2.9.*"
    },
    "config": {
        "sort-packages": true
    }
}

The file “Foo.php” in the directory “app” (this is the only file in this directory):

<?php

namespace App;

class Foo
{

}

In addition I tried to run it with PHP 7.0 and 7.1 and I get different errors.

With 7.1 inside Docker:

Loaded config default from "/var/www/source/.php_cs".

In ConfigurationResolver.php line 745:

  The rules contain unknown fixers: "php_unit_fqcn_annotation", "phpdoc_types" (did you mean "phpdoc_order"?).


fix [--path-mode PATH-MODE] [--allow-risky ALLOW-RISKY] [--config CONFIG] [--dry-run] [--rules RULES] [--using-cache USING-CACHE] [--cache-file CACHE-FILE] [--diff] [--diff-format DIFF-FORMAT] [--format FORMAT] [--stop-on-violation] [--show-progress SHOW-PROGRESS] [--] [<path>]...

With 7.0 inside Docker:

PHP Parse error:  syntax error, unexpected '?', expecting variable (T_VARIABLE) in /var/www/source/vendor/symfony/options-resolver/OptionsResolver.php on line 980

With 7.1 on my Mac:


Fatal error: Uncaught Error: Class 'PhpCsFixer\Finder' not found in /Users/alex/Projects/Api/Country/.php_cs:3
Stack trace:
#0 phar:///usr/local/bin/php-cs-fixer/Symfony/CS/Console/Command/FixCommand.php(318): include()
#1 phar:///usr/local/bin/php-cs-fixer/vendor/symfony/console/Command/Command.php(256): Symfony\CS\Console\Command\FixCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#2 phar:///usr/local/bin/php-cs-fixer/vendor/symfony/console/Application.php(788): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 phar:///usr/local/bin/php-cs-fixer/vendor/symfony/console/Application.php(186): Symfony\Component\Console\Application->doRunCommand(Object(Symfony\CS\Console\Command\FixCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 phar:///usr/local/bin/php-cs-fixer/vendor/symfo in /Users/alex/Projects/Api/Country/.php_cs on line 3