--- /dev/null
+--TEST--
+Properties are considered incompatible if they are different in any of their
+defined characteristics. Thus, initialization values have to be equal, too.
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+trait foo
+{
+ public $zoo = 'foo::zoo';
+}
+
+class baz
+{
+ use foo;
+ public $zoo = 'baz::zoo';
+}
+
+$obj = new baz();
+echo $obj->zoo, "\n";
+?>
+--EXPECTF--
+Fatal error: baz and foo define the same property ($zoo) in the composition of baz. However, the definition differs and is considered incompatible. Class was composed in %s on line %d
\ No newline at end of file
if ((coliding_prop->flags & ZEND_ACC_PPP_MASK) == (property_info->flags & ZEND_ACC_PPP_MASK)) {
/* flags are identical, now the value needs to be checked */
if (property_info->flags & ZEND_ACC_STATIC) {
- not_compatible = compare_function(&compare_result,
- ce->default_static_members_table[coliding_prop->offset],
- ce->traits[i]->default_static_members_table[property_info->offset] TSRMLS_CC) == FAILURE;
+ not_compatible = (FAILURE == compare_function(&compare_result,
+ ce->default_static_members_table[coliding_prop->offset],
+ ce->traits[i]->default_static_members_table[property_info->offset] TSRMLS_CC))
+ || (Z_LVAL(compare_result) != 0);
} else {
- not_compatible = compare_function(&compare_result,
- ce->default_properties_table[coliding_prop->offset],
- ce->traits[i]->default_properties_table[property_info->offset] TSRMLS_CC) == FAILURE;
+ not_compatible = (FAILURE == compare_function(&compare_result,
+ ce->default_properties_table[coliding_prop->offset],
+ ce->traits[i]->default_properties_table[property_info->offset] TSRMLS_CC))
+ || (Z_LVAL(compare_result) != 0);
}
} else {
/* the flags are not identical, thus, we assume properties are not compatible */