Bug #71978 [Asn->Csd]: Existence of return type hint affects other compatibility rules

From: Date: Wed, 06 Apr 2016 14:20:55 +0000
Subject: Bug #71978 [Asn->Csd]: Existence of return type hint affects other compatibility rules
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-200400@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71978&edit=1 ID: 71978 Updated by: dmitry@php.net Reported by: dmitry@php.net Summary: Existence of return type hint affects other compatibility rules -Status: Assigned +Status: Closed Type: Bug Package: Scripting Engine problem Operating System: * PHP Version: 7.0Git-2016-04-06 (Git) Assigned To: dmitry Block user comment: N Private report: N New Comment: Automatic comment on behalf of dmitry@zend.com Revision: http://git.php.net/?p=php-src.git;a=commit;h=e9d65160e85fb08d9bd08202b60a8b19b446c646 Log: Fixed bug #71978 (Existence of return type hint affects other compatibility rules) Previous Comments: ------------------------------------------------------------------------ [2016-04-06 13:56:37] dmitry@php.net Description: ------------ Children classes may override methods with different argument types. This leads to Warning. However if the same methods in addition have the same return type PHP emits "Fatal Error" instead of "Warning" Test script: --------------- <?php class A { function foo(int $a) {} } class B extends A { function foo(string $a) {} } class A1 { function foo(int $a): int {} } class B1 extends A1 { function foo(string $a): int {} } ?> Expected result: ---------------- Warning: Declaration of B::foo(string $a) should be compatible with A::foo(int $a) in %s on line %d Warning: Declaration of B1::foo(string $a): int should be compatible with A1::foo(int $a): int in %s on line %d Actual result: -------------- Warning: Declaration of B::foo(string $a) should be compatible with A::foo(int $a) in %s on line %d Fatal Error: Declaration of B1::foo(string $a): int must be compatible with A1::foo(int $a): int in %s on line %d ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=71978&edit=1

« previous php.bugs (#200400) next »