Re: [RFC] Remove PHP 4 Constructors
| From: | Nikita Popov | Date: | Fri, 21 Nov 2014 16:22:49 +0000 |
| Subject: | Re: [RFC] Remove PHP 4 Constructors | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-79086@lists.php.net to get a copy of this message | ||
On Wed, Nov 19, 2014 at 12:11 AM, Levi Morrison <levim@php.net> wrote:
> Dear Internals,
>
> I am proposing an RFC[1] to remove PHP 4 constructors in PHP 7. If
> accepted, methods with the same name as their defining class will no
> longer be recognized as constructors. As noted in the RFC, there are
> already many situations where we do not recognize these methods as
> constructors, such as in namespaces and traits and when `function
> __construct` is also present.
>
> Andrea Faulds has kindly written a utility that identifies when a PHP
> 4 constructor is defined[2]. It does not automatically change the code
> for liability reasons. The utility PHPMD[3] can also detect this but
> has a false positive when
__construct is also defined.
>
> Cheers,
> Levi Morrison
>
I'm +1 on this RFC.
I've lost count of the number of times I had to debug some "completely
impossible" behavior I got while writing quick testing code (which is
obviously not namespaced), because I accidentally created a class "Test"
with a method "test" or similar.
I'm also pretty confident that we can provide robust tooling for
automatically porting code to new constructors - including updating
parent:: call references if need be. Don't see how that would be a
particular issue here.
Nikita