Re: [RFC] Remove PHP 4 Constructors
| From: | Tony Marston | Date: | Mon, 19 Jan 2015 10:39:41 +0000 |
| Subject: | Re: [RFC] Remove PHP 4 Constructors | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-80797@lists.php.net to get a copy of this message | ||
"Andrea Faulds" wrote in message news:3C77D1E5-ACF1-442D-BC84-59E49EFD6A5E@ajf.me...
That is precisely why I said that "parent::__construct()" should still be legal.On 19 Jan 2015, at 10:05, Tony Marston <TonyMarston@hotmail.com> wrote: "Marcio Almada" wrote in message news:CAOsHV+uhO3OVS-BEQMDjomz4SDWOYjN7ZNMCqMT8BYyNuGQVXw@mail.gmail.com...Inheritance is also an OO principle, and typically a derived class’s constructor will call the parent’s.Surely, according to the principles of OO, a class constructor should ONLY be called when the class is constructed/instantiated into an object via the "new" verb? Google for "class constructor" and you will see all those links which say the same thing.Perhaps there should be a new rule which says that invoking a constructor with anything other than "new" or "parent::__contruct()" should be illegal, in which case this situation would generate an error.Now this would break a lot of code that $obj->__construct(); or $this->__construct(); And I've seen a lot of it.
-- Andrea Faulds http://ajf.me/-- Tony Marston