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

Using trait with method renaming / visibility change triggers bogus errors for other uses of trait #6264

Closed
sad-spirit opened this issue Dec 31, 2021 · 5 comments

Comments

@sad-spirit
Copy link

sad-spirit commented Dec 31, 2021

Bug report

If a trait is used converting a method to private in one class

    use SpecificFoo {
        doFoo as private doFooImpl;
    }

bogus errrors appear in other classes where the same trait is used

Private method FooBar::doFoo() overriding public method Foo::doFoo() should also be public.

while that method is actually public there.

Code snippet that reproduces the problem

https://phpstan.org/r/78866c94-e900-4e2f-be7d-3f724f817b8d

Expected output

No errors. The problem appeared first in phpstan 1.3

sad-spirit added a commit to sad-spirit/pg-builder that referenced this issue Dec 31, 2021
Prevent upgrading to phpstan 1.3 due to phpstan/phpstan#6264
@dktapps
Copy link
Contributor

dktapps commented Dec 31, 2021

This is the exact same issue I encountered with pmmp/PocketMine-MP#4684.

Simpler example: https://phpstan.org/r/5402d664-98c7-44ac-80ef-564dfab3a12f
https://3v4l.org/418La#v8.1.1

@dktapps
Copy link
Contributor

dktapps commented Dec 31, 2021

I should also mention that this appears to corrupt the visibility for future analysed classes using the same trait, for example:
https://phpstan.org/r/2048596a-12db-4c0b-9c5f-d9dd78c1298b

The Sand1 class doesn't experience the bug, but Sand2 does.

@mvorisek
Copy link
Contributor

mvorisek commented Jan 1, 2022

Probably related with #6253 , also present since phpstan v1.3.

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src@fc5be6a

Root cause: Roave/BetterReflection#942

@github-actions
Copy link

github-actions bot commented Feb 4, 2022

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants