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

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

Comments

@Chekote
Copy link

Chekote commented Mar 16, 2021

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
@psalm-github-bot
Copy link

Hey @Chekote, can you reproduce the issue on https://psalm.dev ?

@Chekote
Copy link
Author

Chekote commented Mar 16, 2021

@psalm-github-bot I would not even know where to begin.

@muglug muglug closed this as completed in 817d1cf Mar 16, 2021
@Chekote
Copy link
Author

Chekote commented Mar 16, 2021

@muglug can you please at least let me know why you closed this with no comment? o.O

@Chekote
Copy link
Author

Chekote commented Mar 16, 2021

Did I do something wrong? I read your Contributing to Psalm document before I opened the issue to see if there were any requirements for issue structure, etc.

I read the linked document Contributing to Open Source on Github and followed the guidelines by searching for an existing issue before posting this.

I don't understand what I did to be disregarded without any feedback...

@orklah
Copy link
Collaborator

orklah commented Mar 16, 2021

@Chekote He closed it with a linked commit. This generally means the issue was fixed in this commit.

You should be able to confirm this by running psalm in dev-master for your project

@Chekote
Copy link
Author

Chekote commented Mar 16, 2021

@orklah thanks for the clarification. I didn't notice that it was closed in a linked commit (I'm not used to seeing that as our org never closes issues with linked PRs or Commits), sorry for the oversight 🤦 . I will try that, thank you.

@Chekote
Copy link
Author

Chekote commented Mar 16, 2021

Yes, it seems that 817d1cf did fix the problem. Thanks so much for the incredibly fast fix, I really appreciate it ❤️

This was referenced Mar 17, 2021
kodiakhq bot added a commit to WesleyKlop/vote-system that referenced this issue Mar 17, 2021
Bumps [vimeo/psalm](https://github.com/vimeo/psalm) from 4.6.3 to 4.6.4.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/vimeo/psalm/releases">vimeo/psalm's releases</a>.</em></p>
<blockquote>
<h2>Fix small API regression</h2>
<p><code>IssueBuffer::finish</code> had a small undocumented API change – that change is reverted here (<a href="https://github.com/vimeo/psalm/issues/5410">#5410</a>).</p>
<p>Bugfixes:</p>
<ul>
<li><a href="https://github.com/orklah"><code>@​orklah</code></a> improved the return type of <code>array_combine</code> and <code>iterator_to_array</code> (<a href="https://github.com/vimeo/psalm/issues/5393">#5393</a>, <a href="https://github.com/vimeo/psalm/issues/5400">#5400</a>)</li>
<li>Promoted properties are no longer counted as unused params — thanks <a href="https://github.com/weirdan"><code>@​weirdan</code></a> (<a href="https://github.com/vimeo/psalm/issues/5404">#5404</a>)</li>
<li><a href="https://github.com/theodorejb"><code>@​theodorejb</code></a> improved the type of DOMElement::childNodes (<a href="https://github.com/vimeo/psalm/issues/5403">#5403</a>)</li>
<li>Property invariance checks are now disabled for properties with templates — thanks <a href="https://github.com/AndrolGenhald"><code>@​AndrolGenhald</code></a> (<a href="https://github.com/vimeo/psalm/issues/5380">#5380</a>)</li>
<li><a href="https://github.com/orklah"><code>@​orklah</code></a> fixed scalar-to-string reconciliation inside templates (<a href="https://github.com/vimeo/psalm/issues/5402">#5402</a>)</li>
<li>Fixed a regression asserting on templated arrays and generic objects (<a href="https://github.com/vimeo/psalm/issues/5406">#5406</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/vimeo/psalm/commit/97fe86c4e158b5a57c5150aa5055c38b5a809aab"><code>97fe86c</code></a> Fix BC break introduced in 4.6.3 (<a href="https://github.com/vimeo/psalm/issues/5410">#5410</a>)</li>
<li><a href="https://github.com/vimeo/psalm/commit/9d979e3467b623a69b69a5427884f519e61f7d73"><code>9d979e3</code></a> Fix <a href="https://github.com/vimeo/psalm/issues/5406">#5406</a> - track more changes to assertion type</li>
<li><a href="https://github.com/vimeo/psalm/commit/2777b62d0bc38ae439aedea338c5a6dd23cb7db5"><code>2777b62</code></a> String can be reconciled with Scalar (<a href="https://github.com/vimeo/psalm/issues/5402">#5402</a>)</li>
<li><a href="https://github.com/vimeo/psalm/commit/11490508173c8e6be7f46724a70ca429caf96201"><code>1149050</code></a> adapt bcdiv for PHP8 in stubs (<a href="https://github.com/vimeo/psalm/issues/5401">#5401</a>)</li>
<li><a href="https://github.com/vimeo/psalm/commit/ff5a6cb2974995d73ba2443fc6dc0b7b95ef7906"><code>ff5a6cb</code></a> iterator_to_array must always return array-key (<a href="https://github.com/vimeo/psalm/issues/5400">#5400</a>)</li>
<li><a href="https://github.com/vimeo/psalm/commit/1a3ff5676aee987c35eebac1119ff306ac05f67f"><code>1a3ff56</code></a> fix stub for array_combine + remove false in PHP8 + improve tests (<a href="https://github.com/vimeo/psalm/issues/5395">#5395</a>)</li>
<li><a href="https://github.com/vimeo/psalm/commit/9d840ee87bceb66b791b42f9d51f285d125fdbf2"><code>9d840ee</code></a> Disable property invariance checks for properties with templates (<a href="https://github.com/vimeo/psalm/issues/5380">#5380</a>)</li>
<li><a href="https://github.com/vimeo/psalm/commit/5b9efd579de000a98af42eec52e2dcb7d3573cd3"><code>5b9efd5</code></a> Fix type of DomElement childNodes property (<a href="https://github.com/vimeo/psalm/issues/5403">#5403</a>)</li>
<li><a href="https://github.com/vimeo/psalm/commit/ae247d09a3de23ea015c7a2b4bebac1388954953"><code>ae247d0</code></a> Don't mark promoted properties as unused params (<a href="https://github.com/vimeo/psalm/issues/5404">#5404</a>)</li>
<li><a href="https://github.com/vimeo/psalm/commit/817d1cf3fe9f3e3141bcb7f0a5734d2714ecdf78"><code>817d1cf</code></a> Fix <a href="https://github.com/vimeo/psalm/issues/5408">#5408</a> - avoid nullref when parser param cannot be found</li>
<li>Additional commits viewable in <a href="https://github.com/vimeo/psalm/compare/4.6.3...4.6.4">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=vimeo/psalm&package-manager=composer&previous-version=4.6.3&new-version=4.6.4)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>
This was referenced Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment