|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-11-05 00:10 UTC] gron@php.net
-Status: Open
+Status: Assigned
-Assigned To:
+Assigned To: gron
[2011-11-05 01:46 UTC] gron@php.net
[2011-11-05 01:48 UTC] gron@php.net
-Status: Assigned
+Status: Closed
[2011-11-05 01:48 UTC] gron@php.net
[2012-04-18 09:47 UTC] laruence@php.net
[2012-07-24 23:39 UTC] rasmus@php.net
[2013-11-17 09:35 UTC] laruence@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 11:00:01 2025 UTC |
Description: ------------ Using multiple traits that depend on the same requirement using an abstract method fails with a fatal error. I tried using trait composition in order to move the requirement into a common trait, but this does not work either. Test script: --------------- trait DoubleAmount { public function doubleAmount() { return $this->getAmount() * 2; } public abstract function getAmount(); } trait TripleAmount { public function tripleAmount() { return $this->getAmount() * 3; } public abstract function getAmount(); } class model { use DoubleAmount, TripleAmount; public function getAmount() { return 23; } } Actual result: -------------- PHP Fatal error: Can't inherit abstract function TripleAmount::getAmount() (previously declared abstract in DoubleAmount) in /home/maus/projects/traitstest/trait_abstract.php on line 30