Bug #74607 [Opn->Csd]: Traits enforce different inheritance rules
| From: | nikic@php.net | Date: | Fri, 02 Jun 2017 22:26:20 +0000 |
| Subject: | Bug #74607 [Opn->Csd]: Traits enforce different inheritance rules | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-209371@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74607&edit=1
ID: 74607
Updated by: nikic@php.net
Reported by: mail at pmmaga dot net
Summary: Traits enforce different inheritance rules
-Status: Open
+Status: Closed
Type: Bug
Package: Class/Object related
Operating System: *
PHP Version: 7.0.19
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of mail@pmmaga.net
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c6c1e75e6ba082b6d57f71c28d316b6db4fda6c7
Log: Fix bug #74607: Don't check for bi-directional compatibility in traits
Previous Comments:
------------------------------------------------------------------------
[2017-05-19 15:00:11] levim@php.net
Here is the exact branch that is being taken on master:
https://github.com/php/php-src/blob/372397f518bf6de04a973b7ca52ae724b6f56bd6/Zend/zend_inheritance.c#L1187-L1194
------------------------------------------------------------------------
[2017-05-17 22:06:58] mail at pmmaga dot net
Description:
------------
When inheriting from an abstract class, a method implemented by a trait does not allow adding a
return type. This is allowed when the method is implemented directly in the child class.
On the current master (7.2) the same happens when omitting a type-hint.
With interfaces the behavior is consistent with or without traits.
Test script:
---------------
<?php
abstract class L1{
abstract function m3($x);
}
trait L2t{
function m3($x): int{}
}
class L2 extends L1{
use L2t;
}
Expected result:
----------------
N/A
Actual result:
--------------
Fatal error: Declaration of L2t::m3($x): int must be compatible with L1::m3($x) in ...
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74607&edit=1