You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We should add a test to confirm this, but I believe what would happen is a readonly class may implement an interface with properties, as long as it satisfies those properties with basic properties that have no hooks. So, this should be fine:
That's not what currently happens. Every property in a readonly class becomes implicitly readonly. However, non-readonly properties may not be re-declared as readonly. If it's simple enough, it makes sense to relax this restriction.
Fatal error: Cannot redeclare non-readonly property I::$name as readonly R::$name
Hrm, interesting. I would also favor relaxing that restriction here if possible. It seems like a reasonable use case.
Crell
changed the title
Add test for readonly classes implementing an interface property, cf: https://www.reddit.com/r/PHP/comments/13camsm/comment/jjljmqd/
Add test for readonly classes implementing an interface property
May 16, 2023
cf: https://www.reddit.com/r/PHP/comments/13camsm/comment/jjljmqd/
The text was updated successfully, but these errors were encountered: