phpstan: Crash on /vendor/symfony/polyfill-mbstring/bootstrap.php

Bug report

My phpstan.neon:

parameters:
        level: 6
        paths:
                - app
                - classes

.reviewdog.yml:

runner:

  phpstan:
    format: phpstan
    cmd: phpstan analyse --level 2 --error-format=raw --no-progress --debug -vvv --memory-limit=3G -c /app/phpstan.neon /app

The error:

<snip>
/app/vendor/symfony/polyfill-mbstring/Mbstring.php
/app/vendor/symfony/polyfill-mbstring/bootstrap.php
Fatal error: Uncaught Error: Call to a member function getType() on null in phar:///usr/bin/phpstan/src/Rules/Functions/IncompatibleDefaultParameterTypeRule.php:50
Stack trace:
#0 phar:///usr/bin/phpstan/src/Analyser/FileAnalyser.php(46): PHPStan\Rules\Functions\IncompatibleDefaultParameterTypeRule->processNode(Object(PhpParser\Node\Stmt\Function_), Object(PHPStan\Analyser\MutatingScope))
#1 phar:///usr/bin/phpstan/src/Analyser/NodeScopeResolver.php(239): PHPStan\Analyser\FileAnalyser::PHPStan\Analyser\{closure}(Object(PhpParser\Node\Stmt\Function_), Object(PHPStan\Analyser\MutatingScope))
#2 phar:///usr/bin/phpstan/src/Analyser/NodeScopeResolver.php(199): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Function_), Object(PHPStan\Analyser\MutatingScope), Object(Closure))
#3 phar:///usr/bin/phpstan/src/Analyser/NodeScopeResolver.php(383): PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\If_), Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure))
#4 pha in phar:///usr/bin/phpstan/src/Rules/Functions/IncompatibleDefaultParameterTypeRule.php on line 50
2020/08/08 19:40:52 reviewdog: [finish] runner=phpstan  error=exit status 255
reviewdog: phpstan failed with zero findings: The command itself failed (exit status 255) or reviewdog cannot parse the results

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

The problem is:

phpstan analyse --level 2 --error-format=raw --no-progress --debug -vvv --memory-limit=3G -c /app/phpstan.neon /app

Because you have that /app there it means that paths from the config file aren’t used, and you ran PHPStan even on /app/vendor So either run PHPStan like this:

phpstan analyse --level 2 --error-format=raw --no-progress --debug -vvv --memory-limit=3G -c /app/phpstan.neon

OR:

phpstan analyse --level 2 --error-format=raw --no-progress --debug -vvv --memory-limit=3G -c /app/phpstan.neon /app/app /app/classes