Re: [RFC] Default constructors
| From: | Alexander Kurilo | Date: | Tue, 18 Nov 2014 20:20:34 +0000 |
| Subject: | Re: [RFC] Default constructors | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-78954@lists.php.net to get a copy of this message | ||
On 18/11/14 14:00, Stanislav Malyshev wrote:
Hi!However, Java lets one have as many constructors as one wants because Java supports overloading and there's a default constructor that takes no arguments. Does it *really* make sense for PHP? What if that parent class 'Animal' from your example introduces a constructor that accepts, say, bothThanks for bringing this up and working on the patch. Last time we discussed this(http://www.serverphorums.com/read.php?7,712222,712635), there were a couple of people including Anthony and Sanford who were agains this feature arguing that it would encourage bad practices so I think itObviously, I disagree with that. I do not see any bad practices it encourages - if anything, it encourages the good practice of always calling parent ctor, practice considered so good by many that some languages make it mandatory.
$owner and $what as mandatory arguments? parent::__construct() call in a descendant will appear broken (unintentionally, I suppose), won't it? That'll work in Java just fine, though.