Re: __constructor parameter limitations.
| From: | Ferenc Kovacs | Date: | Fri, 23 Sep 2011 08:23:25 +0000 |
| Subject: | Re: __constructor parameter limitations. | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-55596@lists.php.net to get a copy of this message | ||
On Tue, Sep 20, 2011 at 9:35 PM, Stas Malyshev <smalyshev@sugarcrm.com> wrote:
> Hi!
>
> On 9/20/11 12:07 PM, Reindl Harald wrote:
>>
>> but it is not logical
>>
>> foo() in B can do anything with $a before or after parent::foo()
>> and the caller does not need to know at any point that B
>> has anything to do with the class A
>
> Consider this code:
>
> function doFoo(A $a) {
> $a->foo();
> }
>
> It's fine, right? Since A::foo() signature fits.
> Now consider this code:
>
> $a = new B(); // B extends A, it's OK, right?
> doFoo($a); // oops, $a->foo() breaks!
>
> This code would break since B::foo() requires a parameter.
> --
> Stanislav Malyshev, Software Architect
> SugarCRM: http://www.sugarcrm.com/
> (408)454-6900 ext. 227
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
A little bit off-topic, but maybe we could also discuss/fix this:
https://bugs.php.net/bug.php?id=43200
http://groups.google.com/group/symfony-devs/browse_thread/thread/3fc16ba601045551
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu