Re: __constructor parameter limitations.
| From: | Pierre Joye | Date: | Mon, 19 Sep 2011 09:58:57 +0000 |
| Subject: | Re: __constructor parameter limitations. | ||
| 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-55537@lists.php.net to get a copy of this message | ||
On Mon, Sep 19, 2011 at 11:56 AM, Etienne Kneuss <colder@php.net> wrote:
>> There is a precondition that the abstract method enforces in such
>> prototypes, and it is:
>> - I will require at least X arguments
>> if a method implements this and defines the prototype with:
>> - I will require at least Y arguments with Y < X
>> The procondition of the subclass method is looser. And this is perfectly
>> fine.
>> You may debate whether it is "at least X" or not that the prototype
>> defines, but that's exactly what it does and how PHP w.r.t. to function
>> calls work, we have always allowed more arguments in the call than functions
>> declares.
>
> Apparently you guys are speaking about the initial implementation of an
> abstract method, while I was talking about overriding a method, which is not
> the relly same. So the above doesn't really apply.
> The initial implementation of an abstract method should match the signature,
> while overriding a method should be able to loosen the precondition in many
> ways (type hints change, less arguments, etc..), IMO.
Exactly. Abstract is a different than interface or simple extended
classes. That's something I totally fail to make clear in this lengthy
thread.
Cheers,
--
Pierre
@pierrejoye | http://blog.thepimp.net | http://www.libgd.org