hoaproject / Devtools

The Hoa\Devtools library.
https://hoa-project.net/
6 stars 6 forks source link

Exception thrown during devtools:cs when using a `php-cs-fixer` version > v2.8.0 #51

Closed shulard closed 6 years ago

shulard commented 6 years ago

Hello,

I wanted to run the devtools:cs CS command when working on the #49 PR and got the following error :

$ vendor/bin/hoa devtools:cs Bin/Snapshot.php
Loaded config default from "/Users/shulard/Sites/Forks/Hoa/Devtools/Resource/PHPCSFixer/ConfigurationFile.php".

Fixed all files in 0.127 seconds, 10.000 MB memory used

Files that were not fixed due to errors reported during fixing:
   1) /Users/shulard/Sites/Forks/Hoa/Devtools/Bin/Snapshot.php

I searched around the errors reported during fixing and got the following details when running php-cs-fixer directly :

$ php-cs-fixer fix --config Resource/PHPCSFixer/ConfigurationFile.php --allow-risky yes Bin/Snapshot.php -vvv
Loaded config default from "Resource/PHPCSFixer/ConfigurationFile.php".
E
Legend: ?-unknown, I-invalid file syntax, file ignored, S-Skipped, .-no changes, F-fixed, E-error

Fixed all files in 0.123 seconds, 10.000 MB memory used

Files that were not fixed due to errors reported during fixing:
   1) /Users/shulard/Sites/Forks/Hoa/Devtools/Bin/Snapshot.php

        [ArgumentCountError]
        Too few arguments to function PhpCsFixer\AbstractLinesBeforeNamespaceFixer::fixLinesBeforeNamespace(), 3 passed in /Users/shulard/Sites/Forks/Hoa/Devtools/Resource/PHPCSFixer/Fixer/NoBlankLinesBeforeEntity.php on line 67 and exactly 4 expected

      PhpCsFixer\AbstractLinesBeforeNamespaceFixer->fixLinesBeforeNamespace()
        in /Users/shulard/Sites/Forks/Hoa/Devtools/Resource/PHPCSFixer/Fixer/NoBlankLinesBeforeEntity.php at line 67
      Hoa\Devtools\Resource\PHPCSFixer\Fixer\NoBlankLinesBeforeEntity->applyfix()
        in /usr/local/Cellar/php-cs-fixer/2.10.0/src/AbstractFixer.php at line 73
      PhpCsFixer\AbstractFixer->fix()
        in /usr/local/Cellar/php-cs-fixer/2.10.0/src/Runner/Runner.php at line 190
      PhpCsFixer\Runner\Runner->fixFile()
        in /usr/local/Cellar/php-cs-fixer/2.10.0/src/Runner/Runner.php at line 132
      PhpCsFixer\Runner\Runner->fix()
        in /usr/local/Cellar/php-cs-fixer/2.10.0/src/Console/Command/FixCommand.php at line 219
      PhpCsFixer\Console\Command\FixCommand->execute()
        in /usr/local/Cellar/php-cs-fixer/2.10.0/vendor/symfony/console/Command/Command.php at line 252
      [ ... ]

The PhpCsFixer\AbstractLinesBeforeNamespaceFixer::fixLinesBeforeNamespace signature as changed in PHP-CS-Fixer v2.8.1 :

Since Hoa rely on the host installed php-cs-fixer binary, we have an edge case to check here...

Since PHP-CS-Fixer use the Symfony/Console component, we can check the PhpCsFixer\Console\Application::VERSION constant to check how much parameters we need to use...

Hywan commented 6 years ago

I guess #53 addressed this issue.