Re: Explicit constructor call and polymorphic dispatch
| From: | Fleshgrinder | Date: | Sat, 14 Jan 2017 18:24:24 +0000 |
| Subject: | Re: Explicit constructor call and polymorphic dispatch | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-97756@lists.php.net to get a copy of this message | ||
On 1/14/2017 7:10 PM, Michał Brzuchalski wrote:
> AFAIK parent is a speciual scope which help refers to variables and
> functions in base classe
> http://php.net/manual/kr/keyword.parent.php
> So it looks like proposing your syntax could lead to huge BC break.
> In other languages (eg. Java) there is special syntax quite similar with
>
super($a, $b) call.
>
super **is** Java’s parent keyword.
There is definitely no breaking change here by enabling parent() as an
alternative to parent::__construct() since it has no functionality at
all right now. As a matter of fact, PHP currently aborts with a fatal error:
```
Fatal error: Call to undefined function parent() in
```
Reversing keywords in the global scope is done regularly in PHP minor
versions, hence, that would not be a problem either.
I see only one single problem, users might expect that parent()
actually should call parent::__invoke(). However, that is not the case
right now and nobody ever asked for it plus it is a little used feature
anyways which does not require special treatment (imho).
Regarding the fatal error on a missing constructor implementation in the
parent. I fully agree that this should be possible.
--
Richard "Fleshgrinder" Fussenegger