Re: [RFC] Remove PHP 4 Constructors

From: Date: Thu, 15 Jan 2015 16:39:22 +0000
Subject: Re: [RFC] Remove PHP 4 Constructors
References: 1  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
Hi everyone,

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.
I still think this (and other) BC breaks should be avoided if we want to maximize PHP7 adoption, but I've started working on this: https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/970 which is a patch to php-cs-fixer that would be helpful to ease my (and other's) pain in case the RFC passes. I've tried using Andrea's own work and nikita's php-parser and good results quickly, but ended up switching due to the lack of whitespace support. Cheers -- Matteo Beccati Development & Consulting - http://www.beccati.com/

Thread (115 messages)

« previous php.internals (#80567) next »