Bug #80055 [NEW]: Abstract trait methods returning "self" cannot be fulfilled by traits
| From: | dusk at woofle dot net | Date: | Fri, 04 Sep 2020 07:02:48 +0000 |
| Subject: | Bug #80055 [NEW]: Abstract trait methods returning "self" cannot be fulfilled by traits | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-228872@lists.php.net to get a copy of this message | ||
From: dusk at woofle dot net
Operating system: any
PHP version: 7.4.10
Package: Class/Object related
Bug Type: Bug
Bug description:Abstract trait methods returning "self" cannot be fulfilled by traits
Description:
------------
If a concrete method implemented by a trait is declared as returning
"self", it is considered incompatible with an abstract declaration of
that method in another trait.
Test script:
---------------
trait AbstractTrait {
abstract public function selfReturner() : self;
}
trait ConcreteTrait {
public function selfReturner() : self {
return $this;
}
}
class Test {
use AbstractTrait;
use ConcreteTrait;
}
Expected result:
----------------
The AbstractTrait trait should be satisfied by the implementation
provided by ConcreteTrait.
Actual result:
--------------
Fatal error: Declaration of ConcreteTrait::selfReturner(): ConcreteTrait
must be compatible with AbstractTrait::selfReturner(): AbstractTrait
--
Edit bug report at https://bugs.php.net/bug.php?id=80055&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80055&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80055&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80055&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80055&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80055&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80055&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80055&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80055&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80055&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80055&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80055&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80055&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80055&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80055&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80055&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80055&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80055&r=mysqlcfg