Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

phpstan-rules: Class "X" does not exist #4163

Closed
staabm opened this issue Jun 10, 2022 · 1 comment · Fixed by #4166
Closed

phpstan-rules: Class "X" does not exist #4163

staabm opened this issue Jun 10, 2022 · 1 comment · Fixed by #4166

Comments

@staabm
Copy link
Contributor

staabm commented Jun 10, 2022

today we ran into a problem, which I guess was introduced with the latest release, since we did not see it before.

we get class not found errors, which are triggered within ParentClassMethodNodeResolver.

isn't usage of ReflectionMethod->__construct() runtime reflection, and the code itself should actually be reflected via static reflection instead?

 Internal error: Internal error: Class "Fare_Form" does not exist in file C:\dvl\Workspace\fare\application\B2C\forms\Article.php

     Post the following stack trace to https://github.com/phpstan/phpstan/issues/new?template=Bug_report.md:
     #0 C:\dvl\Workspace\fare\vendor-bin\phpstan\vendor\symplify\phpstan-rules\src\ParentClassMethodNodeResolver.php(29): ReflectionMethod->__construct()
     #1 C:\dvl\Workspace\fare\vendor-bin\phpstan\vendor\symplify\phpstan-rules\src\Rules\NoReferenceRule.php(112): Symplify\PHPStanRules\ParentClassMethodNodeResolver->resolveParentClassMethod()
     #2 C:\dvl\Workspace\fare\vendor-bin\phpstan\vendor\symplify\phpstan-rules\src\Rules\NoReferenceRule.php(68): Symplify\PHPStanRules\Rules\NoReferenceRule->collectParamErrorMessages()
     #3 C:\dvl\Workspace\fare\vendor-bin\phpstan\vendor\symplify\phpstan-rules\src\Rules\AbstractSymplifyRule.php(36): Symplify\PHPStanRules\Rules\NoReferenceRule->process()
     #4 phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(102): Symplify\PHPStanRules\Rules\AbstractSymplifyRule->processNode()
     #5 phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/src/Node/ClassStatementsGatherer.php(95): PHPStan\Analyser\FileAnalyser->PHPStan\Analyser\{closure}()
     #6 phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(380): PHPStan\Node\ClassStatementsGatherer->__invoke()
     #7 phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(325): PHPStan\Analyser\NodeScopeResolver->processStmtNode()
     #8 phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(553): PHPStan\Analyser\NodeScopeResolver->processStmtNodes()
     #9 phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(296): PHPStan\Analyser\NodeScopeResolver->processStmtNode()
     #10 phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(189): PHPStan\Analyser\NodeScopeResolver->processNodes()
     #11 phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/src/Command/WorkerCommand.php(143): PHPStan\Analyser\FileAnalyser->analyseFile()
     #12 phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97):
     PHPStan\Command\WorkerCommand->PHPStan\Command\{closure}()
     #13 phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/vendor/clue/ndjson-react/src/Decoder.php(110): _PHPStan_98a3b0791\Evenement\EventEmitter->emit()
     #14 phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97):
     _PHPStan_98a3b0791\Clue\React\NDJson\Decoder->handleData()
     #15 phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/vendor/react/stream/src/Util.php(62): _PHPStan_98a3b0791\Evenement\EventEmitter->emit()
     #16 phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97):
     _PHPStan_98a3b0791\React\Stream\Util::_PHPStan_98a3b0791\React\Stream\{closure}()
     #17 phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/vendor/react/stream/src/DuplexResourceStream.php(154): _PHPStan_98a3b0791\Evenement\EventEmitter->emit()
     #18 phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/vendor/react/event-loop/src/StreamSelectLoop.php(201):
     _PHPStan_98a3b0791\React\Stream\DuplexResourceStream->handleData()
     #19 phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/vendor/react/event-loop/src/StreamSelectLoop.php(173):
     _PHPStan_98a3b0791\React\EventLoop\StreamSelectLoop->waitForStreamActivity()
     #20 phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/src/Command/WorkerCommand.php(106): _PHPStan_98a3b0791\React\EventLoop\StreamSelectLoop->run()
     #21 phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Command/Command.php(259): PHPStan\Command\WorkerCommand->execute()
     #22 phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(856): _PHPStan_98a3b0791\Symfony\Component\Console\Command\Command->run()
     #23 phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(259):
     _PHPStan_98a3b0791\Symfony\Component\Console\Application->doRunCommand()
     #24 phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(157): _PHPStan_98a3b0791\Symfony\Component\Console\Application->doRun()
     #25 phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(127): _PHPStan_98a3b0791\Symfony\Component\Console\Application->run()
     #26 phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(128): _PHPStan_98a3b0791\{closure}()
     #27 C:\dvl\Workspace\fare\vendor-bin\phpstan\vendor\phpstan\phpstan\phpstan(8): require('...')
     #28 C:\dvl\Workspace\fare\vendor\bin\phpstan(120): include('...')
     #29 {main}
     Child process error (exit code 1):

@staabm
Copy link
Contributor Author

staabm commented Jun 10, 2022

its quite suprising that phpstan still throws this error, even if we use scanDirectories config option and point phpstan exactly to the directory the class-file is included.. this tells me that symplify is not using the phpstan autoloading facilities it seems.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant