loosely-equal value). (pmmaga)
. Fixed bug #61970 (Restraining __construct() access level in subclass gives
a fatal error). (pmmaga)
+ . Fixed bug #63384 (Cannot override an abstract method with an abstract
+ method). (pmmaga, wes)
- BCMath:
. Fixed bug #46564 (bcmod truncates fractionals). (liborm85)
inherited method. This complies with contravariance of method argument types
under the Liskov Substitution Principle.
(https://wiki.php.net/rfc/parameter-no-type-variance)
+ . It is now allowed to override an abstract method with another abstract
+ method in a child class.
+ (https://wiki.php.net/rfc/allow-abstract-function-override)
. A trailing comma in group use statements is now allowed.
(https://wiki.php.net/rfc/list-syntax-trailing-commas)
--- /dev/null
+--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
--- /dev/null
+--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
--- /dev/null
+--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
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));
}