[php-src] PR #25047: Fix GH-16643: Improve incompatible trait property error message

From: Date: Fri, 30 Oct 2026 05:42:13 +0000
Subject: [php-src] PR #25047: Fix GH-16643: Improve incompatible trait property error message
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-40078@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/25047 Author: glbessa 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: ``` Foo and FooTrait define the same property ($options) in the composition of Foo. However, the definition differs and is considered incompatible: only one of them has a default value. Class was composed in %s on line %d ``` Possible reasons, checked in this order: - the visibility differs - only one of them is static - only one of them is readonly - the types differ - only one of them has a default value - the default values differ The 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](https://claude.com/claude-code)

« previous php.git-pulls (#40078) next »