php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #64235
Patch deny_use_with_classes.patch revision 2013-02-21 09:09 UTC by laruence@php.net
Patch bug64235.patch revision 2013-02-20 08:07 UTC by laruence@php.net
revision 2013-02-20 07:39 UTC by laruence@php.net
Patch bug64235.phpt revision 2013-02-20 07:41 UTC by laruence@php.net

Patch deny_use_with_classes.patch for Scripting Engine problem Bug #64235

Patch version 2013-02-21 09:09 UTC

Return to Bug #64235 | Download this patch
Patch Revisions:

Developer: laruence@php.net

diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index a3f4fe5..0a1749d 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -3859,12 +3859,16 @@ static void zend_check_trait_usage(zend_class_entry *ce, zend_class_entry *trait
 {
 	zend_uint i;
 
+	if ((trait->ce_flags & ZEND_ACC_TRAIT) != ZEND_ACC_TRAIT) {
+		zend_error(E_COMPILE_ERROR, "Class %s is not a trait, Only traits may be used in 'as' and 'insteadof' statements", trait->name);
+	}
+
 	for (i = 0; i < ce->num_traits; i++) {
 		if (ce->traits[i] == trait) {
 			return;
 		}
 	}
-	zend_error(E_COMPILE_ERROR, "Trait %s is not used", trait->name);
+	zend_error(E_COMPILE_ERROR, "Required Trait %s wasn't added to %s", trait->name, ce->name);
 }
 /* }}} */
 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 08:01:29 2024 UTC