Repository navigation
Conversation
When a class and a trait (or two traits) define the same property in an incompatible way, the error message now states why the definitions are considered incompatible: differing visibility, static or readonly modifiers, types, or default values, including the case where only one of them has a default value (e.g. a constructor promoted property). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Quoted below: written with Claude, an LLM, as CONTRIBUTING.md asks us to mark. The builds and test runs behind it are on my machine; the commands to repeat them are under the fold.
|
Closes GH-16643
When a class and a trait (or two traits) define the same property incompatibly, the error currently only says that "the definition differs and is considered incompatible", which is confusing in cases like the one from the issue (a constructor promoted property has no default value, while the trait's property does).
This splits the single compatibility check in
zend_do_traits_property_binding()and appends the reason to the existing message:Possible reasons, checked in this order:
the visibility differsonly one of them is staticonly one of them is readonlythe types differonly one of them has a default valuethe default values differThe start of the message is unchanged, so only the expected output of existing tests had to be updated; each reason is covered by at least one of them, plus a new test for the case from the issue.
Trait constants have a similar generic message (
emit_incompatible_trait_constant_error()); I left them out to keep this focused, but I'm happy to follow up if desired. I also didn't add a NEWS/UPGRADING entry since this is only an error message change; let me know if one is wanted.🤖 Generated with Claude Code