Re: [RFC] Remove PHP 4 Constructors
| From: | Levi Morrison | Date: | Tue, 25 Nov 2014 17:38:51 +0000 |
| Subject: | Re: [RFC] Remove PHP 4 Constructors | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-79171@lists.php.net to get a copy of this message | ||
On Fri, Nov 21, 2014 at 11:20 AM, Levi Morrison <levim@php.net> wrote:
>> BTW, old constructor has problem with traits (is this mentioned already?)
>>
>> http://3v4l.org/KZKXo
>>
>> I suppose nobody is using this side effect in production code, but
>> there would be number of users who are confused by this behavior.
>
> If I remember the source code correctly, this should be considered a
> bug. I will definitely look into this, regardless of the outcome of
> this RFC.
It turns out I was incorrect; based on the code and the phpt tests I
would not say this is a bug.
However, traits do check for "colliding constructors" and emit a fatal
error when having both a method named after the class and a
__construct method: http://3v4l.org/YHAtA. Note that it
doesn't matter
who declares the old and new style constructors:
http://3v4l.org/ZOeoY. When defining only the same style of
constructor in both there is no error: http://3v4l.org/H1jG1 and
http://3v4l.org/m5D7p.
I will lift this restriction in the RFC for both PHP 5.7 and 7 and
update the implementation when I can.