From 7c77ca38b1e3ea7a707380c731b237c2c480e093 Mon Sep 17 00:00:00 2001 From: Julien Pauli Date: Wed, 29 Oct 2014 14:35:51 +0100 Subject: Fix #65419 - Inside trait, self::class != __CLASS__ --- Zend/tests/bug65419.phpt | 23 +++++++++++++++++++++++ Zend/zend_compile.c | 6 ++++++ 2 files changed, 29 insertions(+) create mode 100644 Zend/tests/bug65419.phpt diff --git a/Zend/tests/bug65419.phpt b/Zend/tests/bug65419.phpt new file mode 100644 index 0000000000..677b2750f2 --- /dev/null +++ b/Zend/tests/bug65419.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #65419 (Inside trait, self::class != __CLASS__) +--FILE-- + +--EXPECTF-- +ghi +ghi \ No newline at end of file diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 6e1912803e..ae9409e715 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -2140,6 +2140,12 @@ void zend_do_resolve_class_name(znode *result, znode *class_name, int is_static if (!CG(active_class_entry)) { zend_error(E_COMPILE_ERROR, "Cannot access self::class when no class scope is active"); } + if (CG(active_class_entry)->ce_flags & ZEND_ACC_TRAIT) { + constant_name.op_type = IS_CONST; + ZVAL_STRINGL(&constant_name.u.constant, "class", sizeof("class")-1, 1); + zend_do_fetch_constant(result, class_name, &constant_name, ZEND_RT, 1 TSRMLS_CC); + break; + } zval_dtor(&class_name->u.constant); class_name->op_type = IS_CONST; ZVAL_STRINGL(&class_name->u.constant, CG(active_class_entry)->name, CG(active_class_entry)->name_length, 1); -- cgit v1.2.1