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

[Crash] Could not get class storage for static #3801

Closed
mr-feek opened this issue Jul 10, 2020 · 8 comments
Closed

[Crash] Could not get class storage for static #3801

mr-feek opened this issue Jul 10, 2020 · 8 comments
Labels

Comments

@mr-feek
Copy link
Contributor

mr-feek commented Jul 10, 2020

composer show vimeo/psalm | grep versions
versions : * 3.12.2

 composer show nesbot/carbon | grep versions
versions : * 2.36.0
./vendor/bin/psalm
Scanning files...
Analyzing files...

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░   60 / 1112 (5%)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
In ClassLikeStorageProvider.php line 45:

  Could not get class storage for static

When I debug by line, it dies at this line

$date = (string) Carbon::today()->setTime(23, 59, 59)->subDays($offset);

Anything else I can do to help narrow it down?

@muglug
Copy link
Collaborator

muglug commented Jul 10, 2020

Are you able to reproduce the error in a separate repo? I wasn't, at least not with that specific line.

Also does the error persist if you disable the laravel plugin (and if so, what's the stack trace you get?)

@mr-feek
Copy link
Contributor Author

mr-feek commented Jul 10, 2020

I disabled the laravel plugin --

Uncaught InvalidArgumentException: Could not get class storage for static in /var/www/billing/vendor/vimeo/psalm/src/Psalm/Internal/Provider/ClassLikeStorageProvider.php:45
Stack trace:
#0 /var/www/billing/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallReturnTypeFetcher.php(151): Psalm\Internal\Provider\ClassLikeStorageProvider->get('static')
#1 /var/www/billing/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php(630): Psalm\Internal\Analyzer\Statements\Expression\Call\Method\MethodCallReturnTypeFetcher::fetch(Object(Psalm\Internal\Analyzer\StatementsAnalyzer), Object(Psalm\Codebase), Object(PhpParser\Node\Expr\MethodCall), Object(Psalm\Context), Object(Psalm\Internal\MethodIdentifier), Object(Psalm\Internal\MethodIdentifier), Object(Psalm\Internal\MethodIdentifier), 'App\\Console\\Com...', Object(Psalm\Type\Atomic\TNamedObject), Object(Psalm\Type\Atomic\TNamedObject), Array, Object(Psalm\Internal\Analyzer\Statements\Expression\Call\Method\AtomicMethodCallAnalysisResult), Object(Psalm\Internal\Type\TemplateResult))
#2 /var/www/billing/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/Expression/Call/MethodCallAnalyzer.php(173): Psalm\Internal\Analyzer\Statements\Expression\Call\Method\AtomicMethodCallAnalyzer::analyze(Object(Psalm\Internal\Analyzer\StatementsAnalyzer), Object(PhpParser\Node\Expr\MethodCall), Object(Psalm\Codebase), Object(Psalm\Context), Object(Psalm\Type\Atomic\TNamedObject), Object(Psalm\Type\Atomic\TNamedObject), false, NULL, Object(Psalm\Internal\Analyzer\Statements\Expression\Call\Method\AtomicMethodCallAnalysisResult))
#3 /var/www/billing/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php(147): Psalm\Internal\Analyzer\Statements\Expression\Call\MethodCallAnalyzer::analyze(Object(Psalm\Internal\Analyzer\StatementsAnalyzer), Object(PhpParser\Node\Expr\MethodCall), Object(Psalm\Context))
#4 /var/www/billing/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php(45): Psalm\Internal\Analyzer\Statements\ExpressionAnalyzer::handleExpression(Object(Psalm\Internal\Analyzer\StatementsAnalyzer), Object(PhpParser\Node\Expr\MethodCall), Object(Psalm\Context), false, NULL, false)
#5 /var/www/billing/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/Expression/CastAnalyzer.php(87): Psalm\Internal\Analyzer\Statements\ExpressionAnalyzer::analyze(Object(Psalm\Internal\Analyzer\StatementsAnalyzer), Object(PhpParser\Node\Expr\MethodCall), Object(Psalm\Context))
#6 /var/www/billing/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php(296): Psalm\Internal\Analyzer\Statements\Expression\CastAnalyzer::analyze(Object(Psalm\Internal\Analyzer\StatementsAnalyzer), Object(PhpParser\Node\Expr\Cast\String_), Object(Psalm\Context))
#7 /var/www/billing/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php(45): Psalm\Internal\Analyzer\Statements\ExpressionAnalyzer::handleExpression(Object(Psalm\Internal\Analyzer\StatementsAnalyzer), Object(PhpParser\Node\Expr\Cast\String_), Object(Psalm\Context), false, NULL, false)
#8 /var/www/billing/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php(246): Psalm\Internal\Analyzer\Statements\ExpressionAnalyzer::analyze(Object(Psalm\Internal\Analyzer\StatementsAnalyzer), Object(PhpParser\Node\Expr\Cast\String_), Object(Psalm\Context))
#9 /var/www/billing/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php(128): Psalm\Internal\Analyzer\Statements\Expression\AssignmentAnalyzer::analyze(Object(Psalm\Internal\Analyzer\StatementsAnalyzer), Object(PhpParser\Node\Expr\Variable), Object(PhpParser\Node\Expr\Cast\String_), NULL, Object(Psalm\Context), NULL)
#10 /var/www/billing/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php(45): Psalm\Internal\Analyzer\Statements\ExpressionAnalyzer::handleExpression(Object(Psalm\Internal\Analyzer\StatementsAnalyzer), Object(PhpParser\Node\Expr\Assign), Object(Psalm\Context), false, Object(Psalm\Context), true)
#11 /var/www/billing/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php(439): Psalm\Internal\Analyzer\Statements\ExpressionAnalyzer::analyze(Object(Psalm\Internal\Analyzer\StatementsAnalyzer), Object(PhpParser\Node\Expr\Assign), Object(Psalm\Context), false, Object(Psalm\Context), true)
#12 /var/www/billing/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php(163): Psalm\Internal\Analyzer\StatementsAnalyzer::analyzeStatement(Object(Psalm\Internal\Analyzer\StatementsAnalyzer), Object(PhpParser\Node\Stmt\Expression), Object(Psalm\Context), Object(Psalm\Context))
#13 /var/www/billing/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php(547): Psalm\Internal\Analyzer\StatementsAnalyzer->analyze(Array, Object(Psalm\Context), Object(Psalm\Context), true)
#14 /var/www/billing/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ClassAnalyzer.php(1803): Psalm\Internal\Analyzer\FunctionLikeAnalyzer->analyze(Object(Psalm\Context), Object(Psalm\Internal\Provider\NodeDataProvider), Object(Psalm\Context))
#15 /var/www/billing/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ClassAnalyzer.php(754): Psalm\Internal\Analyzer\ClassAnalyzer->analyzeClassMethod(Object(PhpParser\Node\Stmt\ClassMethod), Object(Psalm\Storage\ClassLikeStorage), Object(Psalm\Internal\Analyzer\ClassAnalyzer), Object(Psalm\Context), Object(Psalm\Context))
#16 /var/www/billing/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/FileAnalyzer.php(217): Psalm\Internal\Analyzer\ClassAnalyzer->analyze(Object(Psalm\Context), Object(Psalm\Context))
#17 /var/www/billing/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Analyzer.php(340): Psalm\Internal\Analyzer\FileAnalyzer->analyze(NULL)
#18 /var/www/billing/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Analyzer.php(576): Psalm\Internal\Codebase\Analyzer->Psalm\Internal\Codebase\{closure}(92, '/var/www/billin...')
#19 /var/www/billing/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Analyzer.php(266): Psalm\Internal\Codebase\Analyzer->doAnalysis(Object(Psalm\Internal\Analyzer\ProjectAnalyzer), 1)
#20 /var/www/billing/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php(621): Psalm\Internal\Codebase\Analyzer->analyzeFiles(Object(Psalm\Internal\Analyzer\ProjectAnalyzer), 1, false, true)
#21 /var/www/billing/vendor/vimeo/psalm/src/psalm.php(602): Psalm\Internal\Analyzer\ProjectAnalyzer->check('/var/www/billin...', false)
#22 /var/www/billing/vendor/vimeo/psalm/psalm(2): require_once('/var/www/billin...')
#23 {main}
(Psalm 3.12.2@7c7ebd068f8acaba211d4a2c707c4ba90874fa26 crashed due to an uncaught Throwable)

@mr-feek
Copy link
Contributor Author

mr-feek commented Jul 10, 2020

Another weird thing is it is passing on my CI, but not locally with the same deps 🤔 💭

@muglug
Copy link
Collaborator

muglug commented Jul 10, 2020

Another weird thing is it is passing on my CI, but not locally with the same deps

So does it occur if you just run on that single file?

@mr-feek
Copy link
Contributor Author

mr-feek commented Jul 10, 2020

Yeah, it does. Let me see if i can strip it down and push to a repo to reproduce

@weirdan weirdan added the bug label Jul 19, 2020
@mr-feek
Copy link
Contributor Author

mr-feek commented Jul 21, 2020

I'm still working on getting a minimal repro up -- I can get a file to fail in my local codebase but cannot get it to fail when i extract the file out into its own codebase. Something else in my codebase must be having a side effect, but equally confusing that my CI passes

@mr-feek
Copy link
Contributor Author

mr-feek commented Jul 22, 2020

I finally tracked this down to usePhpDocMethodsWithoutMagicCall="true" 😠 (don't ask me how long that took).

https://github.com/mr-feek/repro-carbon-psalm-issue and composer install && ./vendor/bin/psalm to reproduce.

@mr-feek
Copy link
Contributor Author

mr-feek commented Jul 22, 2020

I tried removing illuminate/console as a dependency, and I got this issue instead of a crash:

UndefinedMethod - app/Console/Commands/TestCommand.php:21:64 - Method App\Console\Commands\TestCommand::subDays does not exist (see https://psalm.dev/022)
        $date = (string) Carbon::today()->setTime(23, 59, 59)->subDays(1);

static must be getting confused..

@muglug muglug closed this as completed in abe91ad Jul 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants