Re: __constructor parameter limitations.
| From: | Stas Malyshev | Date: | Tue, 20 Sep 2011 19:35:44 +0000 |
| Subject: | Re: __constructor parameter limitations. | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-55566@lists.php.net to get a copy of this message | ||
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 AConsider 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