com php-src: Fixed Bug #69467 (Wrong checked for the interface by using Trait): NEWS Zend/tests/bug69467.phpt Zend/zend_compile.c
| From: | Xinchen Hui | Date: | Tue, 21 Apr 2015 14:36:32 +0000 |
| Subject: | com php-src: Fixed Bug #69467 (Wrong checked for the interface by using Trait): NEWS Zend/tests/bug69467.phpt Zend/zend_compile.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-86414@lists.php.net to get a copy of this message | ||
Commit: c667c26f616f91db5b890d39807c77c4720ba507
Author: Xinchen Hui <laruence@php.net> Tue, 21 Apr 2015 22:36:32 +0800
Parents: 35baf7146656c7262914f0059a3a585ae51bb82a
Branches: PHP-5.5 PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c667c26f616f91db5b890d39807c77c4720ba507
Log:
Fixed Bug #69467 (Wrong checked for the interface by using Trait)
Bugs:
https://bugs.php.net/69467
Changed paths:
M NEWS
A Zend/tests/bug69467.phpt
M Zend/zend_compile.c
Diff:
diff --git a/NEWS b/NEWS
index 10a598a..a094c5a 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ PHP NEWS
?? ??? 2015, PHP 5.5.25
- Core:
+ . Fixed bug #69467 (Wrong checked for the interface by using Trait).
+ (Laruence)
. Fixed bug #69420 (Invalid read in zend_std_get_method). (Laruence)
. Fixed bug #60022 ("use statement [...] has no effect" depends on leading
backslash). (Nikita)
diff --git a/Zend/tests/bug69467.phpt b/Zend/tests/bug69467.phpt
new file mode 100644
index 0000000..2228300
--- /dev/null
+++ b/Zend/tests/bug69467.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Bug #69467 (Wrong checked for the interface by using Trait)
+--FILE--
+<?php
+interface Baz {
+ public function bad();
+}
+
+trait Bar{
+ protected function bad(){}
+}
+
+class Foo implements Baz{
+ use Bar;
+}
+
+$test = new Foo();
+var_dump($test instanceof Baz);
+?>
+--EXPECTF--
+Fatal error: Access level to Bar::bad() must be public (as in class Baz) in %sbug69467.php on line
%d
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 4e61f5f..719f6e7 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -3912,14 +3912,15 @@ static void zend_add_trait_method(zend_class_entry *ce, const char *name,
const
}
zend_hash_quick_update(*overriden, arKey, nKeyLength, h, fn, sizeof(zend_function),
(void**)&fn);
return;
- } else if (existing_fn->common.fn_flags & ZEND_ACC_ABSTRACT) {
+ } else if (existing_fn->common.fn_flags & ZEND_ACC_ABSTRACT &&
+ (existing_fn->common.scope->ce_flags & ZEND_ACC_INTERFACE) == 0) {
/* Make sure the trait method is compatible with previosly declared abstract method */
if (!zend_traits_method_compatibility_check(fn, existing_fn TSRMLS_CC)) {
zend_error(E_COMPILE_ERROR, "Declaration of %s must be compatible with %s",
zend_get_function_declaration(fn TSRMLS_CC),
zend_get_function_declaration(existing_fn TSRMLS_CC));
}
- } else if (fn->common.fn_flags & ZEND_ACC_ABSTRACT) {
+ } else if (fn->common.fn_flags & ZEND_ACC_ABSTRACT) {
/* Make sure the abstract declaration is compatible with previous declaration */
if (!zend_traits_method_compatibility_check(existing_fn, fn TSRMLS_CC)) {
zend_error(E_COMPILE_ERROR, "Declaration of %s must be compatible with %s",