summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Pauli <jpauli@php.net>2014-11-28 13:26:53 +0100
committerJulien Pauli <jpauli@php.net>2014-11-28 13:26:53 +0100
commitb248a7a95c00de3e47b2d589d75d719a8fc70dfb (patch)
tree274ef8a0129a6c0e187e2e08f1fb44d15c9a80ba
parent1552d6ae7bb2b2f13a268b035b2fcb83a7c2a0df (diff)
parent619adc9795f925531196c5b7e4797453130eac98 (diff)
downloadphp-git-b248a7a95c00de3e47b2d589d75d719a8fc70dfb.tar.gz
Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5: updated NEWS Fix #65419 - Inside trait, self::class != __CLASS__
-rw-r--r--Zend/tests/bug65419.phpt23
-rw-r--r--Zend/zend_compile.c6
2 files changed, 29 insertions, 0 deletions
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--
+<?php
+trait abc
+{
+ static function def()
+ {
+ echo self::class, "\n";
+ echo __CLASS__, "\n";
+ }
+}
+
+class ghi
+{
+ use abc;
+}
+
+ghi::def();
+?>
+--EXPECTF--
+ghi
+ghi \ No newline at end of file
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index ccaf1652c2..03149091fb 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -2214,6 +2214,12 @@ void zend_do_resolve_class_name(znode *result, znode *class_name, int is_static
if (!CG(active_class_entry)) {
zend_error_noreturn(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);