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

False positive "Access to private property $field of parent class A." #3572

Closed
sunkan opened this issue Jul 6, 2020 · 9 comments
Closed
Labels
Milestone

Comments

@sunkan
Copy link

sunkan commented Jul 6, 2020

Bug report

I mostly want to know if this is the intended behavior for this warning or if this is a bug.

The reason I think it's a bug is because there is now warning or notice from php it self

Code snippet that reproduces the problem

https://phpstan.org/r/0db2cb6e-df24-4cbe-85ec-a85edc7d5c71

Expected output

No error should be reported.

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Jul 6, 2020
@ondrejmirtes
Copy link
Member

Yes, it's a bug, it works in PHP: https://3v4l.org/AnGtO

@muglug
Copy link
Contributor

muglug commented Jul 6, 2020

That looks a lot more like a bug in PHP to be honest.

@ondrejmirtes
Copy link
Member

I wouldn't be so sure, you're accessing private property from A in A.

@muglug
Copy link
Contributor

muglug commented Jul 6, 2020

Yeah, but that private property doesn't belong in B – you're essentially creating a weird mutant instance.

@phpstan-bot
Copy link
Contributor

@sunkan After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
-13: Access to private property $field of parent class A.
+-1: Internal error: PHPStan\Rules\Methods\WrongCaseOfInheritedMethodRule::findMethod(): Argument #2 ($classReflection) must be of type PHPStan\Reflection\ClassReflection, null given, called in /var/task/vendor/phpstan/phpstan-strict-rules/src/Rules/Methods/WrongCaseOfInheritedMethodRule.php on line 40
+Run PHPStan with --debug option and post the stack trace to:
+https://github.com/phpstan/phpstan/issues/new?template=Bug_report.md
Full report
Line Error
-1 Internal error: PHPStan\Rules\Methods\WrongCaseOfInheritedMethodRule::findMethod(): Argument #2 ($classReflection) must be of type PHPStan\Reflection\ClassReflection, null given, called in /var/task/vendor/phpstan/phpstan-strict-rules/src/Rules/Methods/WrongCaseOfInheritedMethodRule.php on line 40Run PHPStan with --debug option and post the stack trace to:https://github.com/phpstan/phpstan/issues/new?template=Bug_report.md

@phpstan-bot
Copy link
Contributor

@sunkan After the latest push in 1.9.x, PHPStan now reports different result with your code snippet:

@@ @@
-13: Access to private property $field of parent class A.
+No errors

@phpstan-bot
Copy link
Contributor

@sunkan After the latest push in 1.9.x, PHPStan now reports different result with your code snippet:

@@ @@
-13: Access to private property $field of parent class A.
+No errors

@phpstan-bot
Copy link
Contributor

@sunkan After the latest push in 1.9.x, PHPStan now reports different result with your code snippet:

@@ @@
-13: Access to private property $field of parent class A.
+No errors

@github-actions
Copy link

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 Dec 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants