|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2013-02-22 15:28 UTC] r dot wilczek at web-appz dot de
 Description:
------------
It is no longer possible to use a trait, which uses another trait and aliases methods.
This worked in PHP 5.4.10, but changed in either PHP 5.4.11 or PHP 5.4.12.
Test script:
---------------
<?php
trait MyTrait
{
	public function foo() {}
}
trait MyOtherTrait
{
    use MyTrait
    {
        foo as bar;
    }
}
class Importer
{
    use MyOtherTrait;
}
echo 'works' . PHP_EOL;
Expected result:
----------------
works
Actual result:
--------------
Fatal error: Trait method foo has not been applied, because there are collisions with other trait methods on Importer in Example.php on line 18
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 17:00:02 2025 UTC | 
Tried the snapshot ... Given the traits MyTrait, MyOtherTrait and the class Importer (see above), it shows this one: $class = new \ReflectionClass('Importer'); foreach ($class->getMethods() as $method) { /* @var $method \ReflectionMethod */ echo $method->getName() . PHP_EOL; } Expected result: foo Actual result: foo foo uh oh!