stechstudio / Laravel-PHP-CS-Fixer

Artisan Command for FriendsOfPHP/PHP-CS_Fixer
MIT License
147 stars 28 forks source link

Too few arguments to function FixCommandExitStatusCalculator::calculate #15

Closed repat closed 5 years ago

repat commented 5 years ago

PHP-CS-Fixer

composer.json

{
"stechstudio/laravel-php-cs-fixer": "^2.0"
}

Error

 Symfony\Component\Debug\Exception\FatalThrowableError  : Too few arguments to function PhpCsFixer\Console\Command\FixCommandExitStatusCalculator::calculate(), 4 passed in /Users/user/project/vendor/stechstudio/laravel-php-cs-fixer/src/Console/FixCommand.php on line 138 and exactly 5 expected

  at /Users/user/project/vendor/friendsofphp/php-cs-fixer/src/Console/Command/FixCommandExitStatusCalculator.php:38
    34|      * @param bool $hasLintErrorsAfterFixing
    35|      *
    36|      * @return int
    37|      */
  > 38|     public function calculate($isDryRun, $hasChangedFiles, $hasInvalidErrors, $hasExceptionErrors, $hasLintErrorsAfterFixing)
    39|     {
    40|         $exitStatus = 0;
    41|
    42|         if ($isDryRun) {

  Exception trace:

  1   PhpCsFixer\Console\Command\FixCommandExitStatusCalculator::calculate()
      /Users/user/project/vendor/stechstudio/laravel-php-cs-fixer/src/Console/FixCommand.php:138

  2   STS\Fixer\Console\FixCommand::handle()
      /Users/user/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32

Possible solution

Seems like a $hasLintErrorsAfterFixing has to be passed to calculate() as well. This is new in Version 2.16.0, which (after SemVer) shouldn't be a breaking change. But it is 🤷‍♂.

$exitStatusCalculator = new FixCommandExitStatusCalculator();

        return $exitStatusCalculator->calculate(
            $resolver->isDryRun(),
            count($changed) > 0,
            count($invalidErrors) > 0,
            count($exceptionErrors) > 0
        );

Hope this helps @bubba-h57