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

 ID:                 64070
 Comment by:         source dot spider 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:

@denny.reeh

OS: Win7/x64 

$ php --version
PHP 5.4.11 (cli) (built: Jan 16 2013 20:26:43)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

$ php .sandbox.php
PHP Fatal error:  Trait method first_function has not been applied, because 
there are collisions with other trait methods on first_class in ########## on 
line 25

Fatal error: Trait method first_function has not been applied, because there 
are 
collisions with other trait methods on first_class in ########## on line 25


Previous Comments:
------------------------------------------------------------------------
[2013-01-25 11:26:34] denny dot reeh at gmail dot com

example works with 5.4.10

------------------------------------------------------------------------
[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