Re: E_STRICT on inheritance + method parameter defaults?

From: Date: Wed, 21 Sep 2005 20:37:01 +0000
Subject: Re: E_STRICT on inheritance + method parameter defaults?
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-19112@lists.php.net to get a copy of this message
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_. And I don't really see the point either as U::f works with all code previously using T::f. Even more so for function V::f($x,$y=false) to provide extended functionality to T::f($x) for code which knows about it. And why would changing the default value be ok in your book? But then again I'm not an OO purist and I don't (have to) use E_STRICT. - Chris

« previous php.internals (#19112) next »