com php-src: Fixed bug #70957 (self::class can not be resolved with reflection for abstract class): NEWS Zend/tests/bug70957.phpt Zend/zend_compile.c
| From: | Xinchen Hui | Date: | Mon, 23 Nov 2015 04:20:44 +0000 |
| Subject: | com php-src: Fixed bug #70957 (self::class can not be resolved with reflection for abstract class): NEWS Zend/tests/bug70957.phpt Zend/zend_compile.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-89963@lists.php.net to get a copy of this message | ||
Commit: ab17840d33354cc32d24c88d3e401d7b0869c996
Author: Xinchen Hui <laruence@gmail.com> Mon, 23 Nov 2015 12:20:44 +0800
Parents: 205e0ba81d84bf91bdae13039a77db5fa1344dd4
Branches: PHP-5.6 PHP-7.0
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ab17840d33354cc32d24c88d3e401d7b0869c996
Log:
Fixed bug #70957 (self::class can not be resolved with reflection for abstract class)
Bugs:
https://bugs.php.net/70957
Changed paths:
M NEWS
A Zend/tests/bug70957.phpt
M Zend/zend_compile.c
Diff:
diff --git a/NEWS b/NEWS
index 189d9e0..27c215b 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ PHP NEWS
?? ??? 2015, PHP 5.6.17
- Core:
+ . Fixed bug #70957 (self::class can not be resolved with reflection for
+ abstract class). (Laruence)
. Fixed bug #70944 (try{ } finally{} can create infinite chains of
exceptions). (Laruence)
diff --git a/Zend/tests/bug70957.phpt b/Zend/tests/bug70957.phpt
new file mode 100644
index 0000000..e6a38f7
--- /dev/null
+++ b/Zend/tests/bug70957.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Bug #70957 (self::class can not be resolved with reflection for abstract class)
+--FILE--
+<?php
+
+abstract class Foo
+{
+ function bar($a = self::class) {}
+}
+
+trait T {
+ public function bar() {
+ }
+}
+
+class Bar extends Foo
+{
+ use T;
+}
+?>
+--EXPECTF--
+Strict Standards: Declaration of T::bar() should be compatible with Foo::bar($a = 'Foo')
in %sbug70957.php on line %d
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index fca4e2a..03c2f5a 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -2214,7 +2214,7 @@ 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) {
+ if ((CG(active_class_entry)->ce_flags & ZEND_ACC_TRAIT) == 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);