summaryrefslogtreecommitdiff
path: root/Zend/zend_compile.c
diff options
context:
space:
mode:
authorStefan Marr <gron@php.net>2012-03-04 19:34:19 +0000
committerStefan Marr <gron@php.net>2012-03-04 19:34:19 +0000
commitffded0020b7f3b218074e785a2c435eebdcde176 (patch)
treea590da908848ab4e9f0e523a27a157604e3a9549 /Zend/zend_compile.c
parent32c5643f6b0ba46fdbdbf58a8def23a8403b3c0b (diff)
downloadphp-git-ffded0020b7f3b218074e785a2c435eebdcde176.tar.gz
Fixed Bug #61052 (Missing error check in trait 'insteadof' clause)
Diffstat (limited to 'Zend/zend_compile.c')
-rw-r--r--Zend/zend_compile.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 88c5020a29..c3c35eb5fc 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -3984,13 +3984,28 @@ static void zend_traits_init_trait_structures(zend_class_entry *ce TSRMLS_DC) /*
/** With the other traits, we are more permissive.
We do not give errors for those. This allows to be more
- defensive in such definitions. */
+ defensive in such definitions.
+ However, we want to make sure that the insteadof declartion
+ is consistent in itself.
+ */
j = 0;
while (cur_precedence->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++;
}