Edit report at https://bugs.php.net/bug.php?id=64070&edit=1

 ID:                 64070
 User updated by:    denny dot reeh at gmail dot com
 Reported by:        denny dot reeh at gmail dot com
 Summary:            Inheritance with Traits failed with error
 Status:             Open
 Type:               Bug
 Package:            Scripting Engine problem
 PHP Version:        5.4.11
 Block user comment: N
 Private report:     N

 New Comment:

example works with 5.4.10


Previous Comments:
------------------------------------------------------------------------
[2013-01-25 11:23:43] 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



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=64070&edit=1

Reply via email to