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

InaccessibleMethod false positive when calling method on sibling #5595

Closed
AndrolGenhald opened this issue Apr 7, 2021 · 1 comment
Closed
Labels

Comments

@AndrolGenhald
Copy link
Collaborator

https://psalm.dev/r/dfdf721e08

Since baz is originally declared on FooBar, Bar can access Foo::baz.

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/dfdf721e08
<?php

class FooBar
{
    protected function baz(FooBar $other): void {}
}

class Foo extends FooBar
{
    protected function baz(FooBar $other): void {}
}

class Bar extends FooBar
{
    protected function baz(FooBar $other): void
    {
        if ($other instanceof Foo) {
            $other->baz($this);
        }
    }
}
Psalm output (using commit a469c82):

ERROR: InaccessibleMethod - 18:21 - Cannot access protected method Foo::baz from context Bar

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

No branches or pull requests

2 participants