Inheritance with Traits failed with error
| Bug #64070 | Inheritance with Traits failed with error | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2013-01-25 11:23 UTC | Modified: | 2013-02-22 08:28 UTC |
|
||||||||||
| From: | denny dot reeh at gmail dot com | Assigned: | dmitry (profile) | |||||||||||
| Status: | Closed | Package: | Scripting Engine problem | |||||||||||
| PHP Version: | 5.4.11 | OS: | ||||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2013-01-25 11:23 UTC] denny dot reeh at gmail dot com
Description:
------------
if two traits have the same function name and a trait uses another trait and using the as operator for aliases the function, it failed with fatal error.
Test script:
---------------
<?php
trait first_trait
{
function first_function()
{
echo "From First Trait\n";
}
}
trait second_trait
{
use first_trait {
first_trait::first_function as second_function;
}
function first_function()
{
echo "From Second Trait\n";
}
}
class first_class
{
use second_trait;
}
$obj = new first_class();
$obj->first_function();
$obj->second_function();
Expected result:
----------------
From Second Trait
From First Trait
Actual result:
--------------
PHP Fatal error: Trait method first_function has not been applied, because there are collisions with other trait methods on first_class in test.php on line 25
PHP Stack trace:
PHP 1. {main}() /data/www/helix/test.php:0
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2013-01-25 11:26 UTC] denny dot reeh at gmail dot com
[2013-02-01 11:41 UTC] source dot spider at gmail dot com
[2013-02-11 01:42 UTC] manchokapitancho at gmail dot com
[2013-02-12 12:55 UTC] maciej dot sz at gmail dot com
[2013-02-17 10:53 UTC] inefedor at gmail dot com
[2013-02-17 10:54 UTC] denny dot reeh at gmail dot com
[2013-02-17 12:05 UTC] denny dot reeh at gmail dot com
[2013-02-18 10:41 UTC] inefedor at gmail dot com
[2013-02-18 12:36 UTC] dmitry@php.net
-Status: Assigned +Status: Closed
[2013-02-22 08:28 UTC] dmitry@php.net
[2013-02-26 10:25 UTC] alexander at mailinator dot net