Edit report at https://bugs.php.net/bug.php?id=64279&edit=1
ID: 64279
User updated by: r dot wilczek at web-appz dot de
Reported by: r dot wilczek at web-appz dot de
Summary: Using traits aliasing other traitmethods broken
-Status: Feedback
+Status: Open
Type: Bug
Package: *General Issues
Operating System: Linux x86_64
PHP Version: 5.4.12
Block user comment: N
Private report: N
New Comment:
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!
Previous Comments:
------------------------------------------------------------------------
[2013-02-22 15:36:00] [email protected]
Please try using this snapshot:
http://snaps.php.net/php5.4-latest.tar.gz
For Windows:
http://windows.php.net/snapshots/
seems the fix didn't goto 5.4.12
------------------------------------------------------------------------
[2013-02-22 15:28:15] 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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64279&edit=1