From 648238da5c45bdf2c65d856b533f9a2534864ba2 Mon Sep 17 00:00:00 2001 From: Joe Watkins Date: Wed, 1 Feb 2017 18:33:47 +0000 Subject: [PATCH 1/2] Revert "Added tests demonstrating the same effect with abstracts" This reverts commit c11b2b809d349399c8f4b54c6bf24078dece455e. --- Zend/tests/bug73987.phpt | 2 +- Zend/tests/bug73987_1.phpt | 2 +- Zend/tests/bug73987_2.phpt | 20 -------------------- Zend/tests/bug73987_3.phpt | 20 -------------------- 4 files changed, 2 insertions(+), 42 deletions(-) delete mode 100644 Zend/tests/bug73987_2.phpt delete mode 100644 Zend/tests/bug73987_3.phpt diff --git a/Zend/tests/bug73987.phpt b/Zend/tests/bug73987.phpt index 610b594a644..551565650c8 100644 --- a/Zend/tests/bug73987.phpt +++ b/Zend/tests/bug73987.phpt @@ -1,5 +1,5 @@ --TEST-- -Bug #73987 (Method compatibility check looks to original definition and not parent - nullability interface) +Bug #73987 (Method compatibility check looks to original definition and not parent) --FILE-- ---EXPECTF-- -Fatal error: Declaration of C::example($a, $b, $c = NULL) must be compatible with B::example($a, $b = NULL, $c = NULL) in %s diff --git a/Zend/tests/bug73987_3.phpt b/Zend/tests/bug73987_3.phpt deleted file mode 100644 index 89e4686ed6f..00000000000 --- a/Zend/tests/bug73987_3.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Bug #73987 (Method compatibility check looks to original definition and not parent - return types abstract) ---FILE-- - ---EXPECTF-- -Fatal error: Declaration of C::example(): string must be compatible with B::example(): int in %s From 46de334452683953425b25fc0451649eaa6059fe Mon Sep 17 00:00:00 2001 From: Joe Watkins Date: Wed, 1 Feb 2017 18:33:58 +0000 Subject: [PATCH 2/2] Revert "Inheritance checks should not ignore parents if these implement an interface" This reverts commit b67eb3440bb244adf6957bf2c68aeeaa6efc8c8d. --- NEWS | 2 -- Zend/tests/bug62358.phpt | 2 +- Zend/tests/bug73987.phpt | 18 ------------------ Zend/tests/bug73987_1.phpt | 18 ------------------ Zend/zend_inheritance.c | 9 +++++---- 5 files changed, 6 insertions(+), 43 deletions(-) delete mode 100644 Zend/tests/bug73987.phpt delete mode 100644 Zend/tests/bug73987_1.phpt diff --git a/NEWS b/NEWS index 6514e485aa0..7f600d8f4ac 100644 --- a/NEWS +++ b/NEWS @@ -15,8 +15,6 @@ PHP NEWS . Fixed bug #73969 (segfault in debug_print_backtrace). (andrewnester) . Fixed bug #73994 (arginfo incorrect for unpack). (krakjoe) . Fixed bug #73973 (assertion error in debug_zval_dump). (andrewnester) - . Fixed bug #73987 (Method compatibility check looks to original - definition and not parent). (pmmaga) - DOM: . Fixed bug #54382 (getAttributeNodeNS doesn't get xmlns* attributes). diff --git a/Zend/tests/bug62358.phpt b/Zend/tests/bug62358.phpt index 8509383d469..35bbc33835b 100644 --- a/Zend/tests/bug62358.phpt +++ b/Zend/tests/bug62358.phpt @@ -23,4 +23,4 @@ class B extends A { } ?> --EXPECTF-- -Fatal error: Declaration of B::foo($var) must be compatible with A::foo() in %sbug62358.php on line 17 +Fatal error: Declaration of B::foo($var) must be compatible with I::foo() in %sbug62358.php on line 17 diff --git a/Zend/tests/bug73987.phpt b/Zend/tests/bug73987.phpt deleted file mode 100644 index 551565650c8..00000000000 --- a/Zend/tests/bug73987.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -Bug #73987 (Method compatibility check looks to original definition and not parent) ---FILE-- - ---EXPECTF-- -Fatal error: Declaration of B::example($a, $b, $c = NULL) must be compatible with A::example($a, $b = NULL, $c = NULL) in %s diff --git a/Zend/tests/bug73987_1.phpt b/Zend/tests/bug73987_1.phpt deleted file mode 100644 index 6a0a157f29a..00000000000 --- a/Zend/tests/bug73987_1.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -Bug #73987 (Method compatibility check looks to original definition and not parent) ---FILE-- - ---EXPECTF-- -Fatal error: Declaration of B::example(): string must be compatible with A::example(): int in %s diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 8ad5cc2e01b..fd1345f844f 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -607,12 +607,13 @@ static void do_inheritance_check_on_method(zend_function *child, zend_function * } else if (!(parent->common.fn_flags & ZEND_ACC_CTOR) || (parent->common.prototype && (parent->common.prototype->common.scope->ce_flags & ZEND_ACC_INTERFACE))) { /* ctors only have a prototype if it comes from an interface */ child->common.prototype = parent->common.prototype ? parent->common.prototype : parent; - /* and if that is the case, we want to check inheritance against it */ - if (parent->common.fn_flags & ZEND_ACC_CTOR) { - parent = child->common.prototype; - } } + if (child->common.prototype && ( + child->common.prototype->common.fn_flags & ZEND_ACC_ABSTRACT + )) { + parent = child->common.prototype; + } if (UNEXPECTED(!zend_do_perform_implementation_check(child, parent))) { int error_level; const char *error_verb;