Re: Parameter checking in 5.2

From: Date: Tue, 26 Sep 2006 19:46:43 +0000
Subject: Re: Parameter checking in 5.2
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-25838@lists.php.net to get a copy of this message
Personally I don't need the strict OO checks for matching parameter lists at all, but as long as they are E_STRICT (or the like) I have no problem with them being done. Nevertheless I would like to relax them just a tiny little bit for signature changes not having an impact of object compatibility.
I agree that allowing to extend method signature (albeit with notice) is a good thing. You could do a number of nice things with it like flexible interfaces receiving variable parameters - still staying with OO. E.g., you can do patterns like this: abstract class Processor() { abstract protected function process(); private function prepare() { /// do something } public function prepare_and_process(/* variable args */) { $this->prepare(); $this->process(/* some args */); } } And extends it overriding only process() function having concrete arguments. Of course, not everybody wants it - some would miss strict control on process parameters - but I don't see why it should not be possible in PHP, for those who wants it. That's why PHP is a dynamic language, I think. Right now if I remove abstract from process() method I can do it - but why couldn't I do it with abstract too? Interfaces don't exactly play nice with it since you can not add code to the interface and can not define visibility for methods.

« previous php.internals (#25838) next »