On Mon, Sep 19, 2011 at 11:32 AM, Gustavo Lopes <glo...@nebm.ist.utl.pt> wrote: > Em Mon, 19 Sep 2011 10:18:50 +0100, Stas Malyshev <smalys...@sugarcrm.com> > escreveu: > >> On 9/19/11 2:12 AM, Gustavo Lopes wrote: >>> >>> Arbitrary as it may be, it's nevertheless reasonably arbitrated given how >>> little useful it is to just ignore arguments and how likely it is to a >>> mistake. >> >> It is not little useful and it is not likely to make such mistake without >> immediately being notified and corrected. I don't know how you make these >> assumptions or what they are based on - could you please bring some >> evidence? > > It would obviously be hard to produce such evidence. Measuring how common > a mistake is very difficult without some study to that effect since those > mistakes are steeply underrepresented in the public PHP code corpus (i.e. > they get fixed). And measuring how common overrides with less arguments > are would still require relatively complex code analysis. > > So, no, I cannot prove the assertions behind my argument, I can only say I > believe them to be plausible. > >>> And I don't buy the func_get_args() argument. Why would anyone use >>> func_get_args for anything other than variadic functions?... I certainly >>> don't. >> >> So you say if you personally don't use something in PHP nobody should use >> it? >> And, BTW, what's wrong with variadic functions (i.e., ones accepting >> variable number of arguments)? Such functions are commonplace in PHP. > > The thing if you introduce func_get_args() to the argument, any discussion > about enforcing signatures becomes meaningless. One could argue this > should be allowed: > > class A { > function foo() {} > } > > class B extends A { > function foo($a) {} > } > > Because for all we know the implementation of A::foo() could have: > > function foo() { > $a = func_get_args()[0]; > } yeah, but you can't know from the method signature that there is, or isn't any place, where the parent method is called without arguments, but your class would be incompatible there.
You aren't supposed to know at all time that what does the Superclass class/method internally or how is it used at all time(where it is called, with how many arguments, etc), but you get a guarantee that all call for that method has to be compatible with it's method signature, so as long as your method signature also compatible with it, you should be fine to change it. -- Ferenc Kovács @Tyr43l - http://tyrael.hu -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php