Skip to content

ext/reflection: Make properties readonly - #24282

Open
kamil-tekiela wants to merge 1 commit into
php:masterfrom
kamil-tekiela:Reflection-readonly-properties
Open

kamil-tekiela wants to merge 1 commit into
php:masterfrom
kamil-tekiela:Reflection-readonly-properties

Conversation

@kamil-tekiela

@kamil-tekiela kamil-tekiela commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Fixes #24147 alternative to #24153

It should not break BetterReflection.

@kamil-tekiela

Copy link
Copy Markdown
Member Author

@ndossche According to the test, this should still allow unset, even though I think it would be better not too. The BC changes are minimal here: the properties cannot be redeclared. As such, I think it may even go on PHP 8.4.

@Ocramius What is your opinion on this?

@Ocramius

Copy link
Copy Markdown
Contributor

even though I think it would be better not too

An alternative could be to interface the properties, FWIW - requires some more substantial changes.

unset() is the only mechanism I currently know of to allow shadowing a property with additional logic: if property accessors allow overriding a parent property, that's also a viable idea.

@Ocramius

Copy link
Copy Markdown
Contributor

BTW, if you want, just take the phpunit suite of BetterReflection for a spin on this branch: it is very detailed

@kocsismate

Copy link
Copy Markdown
Member

These changes make sense to me, and I pretty much support this, but I don't think it should go into PHP 8.4, readonly shouldn't be added to a 2 year-old release IMO.

@kamil-tekiela
kamil-tekiela marked this pull request as draft October 20, 2026 12:34
@kamil-tekiela
kamil-tekiela changed the base branch from PHP-8.4 to master October 20, 2026 12:34
@kamil-tekiela
kamil-tekiela force-pushed the Reflection-readonly-properties branch from e319ba4 to 75d3fc9 Compare October 20, 2026 12:37
@kamil-tekiela
kamil-tekiela marked this pull request as ready for review October 20, 2026 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants