Skip to content

Undefined offset: 0 in FunctionLikeAnalyzer.php:1037 #5408

@Chekote

Description

@Chekote

Apologies if this was already reported. I dug through the existing issues but didn't have any luck finding anything.

I'm using Psalm 4.6.3 on a Laravel 5.8 project.
I'm not using any plugins.
When I run psalm, I get the following error:

Scanning files...
Analyzing files...

Uncaught Exception: PHP Error: Undefined offset: 0 in /var/www/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php:1037
Stack trace in the forked worker:
#0 /var/www/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php(1037): Psalm\Internal\ErrorHandler::Psalm\Internal\{closure}()
#1 /var/www/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php(317): Psalm\Internal\Analyzer\FunctionLikeAnalyzer->processParams()
#2 /var/www/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ClassAnalyzer.php(1703): Psalm\Internal\Analyzer\FunctionLikeAnalyzer->analyze()
#3 /var/www/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ClassAnalyzer.php(398): Psalm\Internal\Analyzer\ClassAnalyzer->analyzeClassMethod()
#4 /var/www/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/FileAnalyzer.php(213): Psalm\Internal\Analyzer\ClassAnalyzer->analyze()
#5 /var/www/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Analyzer.php(341): Psalm\Internal\Analyzer\FileAnalyzer->analyze()
#6 /var/www/vendor/vimeo/psalm/src/Psalm/Internal/Fork/Pool.php(193): Psalm\Internal\Codebase\Analyzer->Psalm\Internal\Codebase\{closure}()
#7 /var/www/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Analyzer.php(407): Psalm\Internal\Fork\Pool->__construct()
#8 /var/www/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Analyzer.php(270): Psalm\Internal\Codebase\Analyzer->doAnalysis()
#9 /var/www/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php(636): Psalm\Internal\Codebase\Analyzer->analyzeFiles()
#10 /var/www/vendor/vimeo/psalm/src/psalm.php(701): Psalm\Internal\Analyzer\ProjectAnalyzer->check()
#11 /var/www/vendor/vimeo/psalm/src/psalm.php(886): Psalm\{closure}()
#12 /var/www/vendor/vimeo/psalm/psalm(2): require_once('/var/www/vendor...')
#13 {main} in /var/www/vendor/vimeo/psalm/src/Psalm/Internal/Fork/Pool.php:357
Stack trace:
#0 /var/www/vendor/vimeo/psalm/src/Psalm/Internal/Fork/Pool.php(389): Psalm\Internal\Fork\Pool->readResultsFromChildren()
#1 /var/www/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Analyzer.php(474): Psalm\Internal\Fork\Pool->wait()
#2 /var/www/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Analyzer.php(270): Psalm\Internal\Codebase\Analyzer->doAnalysis()
#3 /var/www/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php(636): Psalm\Internal\Codebase\Analyzer->analyzeFiles()
#4 /var/www/vendor/vimeo/psalm/src/psalm.php(701): Psalm\Internal\Analyzer\ProjectAnalyzer->check()
#5 /var/www/vendor/vimeo/psalm/src/psalm.php(886): Psalm\{closure}()
#6 /var/www/vendor/vimeo/psalm/psalm(2): require_once('/var/www/vendor...')
#7 {main}
(Psalm 4.6.3@f1a840727dd756899eee2f1f9ea443e265a4763f crashed due to an uncaught Throwable)

It seems to be some kind of internal error. It doesn't reference anything about what part of my code it is trying to analyze at the time, so I have no idea where to look to see how to recreate the problem.

I modified the line where the error is originating to get some more info:

            $fnParams = $this->function->getParams();
            if (!isset($fnParams[$offset])) {
                throw new \Exception("Param $offset does not exist for function " . $this->getParentFQCLN() . ':' . $this->function->name);
            }
            $parser_param = $fnParams[$offset];

And this is what I got:

Uncaught Exception: Param 0 does not exist for function Illuminate\Database\Seeder:run

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions