diff --git a/Zend/tests/traits/bug61052.phpt b/Zend/tests/traits/bug61052.phpt new file mode 100644 index 00000000000..421e9074e59 --- /dev/null +++ b/Zend/tests/traits/bug61052.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #61052 (missing error check in trait 'insteadof' clause) +--FILE-- +exclude_from_classes[j]) { char* class_name = (char*)cur_precedence->exclude_from_classes[j]; zend_uint name_length = strlen(class_name); cur_precedence->exclude_from_classes[j] = zend_fetch_class(class_name, name_length, ZEND_FETCH_CLASS_TRAIT TSRMLS_CC); + + /* make sure that the trait method is not from a class mentioned in + exclude_from_classes, for consistency */ + if (cur_precedence->trait_method->ce == cur_precedence->exclude_from_classes[i]) { + zend_error(E_COMPILE_ERROR, + "Inconsistent insteadof definition. " + "The method %s is to be used from %s, but %s is also on the exclude list", + cur_method_ref->method_name, + cur_precedence->trait_method->ce->name, + cur_precedence->trait_method->ce->name); + } + efree(class_name); j++; }