PHANTOM
🇮🇳 IN
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Zend/tests/abstract_inheritance_001.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
Allow abstract function override
--FILE--
<?php

abstract class A { abstract function bar($x); }
abstract class B extends A { abstract function bar($x); }

echo "DONE";
?>
--EXPECT--
DONE
12 changes: 12 additions & 0 deletions Zend/tests/abstract_inheritance_002.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
Allow abstract function override
--FILE--
<?php

abstract class A { abstract function bar($x); }
abstract class B extends A { abstract function bar($x, $y = 0); }

echo "DONE";
?>
--EXPECT--
DONE
12 changes: 12 additions & 0 deletions Zend/tests/abstract_inheritance_003.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
Allow abstract function override
--FILE--
<?php

abstract class A { abstract function bar($x, $y = 0); }
abstract class B extends A { abstract function bar($x); }

echo "DONE";
?>
--EXPECTF--
Fatal error: Declaration of B::bar($x) must be compatible with A::bar($x, $y = 0) in %s
10 changes: 0 additions & 10 deletions Zend/zend_inheritance.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down