Re: E_STRICT on inheritance + method parameter defaults?
| From: | Marcus Boerger | Date: | Wed, 21 Sep 2005 22:28:07 +0000 |
| Subject: | Re: E_STRICT on inheritance + method parameter defaults? | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-19114@lists.php.net to get a copy of this message | ||
Hello Christian,
Wednesday, September 21, 2005, 10:37:01 PM, you wrote:
> Marcus Boerger wrote:
>> marcus@zaphod /usr/src/PHP_5_1 $ php -r 'class T{function f($x){}} class U extends
>> T{function f($x=2){}}'
>> make: `sapi/cli/php' is up to date.
>>
>> Strict Standards: Declaration of U::f() should be compatible with that of T::f() in Command
>> line code on line 1
>> marcus@zaphod /usr/src/PHP_5_1 $ php -r 'class T{function f($x=1){}} class U extends
>> T{function f($x=2){}}'
>> make: `sapi/cli/php' is up to date.
>>
>> The above shows php is correct here.
> In my opinion Sean didn't ask whether PHP behaves that way but _why_.
The above example show that adding a default result value in a derived class
results in an incompatible signature while changing it works as expected.
Best regards,
Marcus