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

 ID:                 55424
 Updated by:         g...@php.net
 Reported by:        Jared dot Williams1 at ntlworld dot com
 Summary:            Fatal error when calling a method from a trait that
                     is defined in parent class
-Status:             Open
+Status:             Closed
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   Ubuntu x64 11.04
 PHP Version:        5.4SVN-2011-08-15 (SVN)
-Assigned To:        
+Assigned To:        gron
 Block user comment: N
 Private report:     N

 New Comment:

This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

Yes, I introduced that regression in svnrev, 314943 and it should now be fixed 
per  
314981.
http://svn.php.net/viewvc?view=revision&revision=314981

Looks like there is a big hole in our test coverage :-/
Thanks for reporting!


Previous Comments:
------------------------------------------------------------------------
[2011-08-15 22:16:53] g...@php.net

Automatic comment from SVN on behalf of gron
Revision: http://svn.php.net/viewvc/?view=revision&revision=314981
Log: Bug #55424 Fatal error when calling a method from a trait that is defined 
in parent class and required by using an abstract method in the trait.
# The method got unconditionally deleted from the class, since it was assumed 
that we override it, but we did not in case of abstract methods coming from a 
trait. Thus, dont delete when we try to merge in an abstract method.

------------------------------------------------------------------------
[2011-08-15 21:07:24] php-bugs at majkl578 dot cz

With the same test script, I'm getting this error:
Fatal error: Cannot make non abstract method Input::setAttribute() abstract in 
class Text in /www/temp.php on line 27

------------------------------------------------------------------------
[2011-08-15 15:56:49] Jared dot Williams1 at ntlworld dot com

Description:
------------
A fatal error occurs when a method is called from a trait, which is implemented 
in the parent class of the class that utilises the trait.

Feels related to #55355 that was fixed.

Test script:
---------------
<?php

        trait Required
        {
                function setRequired()
                {
                        $this->setAttribute('required', true);
                        return $this;
                }
                
                abstract function setAttribute($name, $value);
        }       
        
        class Input
        {
                protected $attributes = [];
                
                function setAttribute($name, $value)
                {
                        $this->attributes[$name] = $value;
                }
        }
        
        class Text extends Input
        {
                use Required;
        }
        
        $t = new Text();
        $t->setRequired();



Expected result:
----------------
No fatal error.

Actual result:
--------------
PHP Fatal error:  Call to undefined method Text::setAttribute() in 
/home/jared/Temp/trait2.php on line 7

Fatal error: Call to undefined method Text::setAttribute() in 
/home/jared/Temp/trait2.php on line 7



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



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

Reply via email to