From: Stefan Marr Date: Sun, 4 Mar 2012 18:33:33 +0000 (+0000) Subject: Fixed Bug #60911 (Confusing error message when extending traits) X-Git-Tag: PHP-5.4.1-RC1~85 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=34fe62619dcb0df395ea6f916e3891463574ef8a;p=php Fixed Bug #60911 (Confusing error message when extending traits) --- diff --git a/NEWS b/NEWS index 2151b8e61d..1be7ccf16c 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,7 @@ PHP NEWS . Fixed bug #60717 (Order of traits in use statement can cause a fatal error). (Stefan) . Fixed bug #60801 (strpbrk() mishandles NUL byte). (Adam) + . Fixed bug #60911 (Confusing error message when extending traits). (Stefan) . Fixed bug #60978 (exit code incorrect). (Laruence) . Fixed bug #61000 (Exceeding max nesting level doesn't delete numerical vars). (Laruence) diff --git a/Zend/tests/traits/bug55524.phpt b/Zend/tests/traits/bug55524.phpt index 1911cde130..137975980d 100644 --- a/Zend/tests/traits/bug55524.phpt +++ b/Zend/tests/traits/bug55524.phpt @@ -12,4 +12,4 @@ trait Foo extends Base { echo 'DONE'; ?> --EXPECTF-- -Fatal error: A trait (Foo) cannot extend a class in %s on line %d +Fatal error: A trait (Foo) cannot extend a class. Traits can only be composed from other traits with the 'use' keyword. Error in %s on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index a7b130d8fd..88c5020a29 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -4995,7 +4995,7 @@ void zend_do_begin_class_declaration(const znode *class_token, znode *class_name if (doing_inheritance) { /* Make sure a trait does not try to extend a class */ if ((new_class_entry->ce_flags & ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT) { - zend_error(E_COMPILE_ERROR, "A trait (%s) cannot extend a class", new_class_entry->name); + zend_error(E_COMPILE_ERROR, "A trait (%s) cannot extend a class. Traits can only be composed from other traits with the 'use' keyword. Error", new_class_entry->name); } opline->extended_value = parent_class_name->u.op.var;