Edit report at https://bugs.php.net/bug.php?id=55554&edit=1
ID: 55554
User updated by: ryan at zuttonet dot com
Reported by: ryan at zuttonet dot com
Summary: Trait methods overriding legacy constructors
Status: Open
Type: Bug
Package: *Programming Data Structures
Operating System: Ubuntu
PHP Version: 5.4.0alpha3
Block user comment: N
Private report: N
New Comment:
Apologies; the literal expected output for the provided test scripts should be:
"this is a constructor"
As this is the output when using __construct() in the class definition instead of
a legacy-style constructor.
Previous Comments:
------------------------------------------------------------------------
[2011-08-31 15:49:30] ryan at zuttonet dot com
Description:
------------
For the sake of consistency, exactly one of the following should be implemented:
1. Trait methods should be able to override __construct definitions
2. Trait methods should not be able to override legacy constructor definitions
Currently, trait methods are not able to override __construct
definitions. Trait methods are able to override legacy constructor definitions.
Test script:
---------------
Here are two test cases that will reproduce the defect:
https://gist.github.com/1183844
Expected result:
----------------
A trait-level __construct method (or a trait-level method aliased as __construct)
should not be able to override any type of constructor in a class
Actual result:
--------------
Fatal error: Call to private SomeClass::__construct() from invalid context
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55554&edit=1