Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not get class storage on multithreaded scanning #6931

Closed
danog opened this issue Nov 16, 2021 · 1 comment · Fixed by #6952
Closed

Could not get class storage on multithreaded scanning #6931

danog opened this issue Nov 16, 2021 · 1 comment · Fixed by #6952

Comments

@danog
Copy link
Collaborator

danog commented Nov 16, 2021

Encountering the following error on multithreaded scanning:

Uncaught Exception: InvalidArgumentException Could not get class storage for z\packages\crud\ux\tag
Emitted in /home/daniil/zoon/zoon/vendor-bin/check/vendor/vimeo/psalm/src/Psalm/Internal/Provider/ClassLikeStorageProvider.php:43
Stack trace in the forked worker:
#0 /home/daniil/zoon/zoon/vendor-bin/check/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/ClassLikes.php(606): Psalm\Internal\Provider\ClassLikeStorageProvider->get('z\\packages\\crud...')
#1 /home/daniil/zoon/zoon/vendor-bin/check/vendor/vimeo/psalm/src/Psalm/Codebase.php(669): Psalm\Internal\Codebase\ClassLikes->classExtends('z\\packages\\crud...', 'z\\packages\\crud...')
#2 /home/daniil/zoon/zoon/vendor-bin/check/vendor/vimeo/psalm/src/Psalm/Internal/Type/Comparator/ObjectComparator.php(275): Psalm\Codebase->classExtendsOrImplements('z\\packages\\crud...', 'z\\packages\\crud...')
#3 /home/daniil/zoon/zoon/vendor-bin/check/vendor/vimeo/psalm/src/Psalm/Internal/Type/Comparator/AtomicTypeComparator.php(295): Psalm\Internal\Type\Comparator\ObjectComparator::isShallowlyContainedBy(Object(Psalm\Codebase), Object(Psalm\Type\Atomic\TNamedObject), Object(Psalm\Type\Atomic\TNamedObject), false, NULL)
#4 /home/daniil/zoon/zoon/vendor-bin/check/vendor/vimeo/psalm/src/Psalm/Internal/Type/Comparator/UnionTypeComparator.php(159): Psalm\Internal\Type\Comparator\AtomicTypeComparator::isContainedBy(Object(Psalm\Codebase), Object(Psalm\Type\Atomic\TNamedObject), Object(Psalm\Type\Atomic\TNamedObject), false, true, NULL)
#5 /home/daniil/zoon/zoon/vendor-bin/check/vendor/vimeo/psalm/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockScanner.php(946): Psalm\Internal\Type\Comparator\UnionTypeComparator::isContainedBy(Object(Psalm\Codebase), Object(Psalm\Type\Union), Object(Psalm\Type\Union))
#6 /home/daniil/zoon/zoon/vendor-bin/check/vendor/vimeo/psalm/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockScanner.php(361): Psalm\Internal\PhpVisitor\Reflector\FunctionLikeDocblockScanner::handleReturn(Object(Psalm\Codebase), Object(Psalm\Internal\Scanner\FunctionDocblockComment), 'Tag', false, Object(Psalm\Internal\Scanner\FileScanner), Object(Psalm\Storage\MethodStorage), Object(PhpParser\Node\Stmt\ClassMethod), Object(Psalm\Aliases), Array, Array, Array, Object(Psalm\Storage\ClassLikeStorage), 'Z\\Module\\Modera...', Object(Psalm\Storage\FileStorage))
#7 /home/daniil/zoon/zoon/vendor-bin/check/vendor/vimeo/psalm/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php(495): Psalm\Internal\PhpVisitor\Reflector\FunctionLikeDocblockScanner::addDocblockInfo(Object(Psalm\Codebase), Object(Psalm\Internal\Scanner\FileScanner), Object(Psalm\Storage\FileStorage), Object(Psalm\Aliases), Array, Object(Psalm\Storage\ClassLikeStorage), Array, Object(Psalm\Storage\MethodStorage), Object(PhpParser\Node\Stmt\ClassMethod), Object(Psalm\Internal\Scanner\FunctionDocblockComment), false, false, 'Z\\Module\\Modera...')
#8 /home/daniil/zoon/zoon/vendor-bin/check/vendor/vimeo/psalm/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php(223): Psalm\Internal\PhpVisitor\Reflector\FunctionLikeNodeScanner->start(Object(PhpParser\Node\Stmt\ClassMethod))
#9 /home/daniil/zoon/zoon/vendor-bin/check/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(200): Psalm\Internal\PhpVisitor\ReflectorVisitor->enterNode(Object(PhpParser\Node\Stmt\ClassMethod))
#10 /home/daniil/zoon/zoon/vendor-bin/check/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(114): PhpParser\NodeTraverser->traverseArray(Array)
#11 /home/daniil/zoon/zoon/vendor-bin/check/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(223): PhpParser\NodeTraverser->traverseNode(Object(PhpParser\Node\Stmt\Class_))
#12 /home/daniil/zoon/zoon/vendor-bin/check/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(114): PhpParser\NodeTraverser->traverseArray(Array)
#13 /home/daniil/zoon/zoon/vendor-bin/check/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(223): PhpParser\NodeTraverser->traverseNode(Object(PhpParser\Node\Stmt\Namespace_))
#14 /home/daniil/zoon/zoon/vendor-bin/check/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(91): PhpParser\NodeTraverser->traverseArray(Array)
#15 /home/daniil/zoon/zoon/vendor-bin/check/vendor/vimeo/psalm/src/Psalm/Internal/Scanner/FileScanner.php(86): PhpParser\NodeTraverser->traverse(Array)
#16 /home/daniil/zoon/zoon/vendor-bin/check/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(579): Psalm\Internal\Scanner\FileScanner->scan(Object(Psalm\Codebase), Object(Psalm\Storage\FileStorage), false, Object(Psalm\Progress\DefaultProgress))
#17 /home/daniil/zoon/zoon/vendor-bin/check/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(330): Psalm\Internal\Codebase\Scanner->scanFile('/home/daniil/zo...', Array, true)
#18 /home/daniil/zoon/zoon/vendor-bin/check/vendor/vimeo/psalm/src/Psalm/Internal/Fork/Pool.php(194): Psalm\Internal\Codebase\Scanner->Psalm\Internal\Codebase\{closure}(130, '/home/daniil/zo...')
#19 /home/daniil/zoon/zoon/vendor-bin/check/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(398): Psalm\Internal\Fork\Pool->__construct(Array, Object(Closure), Object(Closure), Object(Closure))
#20 /home/daniil/zoon/zoon/vendor-bin/check/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(294): Psalm\Internal\Codebase\Scanner->scanFilePaths(16)
#21 /home/daniil/zoon/zoon/vendor-bin/check/vendor/vimeo/psalm/src/Psalm/Codebase.php(473): Psalm\Internal\Codebase\Scanner->scanFiles(Object(Psalm\Internal\Codebase\ClassLikes), 16)
#22 /home/daniil/zoon/zoon/vendor-bin/check/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php(594): Psalm\Codebase->scanFiles(16)
#23 /home/daniil/zoon/zoon/vendor-bin/check/vendor/vimeo/psalm/src/Psalm/Internal/Cli/Psalm.php(360): Psalm\Internal\Analyzer\ProjectAnalyzer->check('/home/daniil/zo...', true)
#24 /home/daniil/zoon/zoon/vendor-bin/check/vendor/vimeo/psalm/psalm(4): Psalm\Internal\Cli\Psalm::run(Array)
#25 {main} in /home/daniil/zoon/zoon/vendor-bin/check/vendor/vimeo/psalm/src/Psalm/Internal/Fork/Pool.php:369
Stack trace:
#0 /home/daniil/zoon/zoon/vendor-bin/check/vendor/vimeo/psalm/src/Psalm/Internal/Fork/Pool.php(403): Psalm\Internal\Fork\Pool->readResultsFromChildren()
#1 /home/daniil/zoon/zoon/vendor-bin/check/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(405): Psalm\Internal\Fork\Pool->wait()
#2 /home/daniil/zoon/zoon/vendor-bin/check/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(294): Psalm\Internal\Codebase\Scanner->scanFilePaths(16)
#3 /home/daniil/zoon/zoon/vendor-bin/check/vendor/vimeo/psalm/src/Psalm/Codebase.php(473): Psalm\Internal\Codebase\Scanner->scanFiles(Object(Psalm\Internal\Codebase\ClassLikes), 16)
#4 /home/daniil/zoon/zoon/vendor-bin/check/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php(594): Psalm\Codebase->scanFiles(16)
#5 /home/daniil/zoon/zoon/vendor-bin/check/vendor/vimeo/psalm/src/Psalm/Internal/Cli/Psalm.php(360): Psalm\Internal\Analyzer\ProjectAnalyzer->check('/home/daniil/zo...', true)
#6 /home/daniil/zoon/zoon/vendor-bin/check/vendor/vimeo/psalm/psalm(4): Psalm\Internal\Cli\Psalm::run(Array)
#7 {main}
(Psalm 4.12.3@2bfa8a4b75ff585c25f33199620c5491f4cf2e5e crashed due to an uncaught Throwable)

It seems like @ https://github.com/vimeo/psalm/blob/master/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockScanner.php#L956, UnionTypeComparator::isContainedBy is called at scan-time (= with a partially constructed classlike storage), even if it may lead to a call of ObjectComparator::isShallowlyContainedBy, which uses said storage assuming all classes are populated.

@orklah
Copy link
Collaborator

orklah commented Nov 18, 2021

This is a mistake I made in #6187

I'll have to think about the best way to fix that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants