psalm: PHP Notice: Undefined offset => PHP Fatal error: Uncaught UnexpectedValueException: $storage should not be null

PHP Notice:  Undefined offset: 2 in /Users/alek/.composer/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php on line 927

Notice: Undefined offset: 2 in /Users/alek/.composer/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php on line 927
PHP Notice:  Trying to get property 'default' of non-object in /Users/alek/.composer/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php on line 930

Notice: Trying to get property 'default' of non-object in /Users/alek/.composer/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php on line 930
PHP Fatal error:  Uncaught UnexpectedValueException: $storage should not be null for Packing::getreqaudioformats in /Users/alek/.composer/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Methods.php:921
Stack trace:
#0 /Users/alek/.composer/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/MethodAnalyzer.php(50): Psalm\Internal\Codebase\Methods->getStorage('Packing::getreq...')
#1 /Users/alek/.composer/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ClassAnalyzer.php(1534): Psalm\Internal\Analyzer\MethodAnalyzer->__construct(Object(PhpParser\Node\Stmt\ClassMethod), Object(Psalm\Internal\Analyzer\ClassAnalyzer))
#2 /Users/alek/.composer/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ClassAnalyzer.php(811): 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))
#3 /Users/alek/.composer/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/FileAnalyzer.php(197): Psalm\ in /Users/alek/.composer/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Methods.php on line 921

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 24 (8 by maintainers)

Most upvoted comments

Uncaught RuntimeException: PHP Error: Undefined property: Psalm\Config::$threads

It may happen if you also have Psalm installed via composer. Run vendor/bin/psalm instead.

Could you please open a new issue @dwasil

@muglug I’ve created a repo with which you can reproduce the issue. In my case it happens with Laminas InputFilter library.

Here’s the repo: https://github.com/jgwong/psalm-issue-2316-repro

I just ran into the same issue when setting up psalm on a veeeery old branch of ours which was, frankly, a mess.

In my case, this issue was reproducible when:

  • the same class exists multiple times in the same (in my case root) namespace (in reality this wasn’t an issue because either file would have been loaded manually)
  • you run psalm with --threads=n where n > 1

This is a race condition where one process sees the class definition and the other sees methods being called on the other class with the same name.

I don’t think this needs fixing, but I’m posting here if somebody else runs into the same issue.