-
Notifications
You must be signed in to change notification settings - Fork 545
Add dynamic return type extension for get_object_vars
#2268
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
Conversation
src/Reflection/ClassReflection.php
Outdated
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.
I'm not sure if this is the correct way of doing this, i'm open to suggestions.
b377706 to
62d6760
Compare
62d6760 to
8279b9c
Compare
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.
I personally want aware how get_object vars worked on an enum: https://3v4l.org/6hV36
So, the issue now is that there may be 'extra' keys in the array, if the class is not final. (https://3v4l.org/hM8MU)
Is there any way to indicate that the array may have more keys?
Is there any way to indicate that the array may have more keys?
@BackEndTea Currently there isn't, see Psalm 5 announcment and phpstan/phpstan#8438.
So, the issue now is that there may be 'extra' keys in the array, if the class is not final. (3v4l.org/hM8MU)
Is there any way to indicate that the array may have more keys?
Currently you have to return null as soon as you encounter a non final class.
But more important, I think your implementation is wrong (and the right one might be really complex) because uninitialized properties are not in the array https://3v4l.org/XDYC7
No description provided.