Search code examples
phpubuntuzend-frameworkphpstanrector

Facing an issue with PHPstan


I am a novice in PHP and I am working on a legacy project where I am trying to upgrade PHP with Version 8.2 + ubuntu environment. The PHP code is written in ZEND Framework. The legacy code is written in PHP 5.3. I am planning to use Rector framework. According to the Rector, the second step I need to perform is "Running a static Analyzer tool". The tool rector recommends for this step is phpstan.

I am using the same and when I give this command,

vendor/bin/phpstan analyse application

**The PHPStan analyses and reports errors. **

I added a phpstan.neon configuration file, and added basic rules like:

parameters:
  level:1
bootstrapFiles:
- /var/www/fem-stage/vendor/autoload.php
scanDirectories:
- library
fileExtensions:
- php
- ini

I am getting this error.

    root:/var/www/fem-stage# vendor/bin/phpstan analyse application
Note: Using configuration file /var/www/fem-stage/phpstan.neon.

In Helpers.php line 62:

Missing parameter 'featureToggles. alwaysTrueAlwaysReported'.

When I pass debug Command Line Argument, I am getting 2 PHP Fatal Errors.

PHP Fatal error:  Uncaught _PHPStan_01e5828ef\Nette\InvalidArgumentException: Missing parameter 'featureToggles.alwaysTrueAlwaysReported'. in phar:///var/www/fem-stage/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/Helpers.php:62
STACK TRACE
Fatal error: Uncaught _PHPStan_01e5828ef\Nette\InvalidArgumentException: Missing parameter 'featureToggles.alwaysTrueAlwaysReported'. in phar:///var/www/fem-stage/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/Helpers.php:62
STACK TRACE

Looks like it is not in my PHP Project code. All my PHP code is under the "Current Directory"/application folder.


Solution

  • This kind of error is really weird and shouldn't be possible. Would you care to open a GitHub Discussion over at PHPStan's repository where you're most likely to get relevant help? Thanks.

    As for the actual error, you've definitely installed PHPStan 1.11.5 which is one of the latest releases (I can recognize that from the stack trace). The error Missing parameter 'featureToggles.alwaysTrueAlwaysReported' should never happen because the PHPStan itself contains this parameter. So something weird went very wrong.