From:
Operating system: Ubuntu Linux 11.10
PHP version: 5.4.0beta2
Package: Class/Object related
Bug Type: Bug
Bug description:imposing requirements in traits
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 bug report at https://bugs.php.net/bug.php?id=60217&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=60217&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=60217&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=60217&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=60217&r=fixed
Fixed in SVN and need be documented:
https://bugs.php.net/fix.php?id=60217&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=60217&r=alreadyfixed
Need backtrace:
https://bugs.php.net/fix.php?id=60217&r=needtrace
Need Reproduce Script:
https://bugs.php.net/fix.php?id=60217&r=needscript
Try newer version:
https://bugs.php.net/fix.php?id=60217&r=oldversion
Not developer issue:
https://bugs.php.net/fix.php?id=60217&r=support
Expected behavior:
https://bugs.php.net/fix.php?id=60217&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=60217&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=60217&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=60217&r=globals
PHP 4 support discontinued:
https://bugs.php.net/fix.php?id=60217&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=60217&r=dst
IIS Stability:
https://bugs.php.net/fix.php?id=60217&r=isapi
Install GNU Sed:
https://bugs.php.net/fix.php?id=60217&r=gnused
Floating point limitations:
https://bugs.php.net/fix.php?id=60217&r=float
No Zend Extensions:
https://bugs.php.net/fix.php?id=60217&r=nozend
MySQL Configuration Error:
https://bugs.php.net/fix.php?id=60217&r=mysqlcfg