Skip to content

[RFC] Allow Readonly Property Defaults#22588

Open
NickSdot wants to merge 2 commits into
php:masterfrom
NickSdot:readonly-property-defaults
Open

[RFC] Allow Readonly Property Defaults#22588
NickSdot wants to merge 2 commits into
php:masterfrom
NickSdot:readonly-property-defaults

Conversation

@NickSdot

@NickSdot NickSdot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Comment thread Zend/tests/readonly_classes/readonly_with_property_default.phpt Outdated
--EXPECTF--
int(42)

Fatal error: Set access level of D::$prop must be omitted (as in class J) in %s on line %d

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think the test is testing what you want. $prop should be public(set) in D.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hey Tim, thanks for the review!

It's essentially a copy of here:
https://github.com/php/php-src/blob/master/Zend/tests/property_hooks/interface_get_set_readonly.phpt#L11

The intention was to confirm that having a default value does not change anything. You probably think it was not what I wanted to test because of the irrelevant error message? If so please check the comment in the existing test file above -- known issue, it seems.

The case you mean should be tested here:
https://github.com/php/php-src/pull/22588/changes#diff-a5f6cb0065c3c8fe569119380cdb62cb4a1a7b9813fcf3bb97723894cb262667R10

--

Fine?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's essentially a copy of here:

I assume that test predated asymmetric visibility. It should probably be adjusted to include public(set) (or a second test added).

The case you mean should be tested here:

No. That test is not testing the behavior of the interaction between readonly and set; in an interface.

Comment thread Zend/tests/readonly_props/serialization.phpt
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.

2 participants