Re: Cannot call constructor
| From: | Ferenc Kovacs | Date: | Fri, 24 May 2013 12:11:10 +0000 |
| Subject: | Re: Cannot call constructor | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-67487@lists.php.net to get a copy of this message | ||
On Thu, May 23, 2013 at 11:32 PM, Stas Malyshev <smalyshev@sugarcrm.com>wrote:
> Hi!
>
> > Right now, to avoid this situation, you have to do:
> > if (method_exists(get_parent_class(), '__construct'))
> > parent::__construct();
> >
> > If you don't check for the method existing, you get:
> > Fatal error: Cannot call constructor ...
>
> This makes a lot of sense. I think we also discussed this idea some time
> ago, but it didn't go anywhere that time...
last time it was discussed on the list:
http://www.mail-archive.com/internals@lists.php.net/msg50504.html
to summarize it:
Etienne was arguing that for the concrete example (Spl classes) it would be
better to make sure that the object is properly initialized so having a
constructor in the spl classes.
Anthony was the only one who was against the idea of removing the error
when you call a parent constructor which doesn't (explicitly) have one.
Otherwise everybody else seemed to agree with the above change and only the
implementation was discussed:
- we should remove the error completelly
- we should make the error less serious (please don't do this)
- we should always create a common ancestor for every class by default
which have an empty constructor/destructor
- we should always create an empty constructor/desctructor for every class
without it.
So maybe we could discuss this and based on the feedback create an rfc
(with or without a vote for the alternative implementations).
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu