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
[PHP 8.2] Add readonly class support #834
Conversation
71a4045
to
f34ec2c
Compare
Ready for review 👍 |
ec1116b
to
37b63f3
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.
This is missing a pretty printer test (and maybe pretty printer implementation -- not sure if this works out of the box).
e3cd925
to
64a01d0
Compare
I've added simple print. Seems working as the modifier method is universal. |
cce47ee
to
9bffe60
Compare
Ready for review ✔️ |
ccf3d46
to
05018b8
Compare
I've added the custom check for class modifiers. Let me know if that's ok. Otherwise good to review ✔️ |
Can you please regenerate the Php7.php file to fix the merge conflict? |
e1526ce
to
4978997
Compare
Done 👍 |
@TomasVotruba Thanks for the implementation! I've just noticed a slight difference between how properties of a readonly class is handled by php-src and PHP-Parser: while the former automatically assigns the readonly flag to any such property, Can we allow this inconsistency or should this be changed on PHP-Parser's part? |
Thank you, that's an interesting question. So any property inside the readonly class should have implicit readonly modifier? How would you differ between implicit readonly modifier, when it comes to printer? I think we have same convention for final classes. Their properties and methods are nor marked as final, even if PHP sees them this way. Saying that, I think php-parser is different from php-src, as the former parsers what it sees (and nothing implicit) and later covers implicit behavior not to allow invalid run. Like wysiwyg vs. runtime. Maybe different point of views: What real php-parser use case is negatively affected by this? |
Aha, it sounds like a good rule of thumb, and makes sense to me.
Hmm, I'm not aware of any. Although, I'll have to adapt the readonly class support in my PR :) P.S. @nikic Can you please make a PHP-Parser release so that I can update it in php-src? |
Ref https://wiki.php.net/rfc/readonly_classes
PHP src: php/php-src#7305