Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[PropertyAccess] Fix handling of uninitialized property of anonymous class#45002
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
nicolas-grekas commentedJan 12, 2022
| Q | A |
|---|---|
| Branch? | 4.4 |
| Bug fix? | yes |
| New feature? | no |
| Deprecations? | no |
| Tickets | Fix#44983 |
| License | MIT |
| Doc PR | - |
nicolas-grekas commentedJan 12, 2022
Thank you@filiplikavcan. |
filiplikavcan commentedJan 14, 2022
This also affects 5.* and 6.* version. Will this PR be merged into those branches too? |
nicolas-grekas commentedJan 14, 2022
It is already, isn't it? |
filiplikavcan commentedJan 14, 2022
Ah, ok it is. It is not merged in 6.1 because there are conflict changes I suppose. Should I create a new PR for that or it is up to maintainers to resolve conflicts and merge it to 6.1? |
nicolas-grekas commentedJan 14, 2022
No need to, I'll handle the merge later on. |
| // handle uninitialized properties in PHP >= 7.4 | ||
| if (\PHP_VERSION_ID >=70400 &&preg_match('/^Typed property ([\w\\\]+)::\$(\w+) must not be accessed before initialization$/',$e->getMessage(),$matches)) { | ||
| $r =new \ReflectionProperty($matches[1],$matches[2]); | ||
| if (\PHP_VERSION_ID >=70400 &&preg_match('/^Typed property ('.preg_quote(get_debug_type($object),'/').')::\$(\w+) must not be accessed before initialization$/',$e->getMessage(),$matches)) { |
filiplikavcanJan 31, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This change introduced a new bug:
class X {publicint$a; }class Yextends X {}(newY)->a;
This throws:
Typed property X::$a must not be accessed before initializationbut sinceget_debug_type(new Y) returnsY the error message does not match
Typed property Y::$a must not be accessed before initialization"Here is a PR which fixes this:#45255