Bug #75590 [Opn]: Fatal error when removing optional argument in subclass (BC break).

From: Date: Wed, 29 Nov 2017 17:08:55 +0000
Subject: Bug #75590 [Opn]: Fatal error when removing optional argument in subclass (BC break).
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-212808@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75590&edit=1 ID: 75590 User updated by: christoph at burschka dot de Reported by: christoph at burschka dot de Summary: Fatal error when removing optional argument in subclass (BC break). Status: Open Type: Bug Package: *General Issues Operating System: MacOS PHP Version: 7.2.0RC6 Block user comment: N Private report: N New Comment: Also note: If the interface declares the optional argument as well, then the result is a fatal error in both 7.1.11 and 7.2.0RC6. Previous Comments: ------------------------------------------------------------------------ [2017-11-29 17:02:56] christoph at burschka dot de Description: ------------ In this inheritance chain, an interface defines a function without an argument, then an implementing class adds an optional argument, and a subclass defines the function with the original signature from the interface (no argument). This works in PHP 7.1.11, but triggers E_ERROR in PHP 7.2.0RC6. (Note: Without the interface, simply removing an optional argument in a subclass is E_WARNING on both 7.1.11 and 7.2.0RC6.) Test script: --------------- interface A { public function f(); } class B implements A { public function f(A $x = NULL) {} } class C extends B { public function f() {} } Expected result: ---------------- Same behavior in PHP 7.2.0RC6 as PHP 7.1.11, or at worst a non-fatal warning/deprecation. Actual result: -------------- No warning in 7.1.11, E_ERROR in 7.2.0RC6. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75590&edit=1

« previous php.bugs (#212808) next »