Re: [RFC] Remove PHP 4 Constructors

From: Date: Sat, 17 Jan 2015 19:40:03 +0000
Subject: Re: [RFC] Remove PHP 4 Constructors
References: 1 2 3 4 5 6 7 8 9 10 11 12 13  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On 17/01/2015 18:33, Todd Ruth wrote:
As already mentioned I think as an end result we shouldn't have two
ways to define constructors. Given that PHP already prefers the new-style constructors I've proposed that we work towards dropping the old-style, it's just down to a matter of how. I've been following these threads for about 10 years and beg that php internals continues to "live and let live". There have been many, many threads over the years from what I would call (with obvious bias) "OO fundamentalists". They seem to be at war with code that is "bad form".
This is an argument that comes up a lot, and it has some merit, sometimes. I don't think using __construct over named-method for constructors really has anything to do with "OOP fundamentalism"; it was a design change to make certain things simpler (like parent::__construct), and more consistent (all reserved magic methods begin with __, so any method not beginning with that is safe to use however you like).
In the global cost/benefit analysis I don't see that the benefits of purifying OO outweigh the costs.
Not everything is a matter of code style - supporting legacy features comes at a cost in complexity, and sometimes even performance. Whenever new features are added - such as the ability to call parent::__construct when the parent doesn't declare a constructor explicitly - decisions have to be made on how they interact with old features - such as PHP4-style constructors. And simply by having an accumulation of old features, the codebase is larger, harder to understand, harder to change, and has more surface area for bugs. Deprecating a feature or raising an E_STRICT doesn't, of course, reduce this complexity by itself - indeed, it slightly increases it - but it paves the way for a future version to decide that this feature is no longer supported, and can be removed in order to improve the rest of the engine. So, you are quite right to highlight the costs of doing this, and they may well outweigh the benefits in this case. However, you are wrong to assume that the only benefit to be weighed is "purifying OO". Regards, -- Rowan Collins [IMSoP]

Thread (115 messages)

« previous php.internals (#80707) next »