From 8d3818fffbfec9eb0053c6b59f1236a481284f93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Magalh=C3=A3es?= Date: Sat, 22 Apr 2017 18:41:54 +0200 Subject: [PATCH] Allow overriding abstract methods --- Zend/tests/abstract_inheritance_001.phpt | 12 ++++++++++++ Zend/tests/abstract_inheritance_002.phpt | 12 ++++++++++++ Zend/tests/abstract_inheritance_003.phpt | 12 ++++++++++++ Zend/zend_inheritance.c | 10 ---------- 4 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 Zend/tests/abstract_inheritance_001.phpt create mode 100644 Zend/tests/abstract_inheritance_002.phpt create mode 100644 Zend/tests/abstract_inheritance_003.phpt diff --git a/Zend/tests/abstract_inheritance_001.phpt b/Zend/tests/abstract_inheritance_001.phpt new file mode 100644 index 0000000000000..9e061e65d5aac --- /dev/null +++ b/Zend/tests/abstract_inheritance_001.phpt @@ -0,0 +1,12 @@ +--TEST-- +Allow abstract function override +--FILE-- + +--EXPECT-- +DONE diff --git a/Zend/tests/abstract_inheritance_002.phpt b/Zend/tests/abstract_inheritance_002.phpt new file mode 100644 index 0000000000000..78f53c85c8b58 --- /dev/null +++ b/Zend/tests/abstract_inheritance_002.phpt @@ -0,0 +1,12 @@ +--TEST-- +Allow abstract function override +--FILE-- + +--EXPECT-- +DONE diff --git a/Zend/tests/abstract_inheritance_003.phpt b/Zend/tests/abstract_inheritance_003.phpt new file mode 100644 index 0000000000000..24d5920cc15a9 --- /dev/null +++ b/Zend/tests/abstract_inheritance_003.phpt @@ -0,0 +1,12 @@ +--TEST-- +Allow abstract function override +--FILE-- + +--EXPECTF-- +Fatal error: Declaration of B::bar($x) must be compatible with A::bar($x, $y = 0) in %s diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 3a32215708fb8..8f43d1560099d 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -551,16 +551,6 @@ static void do_inheritance_check_on_method(zend_function *child, zend_function * uint32_t child_flags; uint32_t parent_flags = parent->common.fn_flags; - if ((parent->common.scope->ce_flags & ZEND_ACC_INTERFACE) == 0 - && parent->common.fn_flags & ZEND_ACC_ABSTRACT - && parent->common.scope != (child->common.prototype ? child->common.prototype->common.scope : child->common.scope) - && child->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_IMPLEMENTED_ABSTRACT)) { - zend_error_noreturn(E_COMPILE_ERROR, "Can't inherit abstract function %s::%s() (previously declared abstract in %s)", - ZSTR_VAL(parent->common.scope->name), - ZSTR_VAL(child->common.function_name), - child->common.prototype ? ZSTR_VAL(child->common.prototype->common.scope->name) : ZSTR_VAL(child->common.scope->name)); - } - if (UNEXPECTED(parent_flags & ZEND_ACC_FINAL)) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot override final method %s::%s()", ZEND_FN_SCOPE_NAME(parent), ZSTR_VAL(child->common.function_name)); }