Bug #80055 [Ver->Csd]: Abstract trait methods returning "self" cannot be fulfilled by traits

From: Date: Thu, 15 Oct 2020 12:24:54 +0000
Subject: Bug #80055 [Ver->Csd]: Abstract trait methods returning "self" cannot be fulfilled by traits
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-229637@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80055&edit=1 ID: 80055 Updated by: nikic@php.net Reported by: dusk at woofle dot net Summary: Abstract trait methods returning "self" cannot be fulfilled by traits -Status: Verified +Status: Closed Type: Bug Package: Class/Object related Operating System: any PHP Version: 7.4.10 Block user comment: N Private report: N New Comment: Automatic comment on behalf of nikita.ppv@gmail.com Revision: http://git.php.net/?p=php-src.git;a=commit;h=4ece62fba9ff4ea5e500a329ae2c349f91771ff8 Log: Fix bug #80055 Previous Comments: ------------------------------------------------------------------------ [2020-09-04 07:28:30] nikic@php.net Also the case on PHP 8: https://3v4l.org/Go6WO ------------------------------------------------------------------------ [2020-09-04 07:02:48] dusk at woofle dot net 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 this bug report at https://bugs.php.net/bug.php?id=80055&edit=1

« previous php.bugs (#229637) next »