diff options
author | Stefan Marr <gron@php.net> | 2011-11-01 00:39:10 +0000 |
---|---|---|
committer | Stefan Marr <gron@php.net> | 2011-11-01 00:39:10 +0000 |
commit | b5f15ef561fcf8348fc9e3b986f096eacf4e243c (patch) | |
tree | 9a90ec641c1303f68d13567a3f850dc7c66c24a8 | |
parent | 2e5d5e5ac64daab299cd04382df92c3fd4fa17f6 (diff) | |
download | php-git-b5f15ef561fcf8348fc9e3b986f096eacf4e243c.tar.gz |
Fixed Bug #60145 (Usage of trait's use statement inside interfaces not properly checked.)
-rw-r--r-- | Zend/tests/traits/bug60145.phpt | 17 | ||||
-rw-r--r-- | Zend/zend_compile.c | 6 |
2 files changed, 23 insertions, 0 deletions
diff --git a/Zend/tests/traits/bug60145.phpt b/Zend/tests/traits/bug60145.phpt new file mode 100644 index 0000000000..fcd0cfa5f2 --- /dev/null +++ b/Zend/tests/traits/bug60145.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #60145 (Usage of trait's use statement inside interfaces not properly checked.) +--FILE-- +<?php + +trait foo { + +} + +interface MyInterface { + use foo; + + public function b(); + +} +--EXPECTF-- +Fatal error: Cannot use traits inside of interfaces. foo is used in MyInterface in %s on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 47e6f53736..bf8a35d3ed 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -5023,6 +5023,12 @@ void zend_do_implements_interface(znode *interface_name TSRMLS_DC) /* {{{ */ void zend_do_implements_trait(znode *trait_name TSRMLS_DC) /* {{{ */ { zend_op *opline; + if ((CG(active_class_entry)->ce_flags & ZEND_ACC_INTERFACE)) { + zend_error(E_COMPILE_ERROR, + "Cannot use traits inside of interfaces. %s is used in %s", + Z_STRVAL(trait_name->u.constant), CG(active_class_entry)->name); + } + switch (zend_get_class_fetch_type(Z_STRVAL(trait_name->u.constant), Z_STRLEN(trait_name->u.constant))) { case ZEND_FETCH_CLASS_SELF: |