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 for forwardcompatauthenticatortrait #7863

Closed
yuriimatsak opened this issue Apr 12, 2022 · 4 comments · Fixed by #8817
Closed

Could not get class storage for forwardcompatauthenticatortrait #7863

yuriimatsak opened this issue Apr 12, 2022 · 4 comments · Fixed by #8817
Assignees

Comments

@yuriimatsak
Copy link

Getting an error when trying to analize
It does not matter if i ran with flag --no-cache or without

Uncaught Exception: InvalidArgumentException Could not get class storage for lexik\bundle\jwtauthenticationbundle\security\authenticator\forwardcompatauthenticatortrait
Emitted in /code/vendor/vimeo/psalm/src/Psalm/Internal/Provider/ClassLikeStorageProvider.php:46

Could be reproduced here
https://psalm.dev/r/10017f26ce

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/10017f26ce
<?php

namespace Lexik\Bundle\JWTAuthenticationBundle\Security\Authenticator;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface;

$r = new \ReflectionMethod(AuthenticatorInterface::class, 'authenticate');

if ($r->hasReturnType() && Passport::class === $r->getReturnType()->getName()) {
    eval('
        namespace Lexik\Bundle\JWTAuthenticationBundle\Security\Authenticator;
        
        use Symfony\Component\HttpFoundation\Request;
        use Symfony\Component\Security\Http\Authenticator\Passport\Passport;

        /**
         * @internal
         */
        trait ForwardCompatAuthenticatorTrait
        {
            public function authenticate(Request $request): Passport
            {
                return $this->doAuthenticate($request);
            }
        }
    ');
} else {
    /**
     * @internal
     */
    trait ForwardCompatAuthenticatorTrait
    {
        public function authenticate(Request $request): PassportInterface
        {
            return $this->doAuthenticate($request);
        }
    }
}
Psalm encountered an internal error:

/vendor/vimeo/psalm/src/Psalm/Internal/Provider/ClassLikeStorageProvider.php: Could not get class storage for forwardcompatauthenticatortrait

@kkmuffme
Copy link
Contributor

kkmuffme commented Jun 4, 2022

Same for me. I ran with --no-cache and --threads=1 too, to ensure it's not one of those causing it.

Full trace:

Uncaught InvalidArgumentException: Could not get class storage for cacheable_request_trait in /opt/composer/vendor/vimeo/psalm/src/Psalm/Internal/Provider/ClassLikeStorageProvider.php:46
Stack trace:
#0 /opt/composer/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/TraitAnalyzer.php(66): Psalm\Internal\Provider\ClassLikeStorageProvider->get('Cacheable_Reque...')
#1 /opt/composer/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php(597): Psalm\Internal\Analyzer\TraitAnalyzer::analyze(Object(Psalm\Internal\Analyzer\StatementsAnalyzer), Object(PhpParser\Node\Stmt\Trait_), Object(Psalm\Context))
#2 /opt/composer/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php(206): Psalm\Internal\Analyzer\StatementsAnalyzer::analyzeStatement(Object(Psalm\Internal\Analyzer\StatementsAnalyzer), Object(PhpParser\Node\Stmt\Trait_), Object(Psalm\Context), NULL)
#3 /opt/composer/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/IfAnalyzer.php(68): Psalm\Internal\Analyzer\StatementsAnalyzer->analyze(Array, Object(Psalm\Context))
#4 /opt/composer/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/Block/IfElseAnalyzer.php(365): Psalm\Internal\Analyzer\Statements\Block\IfElse\IfAnalyzer::analyze(Object(Psalm\Internal\Analyzer\StatementsAnalyzer), Object(PhpParser\Node\Stmt\If_), Object(Psalm\Internal\Scope\IfScope), Object(Psalm\Internal\Scope\IfConditionalScope), Object(Psalm\Context), Object(Psalm\Context), Object(Psalm\Context), Array)
#5 /opt/composer/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php(517): Psalm\Internal\Analyzer\Statements\Block\IfElseAnalyzer::analyze(Object(Psalm\Internal\Analyzer\StatementsAnalyzer), Object(PhpParser\Node\Stmt\If_), Object(Psalm\Context))
#6 /opt/composer/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php(206): Psalm\Internal\Analyzer\StatementsAnalyzer::analyzeStatement(Object(Psalm\Internal\Analyzer\StatementsAnalyzer), Object(PhpParser\Node\Stmt\If_), Object(Psalm\Context), NULL)
#7 /opt/composer/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/NamespaceAnalyzer.php(92): Psalm\Internal\Analyzer\StatementsAnalyzer->analyze(Array, Object(Psalm\Context), NULL, true)
#8 /opt/composer/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/FileAnalyzer.php(316): Psalm\Internal\Analyzer\NamespaceAnalyzer->collectAnalyzableInformation()
#9 /opt/composer/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/FileAnalyzer.php(193): Psalm\Internal\Analyzer\FileAnalyzer->populateCheckers(Array)
#10 /opt/composer/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Analyzer.php(362): Psalm\Internal\Analyzer\FileAnalyzer->analyze()
#11 /opt/composer/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Analyzer.php(619): Psalm\Internal\Codebase\Analyzer->Psalm\Internal\Codebase\{closure}(3892, '/var/www/vhosts...')
#12 /opt/composer/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Analyzer.php(291): Psalm\Internal\Codebase\Analyzer->doAnalysis(Object(Psalm\Internal\Analyzer\ProjectAnalyzer), 1)
#13 /opt/composer/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php(1203): Psalm\Internal\Codebase\Analyzer->analyzeFiles(Object(Psalm\Internal\Analyzer\ProjectAnalyzer), 1, false, false)
#14 /opt/composer/vendor/vimeo/psalm/src/Psalm/Internal/Cli/Psalm.php(375): Psalm\Internal\Analyzer\ProjectAnalyzer->checkPaths(Array)
#15 /opt/composer/vendor/vimeo/psalm/psalm(6): Psalm\Internal\Cli\Psalm::run(Array)
#16 /opt/composer/vendor/bin/psalm(112): include('/opt/composer/v...')
#17 {main}

@weirdan
Copy link
Collaborator

weirdan commented Dec 3, 2022

Simplified: https://psalm.dev/r/d0f331ef60

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/d0f331ef60
<?php

namespace NS;

if (rand(0,1)) {
    trait ForwardCompatAuthenticatorTrait {}
}
Psalm encountered an internal error:

/vendor/vimeo/psalm/src/Psalm/Internal/Provider/ClassLikeStorageProvider.php: Could not get class storage for forwardcompatauthenticatortrait

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.

4 participants