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

 ID:                 64235
 Comment by:         re...@php.net
 Reported by:        imenem at inox dot ru
 Summary:            Insteadof not work for class method in 5.4.11
 Status:             Feedback
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   Debian GNU/Linux
 PHP Version:        5.4.11
 Assigned To:        dmitry
 Block user comment: N
 Private report:     N

 New Comment:

insteadof and 'as' bother for traits, I thought after the trait refactor, it's 
works as expected.

If we keep 'insteadof' could been used for class method as feature I'm fine:0


Previous Comments:
------------------------------------------------------------------------
[2013-02-20 07:58:32] dmi...@php.net

Yet another traits mess :(
I suppose, it worked in 5.4.4 because of mistake.
RFC and traits documentation don't say if class names may be used in context of 
"as" and "insteadof" operators.

In my opinion, class names must not be used in contest of "as".
However, their usage in context of "inseadof" may make sense (I'm not sure).
Anyway, it has to be defined in documentation first.

------------------------------------------------------------------------
[2013-02-20 07:44:12] larue...@php.net

fix attached, which fix this bug, and trigger fatal error in compile time for 
the 
test script I pasted before.

------------------------------------------------------------------------
[2013-02-20 07:41:23] larue...@php.net

The following patch has been added/updated:

Patch Name: bug64235.phpt
Revision:   1361346083
URL:        
https://bugs.php.net/patch-display.php?bug=64235&patch=bug64235.phpt&revision=1361346083

------------------------------------------------------------------------
[2013-02-20 07:39:40] larue...@php.net

The following patch has been added/updated:

Patch Name: bug64235.patch
Revision:   1361345980
URL:        
https://bugs.php.net/patch-display.php?bug=64235&patch=bug64235.patch&revision=1361345980

------------------------------------------------------------------------
[2013-02-20 07:15:37] larue...@php.net

actually, I was looking into this,  I have thought the similar fix of you, but 
unfortunatly, it is wrong, thinking of this:

<?php
class TestParentClass
{
    public function method()
    {
        print_r('Parent method');
        print "\n";
    }
}

trait TestTrait
{
    public function method()
    {
        print_r('Trait method');
        print "\n";
    }
}

class TestChildClass extends TestParentClass
{
    use TestTrait
    {
        TestParentClass::method as methodParent;
    }
}

(new TestChildClass)->methodParent();
~

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


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=64235


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

Reply via email to