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

5.22.0 regression: Could not get class storage for psl\range\upperboundrangeinterface #10706

Closed
zerkms opened this issue Feb 14, 2024 · 25 comments · Fixed by #10720
Closed

5.22.0 regression: Could not get class storage for psl\range\upperboundrangeinterface #10706

zerkms opened this issue Feb 14, 2024 · 25 comments · Fixed by #10720

Comments

@zerkms
Copy link
Contributor

zerkms commented Feb 14, 2024

It was fine in 5.21.1

Target PHP version: 8.3 (inferred from current PHP version).
Scanning files...
Uncaught InvalidArgumentException: Could not get class storage for psl\range\upperboundrangeinterface in /app-appname/vendor/vimeo/psalm/src/Psalm/Internal/Provider/ClassLikeStorageProvider.php:45
Stack trace:
#0 /app-appname/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/ClassLikes.php(726): Psalm\Internal\Provider\ClassLikeStorageProvider->get()
#1 /app-appname/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/ClassLikes.php(716): Psalm\Internal\Codebase\ClassLikes->getParentInterfaces()
#2 /app-appname/vendor/vimeo/psalm/src/Psalm/Codebase.php(763): Psalm\Internal\Codebase\ClassLikes->interfaceExtends()
#3 /app-appname/vendor/vimeo/psalm/src/Psalm/Internal/Type/Comparator/ObjectComparator.php(357): Psalm\Codebase->interfaceExtends()
#4 /app-appname/vendor/vimeo/psalm/src/Psalm/Internal/Type/Comparator/ObjectComparator.php(117): Psalm\Internal\Type\Comparator\ObjectComparator::isIntersectionShallowlyContainedBy()
#5 /app-appname/vendor/vimeo/psalm/src/Psalm/Internal/Type/Comparator/AtomicTypeComparator.php(350): Psalm\Internal\Type\Comparator\ObjectComparator::isShallowlyContainedBy()
#6 /app-appname/vendor/vimeo/psalm/src/Psalm/Type.php(891): Psalm\Internal\Type\Comparator\AtomicTypeComparator::isContainedBy()
#7 /app-appname/vendor/vimeo/psalm/src/Psalm/Type.php(768): Psalm\Type::intersectAtomicTypes()
#8 /app-appname/vendor/vimeo/psalm/src/Psalm/Internal/PhpVisitor/Reflector/TypeHintResolver.php(112): Psalm\Type::intersectUnionTypes()
#9 /app-appname/vendor/vimeo/psalm/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php(405): Psalm\Internal\PhpVisitor\Reflector\TypeHintResolver::resolve()
#10 /app-appname/vendor/vimeo/psalm/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php(207): Psalm\Internal\PhpVisitor\Reflector\FunctionLikeNodeScanner->start()
#11 /app-appname/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(200): Psalm\Internal\PhpVisitor\ReflectorVisitor->enterNode()
#12 /app-appname/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(114): PhpParser\NodeTraverser->traverseArray()
#13 /app-appname/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(223): PhpParser\NodeTraverser->traverseNode()
#14 /app-appname/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(114): PhpParser\NodeTraverser->traverseArray()
#15 /app-appname/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(223): PhpParser\NodeTraverser->traverseNode()
#16 /app-appname/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(91): PhpParser\NodeTraverser->traverseArray()
#17 /app-appname/vendor/vimeo/psalm/src/Psalm/Internal/Scanner/FileScanner.php(79): PhpParser\NodeTraverser->traverse()
#18 /app-appname/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(554): Psalm\Internal\Scanner\FileScanner->scan()
#19 /app-appname/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(782): Psalm\Internal\Codebase\Scanner->scanFile()
#20 /app-appname/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(428): Psalm\Internal\Codebase\Scanner->scanAPath()
#21 /app-appname/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(280): Psalm\Internal\Codebase\Scanner->scanFilePaths()
#22 /app-appname/vendor/vimeo/psalm/src/Psalm/Config.php(2576): Psalm\Internal\Codebase\Scanner->scanFiles()
#23 /app-appname/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php(372): Psalm\Config->visitComposerAutoloadFiles()
#24 /app-appname/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php(502): Psalm\Internal\Analyzer\ProjectAnalyzer->visitAutoloadFiles()
#25 /app-appname/vendor/vimeo/psalm/src/Psalm/Internal/Cli/Psalm.php(374): Psalm\Internal\Analyzer\ProjectAnalyzer->check()
#26 /app-appname/vendor/vimeo/psalm/psalm(9): Psalm\Internal\Cli\Psalm::run()
#27 /app-appname/vendor/bin/psalm(119): include('...')
#28 {main}
(Psalm 5.22.0@fe2c67ec89f358940f90db05efd2d663388b45a6 crashed due to an uncaught Throwable)

file under test:

<?php
declare(strict_types=1);

// empty file, correct

command:

./vendor/bin/psalm -c configs/<redacted>/psalm.xml configs/<redacted>/a.php --no-cache
<?xml version="1.0"?>
<psalm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" errorLevel="1" findUnusedCode="false" findUnusedBaselineEntry="true" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" autoloader="/app-appname/src-dev/psalm-autoload.php">
    <projectFiles>
        <directory name="."/>
        <ignoreFiles>
            <directory name="vendor"/>
        </ignoreFiles>
    </projectFiles>

    <issueHandlers>
        <UnusedClass>
            <errorLevel type="suppress">
                <directory name="."/>
            </errorLevel>
        </UnusedClass>
    </issueHandlers>

    <plugins>
        <pluginClass class="Psl\Psalm\Plugin"/>
    </plugins>
</psalm>

Removing plugin changes nothing

psalm-autoload.php:

<?php
declare(strict_types=1);

function maybeAutoload(string $path): void
{
    if (!is_file($path)) {
        return;
    }

    require_once $path;
}

maybeAutoload('/app/vendor/autoload.php');
maybeAutoload(getcwd() . '/vendor/autoload.php');

It totally has something to do with autoloader: as if I remove the first autoload.php - it then works fine.

@simonberger
Copy link

I got the same kind of crash.
On 5.22.0 with InvalidArgumentException Could not get class storage for mockery\mockinterface
And on 5.21.1 InvalidArgumentException Could not get class storage for monolog\logger

When I had the error on 5.21.1 I tried to get some insights with --debug which did not help me at all.

Interestingly in 5.22.0 psalm successfully completes when applying --debug and followup calls without the flag are working because of the cache. When adding --no-cache it again crashes when --debug is missing.
I don't know if this information helps at all but I wanted to mention it at least.

@weirdan
Copy link
Collaborator

weirdan commented Feb 15, 2024

--debug switches psalm to single-threaded mode, so the workaround would be to use --threads=1 for the time being.

@simonberger
Copy link

Thanks, that's the solution indeed. I'll stick to 5.18 for now (I know 5.19 and/or 5.20 would probably work as well).

@tm1000
Copy link
Contributor

tm1000 commented Feb 15, 2024

I'm experiencing the same issue

   Exception 

  InvalidArgumentException Could not get class storage for company\internal\namespace\class
Emitted in /app/vendor/vimeo/psalm/src/Psalm/Internal/Provider/ClassLikeStorageProvider.php:45
Stack trace in the forked worker:
#0 /app/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/ClassLikes.php(726): Psalm\Internal\Provider\ClassLikeStorageProvider->get('...')
#1 /app/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/ClassLikes.php(716): Psalm\Internal\Codebase\ClassLikes->getParentInterfaces('...')
#2 /app/vendor/vimeo/psalm/src/Psalm/Codebase.php(763): Psalm\Internal\Codebase\ClassLikes->interfaceExtends('...', '...')
#3 /app/vendor/vimeo/psalm/src/Psalm/Internal/Type/Comparator/ObjectComparator.php(357): Psalm\Codebase->interfaceExtends('...', '...')
#4 /app/vendor/vimeo/psalm/src/Psalm/Internal/Type/Comparator/ObjectComparator.php(117): Psalm\Internal\Type\Comparator\ObjectComparator::isIntersectionShallowlyContainedBy(Object(Psalm\Codebase), Object(Psalm\Type\Atomic\TNamedObject), Object(Psalm\Type\Atomic\TNamedObject), '...', false, false, NULL)
#5 /app/vendor/vimeo/psalm/src/Psalm/Internal/Type/Comparator/AtomicTypeComparator.php(350): Psalm\Internal\Type\Comparator\ObjectComparator::isShallowlyContainedBy(Object(Psalm\Codebase), Object(Psalm\Type\Atomic\TNamedObject), Object(Psalm\Type\Atomic\TNamedObject), false, NULL)
#6 /app/vendor/vimeo/psalm/src/Psalm/Type.php(891): Psalm\Internal\Type\Comparator\AtomicTypeComparator::isContainedBy(Object(Psalm\Codebase), Object(Psalm\Type\Atomic\TNamedObject), Object(Psalm\Type\Atomic\TNamedObject), false, true)
#7 /app/vendor/vimeo/psalm/src/Psalm/Type.php(768): Psalm\Type::intersectAtomicTypes(Object(Psalm\Type\Atomic\TNamedObject), Object(Psalm\Type\Atomic\TNamedObject), Object(Psalm\Codebase), false, false, true)
#8 /app/vendor/vimeo/psalm/src/Psalm/Internal/PhpVisitor/Reflector/TypeHintResolver.php(112): Psalm\Type::intersectUnionTypes(Object(Psalm\Type\Union), Object(Psalm\Type\Union), Object(Psalm\Codebase))
#9 /app/vendor/vimeo/psalm/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php(405): Psalm\Internal\PhpVisitor\Reflector\TypeHintResolver::resolve(Object(PhpParser\Node\IntersectionType), Object(Psalm\CodeLocation), Object(Psalm\Codebase), Object(Psalm\Storage\FileStorage), Object(Psalm\Storage\ClassLikeStorage), Object(Psalm\Aliases), 80210)
#10 /app/vendor/vimeo/psalm/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php(207): Psalm\Internal\PhpVisitor\Reflector\FunctionLikeNodeScanner->start(Object(PhpParser\Node\Stmt\ClassMethod))
#11 /app/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(200): Psalm\Internal\PhpVisitor\ReflectorVisitor->enterNode(Object(PhpParser\Node\Stmt\ClassMethod))
#12 /app/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(114): PhpParser\NodeTraverser->traverseArray(Array)
#13 /app/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(223): PhpParser\NodeTraverser->traverseNode(Object(PhpParser\Node\Stmt\Interface_))
#14 /app/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(114): PhpParser\NodeTraverser->traverseArray(Array)
#15 /app/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(223): PhpParser\NodeTraverser->traverseNode(Object(PhpParser\Node\Stmt\Namespace_))
#16 /app/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(91): PhpParser\NodeTraverser->traverseArray(Array)
#17 /app/vendor/vimeo/psalm/src/Psalm/Internal/Scanner/FileScanner.php(79): PhpParser\NodeTraverser->traverse(Array)
#18 /app/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(554): Psalm\Internal\Scanner\FileScanner->scan(Object(Psalm\Codebase), Object(Psalm\Storage\FileStorage), false, Object(Psalm\Progress\DefaultProgress))
#19 /app/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(782): Psalm\Internal\Codebase\Scanner->scanFile('...', Array, false)
#20 /app/vendor/vimeo/psalm/src/Psalm/Internal/Fork/Pool.php(191): Psalm\Internal\Codebase\Scanner->scanAPath(4, '...')
#21 /app/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(332): Psalm\Internal\Fork\Pool->__construct(Object(Psalm\Config), Array, Object(Closure), Object(Closure), Object(Closure))
#22 /app/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(280): Psalm\Internal\Codebase\Scanner->scanFilePaths(3.0)
#23 /app/vendor/vimeo/psalm/src/Psalm/Codebase.php(505): Psalm\Internal\Codebase\Scanner->scanFiles(Object(Psalm\Internal\Codebase\ClassLikes), 3)
#24 /app/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php(510): Psalm\Codebase->scanFiles(3)
#25 /app/vendor/vimeo/psalm/src/Psalm/Internal/Cli/Psalm.php(374): Psalm\Internal\Analyzer\ProjectAnalyzer->check('...', true)
#26 /app/vendor/vimeo/psalm/psalm(9): Psalm\Internal\Cli\Psalm::run(Array)
#27 /app/vendor/bin/psalm(119): include('...')
#28 {main}

  at vendor/vimeo/psalm/src/Psalm/Internal/Fork/Pool.php:379
    375▕                                  * @psalm-suppress MixedArgument
    376▕                                  */
    377▕                                 posix_kill($child_pid, SIGTERM);
    378▕                             }
  ➜ 379▕                             throw new Exception($message->message);
    380▕                         } else {
    381▕                             error_log('Child should return ForkMessage - response type=' . gettype($message));
    382▕                             $this->did_have_error = true;
    383▕                         }


@weirdan
Copy link
Collaborator

weirdan commented Feb 15, 2024

@zerkms I was unable to reproduce the issue in this repo: https://github.com/weirdan/10706
Am I missing something?

@weirdan
Copy link
Collaborator

weirdan commented Feb 16, 2024

I also went through https://github.com/search?q=psalm+5.22.0+is%3Aopen+status%3Afailure+&type=pullrequests and couldn't find any public repo experiencing this issue.

@zerkms
Copy link
Contributor Author

zerkms commented Feb 16, 2024

@weirdan (and all) sorry I didn't provide the actual repro repository in the beginning. It's Friday afternoon here, and I'm quite busy doing something else. I promise to provide a repository on Monday, Feb 19th, when I'm back to my development tasks. Sorry again :-)

@tm1000
Copy link
Contributor

tm1000 commented Feb 16, 2024

Just shooting in the dark here but looking at the classes that are failing (and my private one) could this be a case of intersection types that are interfaces being tested by psalm as classes?

My theory is that in the code somewhere all the classes that are failing are referenced as an intersect somewhere else

Ref: https://php.watch/versions/8.1/intersection-types

@discordier
Copy link
Contributor

Just shooting in the dark here but looking at the classes that are failing (and my private one) could this be a case of intersection types that are interfaces being tested by psalm as classes?

My theory is that in the code somewhere all the classes that are failing are referenced as an intersect somewhere else

Ref: https://php.watch/versions/8.1/intersection-types

I can second on that, I'm getting the issue for a doctrine entity property annotated as:

use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Selectable;
use Doctrine\ORM\Mapping as ORM;

class Product
{
    /** @var Selectable<int, ProductPrice>&Collection<int, ProductPrice> */
    #[ORM\OneToMany(
        targetEntity: ProductPrice::class,
        mappedBy: 'product',
        cascade: ['persist', 'remove'],
        fetch: 'EAGER',
        orphanRemoval: true,
    )]
    private Selectable&Collection $prices;
}

Tried to reproduce on psalm.dev somehow but failed so far.

@tm1000
Copy link
Contributor

tm1000 commented Feb 16, 2024

Psalm.dev isn't threaded which is also part of the issue.

@tm1000
Copy link
Contributor

tm1000 commented Feb 16, 2024

If you look at an another issue (which I think is actually a dup of this issue). You'll see something interesting (#10708 (comment)) in the stack that was obtained through dbgp

myproject/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/ClassLikes.php:726: Psalm\Internal\Codebase\ClassLikes->getParentInterfaces
myproject/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/ClassLikes.php:716: Psalm\Internal\Codebase\ClassLikes->interfaceExtends
myproject/vendor/vimeo/psalm/src/Psalm/Codebase.php:763: Psalm\Codebase->interfaceExtends
myproject/vendor/vimeo/psalm/src/Psalm/Internal/Type/Comparator/ObjectComparator.php:357: Psalm\Internal\Type\Comparator\ObjectComparator::isIntersectionShallowlyContainedBy
myproject/vendor/vimeo/psalm/src/Psalm/Internal/Type/Comparator/ObjectComparator.php:117: Psalm\Internal\Type\Comparator\ObjectComparator::isShallowlyContainedBy
myproject/vendor/vimeo/psalm/src/Psalm/Internal/Type/Comparator/AtomicTypeComparator.php:350: Psalm\Internal\Type\Comparator\AtomicTypeComparator::isContainedBy

Look at line 4 of this. ObjectComparator::isIntersectionShallowlyContainedBy

🤔

@weirdan
Copy link
Collaborator

weirdan commented Feb 17, 2024

It may be essentially the same issue, but the one @zerkms is having would be easier to reproduce and debug. The backtrace shows the exception was emitted during autoload registration, which is done before forking.

@weirdan
Copy link
Collaborator

weirdan commented Feb 17, 2024

While on the topic of PSL, I noticed that I sometimes (like 1 in 100 runs) get the following fatal error:

PHP Fatal error:  Declaration of

Psl\Range\FromRange::withUpperBound(int $upper_bound, bool $upper_inclusive): Psl\Range\BetweenRange

must be compatible with

Psl\Range\LowerBoundRangeInterface::withUpperBound(int $upper_bound, bool $upper_inclusive): Psl\Range\UpperBoundRangeInterface&Psl\Range\LowerBoundRangeInterface

in /home/weirdan/src/psalm/issues/10706/vendor/azjezz/psl/src/Psl/Range/FromRange.php on line 72

@zerkms
Copy link
Contributor Author

zerkms commented Feb 18, 2024

Here is a repro repository: https://github.com/zerkms/psalm-10706-repro

@weirdan
Copy link
Collaborator

weirdan commented Feb 18, 2024

Thanks, reproduced.

weirdan added a commit that referenced this issue Feb 19, 2024
This may resolve #10706, although I'm not exactly convinced it's the
best way.
@weirdan
Copy link
Collaborator

weirdan commented Feb 19, 2024

@zerkms would you mind trying with dev-10706-catch-intersection-exceptions-during-scanning (composer require --dev vimeo/psalm:dev-10706-catch-intersection-exceptions-during-scanning) with your actual project? It does fix the crash, but I'm particularly interested if it starts reporting some false positives / negatives compared to 5.21.1

@zerkms
Copy link
Contributor Author

zerkms commented Feb 19, 2024

@weirdan that branch now runs fine: it does not crash and there are no unexpected warnings reported.

@weirdan
Copy link
Collaborator

weirdan commented Feb 19, 2024

@tm1000 @discordier @simonberger can you confirm as well?

@gndk
Copy link
Contributor

gndk commented Feb 19, 2024

I can confirm as well. No crash and no new errors. Coming from 5.21.1

My crash was:

Uncaught Exception: InvalidArgumentException Could not get class storage for symfony\component\serializer\serializerinterface
Emitted in /srv/share/vendor/vimeo/psalm/src/Psalm/Internal/Provider/ClassLikeStorageProvider.php:45

@simonberger
Copy link

For me it is still crashing but it seem to fix one problem.
As pointing out above I had the problem already since at least 5.21.1. With your branch I see multiple catches on that introduced point and then a fallback to the reported monolog\logger class from 5.21.1 instead of mockery.

Here is the stack trace in case this shows anything new.

Uncaught Exception: InvalidArgumentException Could not get class storage for monolog\logger
Emitted in /var/www/project/vendor/vimeo/psalm/src/Psalm/Internal/Provider/ClassLikeStorageProvider.php:45
Stack trace in the forked worker:
#0 /var/www/project/vendor/vimeo/psalm/src/Psalm/Internal/Type/TypeExpander.php(292): Psalm\Internal\Provider\ClassLikeStorageProvider->get()
#1 /var/www/project/vendor/vimeo/psalm/src/Psalm/Internal/Type/TypeParser.php(1697): Psalm\Internal\Type\TypeExpander::expandAtomic()
#2 /var/www/project/vendor/vimeo/psalm/src/Psalm/Internal/Type/TypeParser.php(661): Psalm\Internal\Type\TypeParser::resolveTypeAliases()
#3 /var/www/project/vendor/vimeo/psalm/src/Psalm/Internal/Type/TypeParser.php(188): Psalm\Internal\Type\TypeParser::getTypeFromGenericTree()
#4 /var/www/project/vendor/vimeo/psalm/src/Psalm/Internal/Type/TypeParser.php(158): Psalm\Internal\Type\TypeParser::getTypeFromTree()
#5 /var/www/project/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/CommentAnalyzer.php(163): Psalm\Internal\Type\TypeParser::parseTokens()
#6 /var/www/project/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/CommentAnalyzer.php(63): Psalm\Internal\Analyzer\CommentAnalyzer::arrayToDocblocks()
#7 /var/www/project/vendor/vimeo/psalm/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php(1580): Psalm\Internal\Analyzer\CommentAnalyzer::getTypeFromComment()
#8 /var/www/project/vendor/vimeo/psalm/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php(778): Psalm\Internal\PhpVisitor\Reflector\ClassLikeNodeScanner->visitPropertyDeclaration()
#9 /var/www/project/vendor/vimeo/psalm/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php(155): Psalm\Internal\PhpVisitor\Reflector\ClassLikeNodeScanner->start()
#10 /var/www/project/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(200): Psalm\Internal\PhpVisitor\ReflectorVisitor->enterNode()
#11 /var/www/project/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(114): PhpParser\NodeTraverser->traverseArray()
#12 /var/www/project/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(223): PhpParser\NodeTraverser->traverseNode()
#13 /var/www/project/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(91): PhpParser\NodeTraverser->traverseArray()
#14 /var/www/project/vendor/vimeo/psalm/src/Psalm/Internal/Scanner/FileScanner.php(79): PhpParser\NodeTraverser->traverse()
#15 /var/www/project/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(554): Psalm\Internal\Scanner\FileScanner->scan()
#16 /var/www/project/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(782): Psalm\Internal\Codebase\Scanner->scanFile()
#17 /var/www/project/vendor/vimeo/psalm/src/Psalm/Internal/Fork/Pool.php(191): Psalm\Internal\Codebase\Scanner->scanAPath()
#18 /var/www/project/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(332): Psalm\Internal\Fork\Pool->__construct()
#19 /var/www/project/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(280): Psalm\Internal\Codebase\Scanner->scanFilePaths()
#20 /var/www/project/vendor/vimeo/psalm/src/Psalm/Codebase.php(505): Psalm\Internal\Codebase\Scanner->scanFiles()
#21 /var/www/project/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php(510): Psalm\Codebase->scanFiles()
#22 /var/www/project/vendor/vimeo/psalm/src/Psalm/Internal/Cli/Psalm.php(374): Psalm\Internal\Analyzer\ProjectAnalyzer->check()
#23 /var/www/project/vendor/vimeo/psalm/psalm(9): Psalm\Internal\Cli\Psalm::run()
#24 {main} in /var/www/project/vendor/vimeo/psalm/src/Psalm/Internal/Fork/Pool.php:379

@tm1000
Copy link
Contributor

tm1000 commented Feb 19, 2024

@simonberger your error seems to be the only one that's not an interface

@boesing
Copy link
Contributor

boesing commented Feb 19, 2024

I do have the exact same error reported on slack for earlier versions on symfony slack some weeks ago:
https://symfony-devs.slack.com/archives/C8SFXTD2M/p1706719535381899

I can confirm that I do have the exact same issue as @simonberger and the only working psalm version (for me) is 5.18, everything higher than that leads to crashes.

I was trying to extract a reproduction from our codebase into a dedicated repository but I haven't managed to reproduce the issue.

I still think that this it might be related to the way how psalm is scanning files in a specific order.
i.e. if a file consuming a class which is not yet scanned by psalm, the error occurs.
Not 100% sure how psalm determines the order of files being scanned.

weirdan added a commit that referenced this issue Feb 22, 2024
This may resolve #10706, although I'm not exactly convinced it's the
best way.
@boesing
Copy link
Contributor

boesing commented Feb 22, 2024

@weirdan I tested the recent patch release. Sadly, it does not solve the problem regarding monolog reported in #10706 (comment) and #10706 (comment)

@weirdan
Copy link
Collaborator

weirdan commented Feb 23, 2024

@boesing the issue looks remotely similar but not the same (i.e. not about intersections it appears). I extracted it in #10739.

@discordier
Copy link
Contributor

@weirdan Sorry for the late reply, works for me now.

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.

7 participants