Edit report at https://bugs.php.net/bug.php?id=60217&edit=1
ID: 60217 Updated by: g...@php.net Reported by: maus dot christian at googlemail dot com Summary: imposing requirements in traits -Status: Open +Status: Assigned Type: Bug Package: Class/Object related Operating System: Ubuntu Linux 11.10 PHP Version: 5.4.0beta2 -Assigned To: +Assigned To: gron Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2011-11-04 13:12:06] maus dot christian at googlemail dot com 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=60217&edit=1