Skip to content

Fix public readonly property injection #860

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

Merged

Conversation

kocsismate
Copy link
Contributor

The compiler tries to initialize all public properties directly inside the compiled container, however readonly properties do not support writing from an outside scope.

Additionally, I noticed a small room for a performance improvement: ReflectionProperty::setAccessible() doesn't have to be invoked as of PHP 8.1 (https://wiki.php.net/rfc/make-reflection-setaccessible-no-op), so I fixed it as well in a separate commit.

Copy link
Member

@mnapoli mnapoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's brilliant! The CS checks are failing, but once fixed I'd be happy to merge!

@kocsismate kocsismate force-pushed the fix-public-readonly-property-injection branch from 4b2908b to 15e4b16 Compare August 8, 2023 13:38
@kocsismate
Copy link
Contributor Author

Done! The one remaining CS issue seems unrelated to my changes 🤔

@mnapoli
Copy link
Member

mnapoli commented Aug 8, 2023

Got it, thanks!

@mnapoli mnapoli merged commit 8ed7946 into PHP-DI:master Aug 8, 2023
@kocsismate kocsismate deleted the fix-public-readonly-property-injection branch August 8, 2023 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants