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
psalm --version
Psalm 3.6.4@3e98c800ec72e06eed7546956823ff395fc30c75
Mind running with --debug-by-line to identify the code that causes the failure?
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:
psalm with --threads=n where n > 1This 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.
Oh thanks!
@pilif I鈥檓 going to try to reproduce based on this information (but if you can create a small repro repo that would be amazing). At the very least Psalm shouldn鈥檛 crash.
I had a lot of trouble reproducing it because it's sheer luck which process sees one class and which sees the usage of the other.
So for various values of n and depending on the machine I was trying on, it would be fine or blow up.
Of the classes in question, both were named Importer, both were abstract, both were subclassed and subclasses of both were checked by psalm.
One of them had a public function startFile($file){} method, the other didn't.
The fix was to exclude the directory containing one of the classes and subclasses.
Also hitting this. Seems like the same problem of different classes with the same name. Would rather not exclude either of the directories. Can psalm disambiguate the files somehow?
3.9 crashes by default for us because of this.
Seem to be able to get around it by setting threads=1 (--init seems to need --debug).
If anyone can create a repo that reproduces the bug, I'll be able to fix it quickly cc @nickyr
Yeah it鈥檚 really a struggle to reproduce in a separate repo. And trimming down the problem repo is unwieldy because it鈥檚 so big that psalm init eats up all my computer鈥檚 application memory If it doesn鈥檛 crash first...that鈥檚 gonna be an issue.
I鈥檝e seen it fail on two different classes, each of which shares its name with at least one other class. In one case, all the classes with the same name extend the same parent. But in another case, one of the classes has no parents or children.
But making a repo with classes with the same name doesn鈥檛 reproduce the issue for me, it just fails with a DuplicateClass error. I wonder if a certain volume of classes is needed for the race condition to have a chance of happening.
Ahhh - Psalm probably isn鈥檛 forking its analysis because the number of files is too low - you can override that in Psalm\Internal\Fork\Pool
Also Nico says hi
Ok I got it to fork, had to edit a couple other places. Still no repro though. I may need to think about this whole memory limit issue first anyway...
And hi Nico!
Can now reproduce this on our codebase with --threads=1 too
@leighman can you create a reproducer in a new repo?
Can have another go. I have tried in the past and not been able to. I think it has to do with the number of (non-namespaced) files.
Right, but if you can reproduce on a single thread it implies an order-of-operations issue that should be reproducible. Another alternative would be to give me temporary access to the repo, but I could understand how that might be complicated.
I am also getting this, if I run it normally, I get an error about storage and undefined index
If i run with --debug-by-line it never finishes
Stack trace below:
vendor/bin/psalm 16:05:09
Scanning files...
Analyzing files...
zack@hephaestus html (composer)> vendor/bin/psalm 16:05:09
Scanning files...
Analyzing files...
EEE鈻慐E鈻慐EE鈻慐EEEEEEEEE鈻慐EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE 60 / 543 (11%)
鈻慐EEEEE鈻慐EEEEEEEEEE鈻慐鈻慐鈻慐E鈻慞HP Notice: Undefined offset: 0 in <redacted>/html/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php on line 1119
Notice: Undefined offset: 0 in <redacted>/html/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php on line 1119
PHP Notice: Trying to get property 'default' of non-object in <redacted>/html/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php on line 1122
Notice: Trying to get property 'default' of non-object in <redacted>/html/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php on line 1122
EUncaught Exception: $storage should not be null for Namespace\Classname::getid
Stack trace in the forked worker:
#0 <redacted>/html/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ClassAnalyzer.php(1933): Psalm\Internal\Codebase\Methods->getStorage()
#1 <redacted>/html/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ClassAnalyzer.php(1904): Psalm\Internal\Analyzer\ClassAnalyzer::analyzeClassMethodReturnType()
#2 <redacted>/html/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ClassAnalyzer.php(739): Psalm\Internal\Analyzer\ClassAnalyzer->analyzeClassMethod()
#3 <redacted>/html/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/FileAnalyzer.php(217): Psalm\Internal\Analyzer\ClassAnalyzer->analyze()
#4 <redacted>/html/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Analyzer.php(349): Psalm\Internal\Analyzer\FileAnalyzer->analyze()
#5 <redacted>/html/vendor/vimeo/psalm/src/Psalm/Internal/Fork/Pool.php(184): Psalm\Internal\Codebase\Analyzer->Psalm\Internal\Codebase\{closure}()
#6 <redacted>/html/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Analyzer.php(415): Psalm\Internal\Fork\Pool->__construct()
#7 <redacted>/html/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Analyzer.php(275): Psalm\Internal\Codebase\Analyzer->doAnalysis()
#8 <redacted>/html/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php(630): Psalm\Internal\Codebase\Analyzer->analyzeFiles()
#9 <redacted>/html/vendor/vimeo/psalm/src/psalm.php(666): Psalm\Internal\Analyzer\ProjectAnalyzer->check()
#10 <redacted>/html/vendor/vimeo/psalm/psalm(2): require_once('/home/zack/Envi...')
#11 {main} in <redacted>/html/vendor/vimeo/psalm/src/Psalm/Internal/Fork/Pool.php:348
Stack trace:
#0 <redacted>/html/vendor/vimeo/psalm/src/Psalm/Internal/Fork/Pool.php(380): Psalm\Internal\Fork\Pool->readResultsFromChildren()
#1 <redacted>/html/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Analyzer.php(481): Psalm\Internal\Fork\Pool->wait()
#2 <redacted>/html/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Analyzer.php(275): Psalm\Internal\Codebase\Analyzer->doAnalysis()
#3 <redacted>/html/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php(630): Psalm\Internal\Codebase\Analyzer->analyzeFiles()
#4 <redacted>/html/vendor/vimeo/psalm/src/psalm.php(666): Psalm\Internal\Analyzer\ProjectAnalyzer->check()
#5 <redacted>/html/vendor/vimeo/psalm/psalm(2): require_once('/home/zack/Envi...')
#6 {main}
(Psalm 3.13.1@afd8874a9e4562eac42a02de90e42e430c3a1db1 crashed due to an uncaught Throwable)
Obviously redacted the directories and the namespace and class name are changed
Any ideas?
@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
@jgwong that was a different issue, now fixed.
Closing this as not reproducable