-
Notifications
You must be signed in to change notification settings - Fork 15
Closed
Description
analyze a file like
<?php
namespace X;
class A {
public function aMethod():bool {
return true;
}
}
function doFoo() {
/** @var A $x */
$x = createMagically();
$x->aMethod();
}
triggers this exception
$ php vendor/bin/phpstan analyze test.php --debug -v
Note: Using configuration file C:\dvl\Workspace\dead-code-detector\phpstan.neon.dist.
C:\dvl\Workspace\dead-code-detector\test.php
-- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Error
-- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Internal error: Function createMagically not found while trying to analyse it - discovering symbols is probably not configured properly. while analysing file
C:\dvl\Workspace\dead-code-detector\test.php
Post the following stack trace to https://github.com/phpstan/phpstan/issues/new?template=Bug_report.yaml:
## phar://C:/dvl/Workspace/dead-code-detector/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/BetterReflectionProvider.php(247)
#0 phar://C:/dvl/Workspace/dead-code-detector/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ReflectionProvider/MemoizingReflectionProvider.php(67):
PHPStan\Reflection\BetterReflection\BetterReflectionProvider->getFunction()
shipmonk-rnd/dead-code-detector#1 C:\dvl\Workspace\dead-code-detector\vendor\shipmonk\phpstan-rules\src\Rule\ForbidCheckedExceptionInCallableRule.php(430):
PHPStan\Reflection\ReflectionProvider\MemoizingReflectionProvider->getFunction()
shipmonk-rnd/dead-code-detector#2 C:\dvl\Workspace\dead-code-detector\vendor\shipmonk\phpstan-rules\src\Rule\ForbidCheckedExceptionInCallableRule.php(123):
ShipMonk\PHPStan\Rule\ForbidCheckedExceptionInCallableRule->whitelistAllowedCallables()
shipmonk-rnd/dead-code-detector#3 phar://C:/dvl/Workspace/dead-code-detector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(120):
ShipMonk\PHPStan\Rule\ForbidCheckedExceptionInCallableRule->processNode()
shipmonk-rnd/dead-code-detector#4 phar://C:/dvl/Workspace/dead-code-detector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(583):
PHPStan\Analyser\FileAnalyser->PHPStan\Analyser\{closure}()
shipmonk-rnd/dead-code-detector#5 phar://C:/dvl/Workspace/dead-code-detector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(728):
PHPStan\Analyser\NodeScopeResolver::PHPStan\Analyser\{closure}()
shipmonk-rnd/dead-code-detector#6 phar://C:/dvl/Workspace/dead-code-detector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(3237):
PHPStan\Analyser\NodeScopeResolver::PHPStan\Analyser\{closure}()
because ForbidCheckedExceptionInCallableRule
calls $this->reflectionProvider->getFunction
without a previous $this->reflectionProvider->hasFunction
.
I guess similar things are possible with MethodCall
, StaticCall
etc.
root-cause of the problem is in shipmonk/phpstan-rules
Metadata
Metadata
Assignees
Labels
No labels