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

TooManyArguments false positive #10961

Open
edsrzf opened this issue May 6, 2024 · 1 comment
Open

TooManyArguments false positive #10961

edsrzf opened this issue May 6, 2024 · 1 comment

Comments

@edsrzf
Copy link
Contributor

edsrzf commented May 6, 2024

https://psalm.dev/r/297ffd1c85

This seems to be an interaction between:

  • Parent class constructor that calls a private method - making the init method protected or higher fixes the error
  • Parent class that has a magic __call method - removing the magic method fixes the error
  • Property initialization analysis for the child class - removing the child class fixes the error

A bit of debugging shows that analysis is getting into MissingMethodCallHandler, and the reason for the TooManyArguments error is that this call is erroneously being transformed into a call to __call. I'm guessing that it's trying to find the private method in the context of the child class.

Copy link

I found these snippets:

https://psalm.dev/r/297ffd1c85
<?php

class Base
{
    protected int $i;
    
    public function __construct()
    {
        $this->init(1);
    }
    
    private function init(int $value): void
    {
        $this->i = $value;
    }
    
    public function __call()
    {
    }
}

class Child extends Base
{
}
Psalm output (using commit 16b24bd):

ERROR: TooManyArguments - 9:16 - Too many arguments for method Base::init - saw 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant