Re: AW: [PHP-DEV] Method overloading by method signature
| From: | Christian Schneider | Date: | Tue, 16 Oct 2007 09:45:03 +0000 |
| Subject: | Re: AW: [PHP-DEV] Method overloading by method signature | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-32809@lists.php.net to get a copy of this message | ||
Hans Moog wrote:
When it would be: == function xpath(DomDocument $arg) {function xpathFromDom($arg) { return new DomXPath($arg); } function xpathFromTree($arg) { return new DomXPath($this->loadXML($arg->getSource()))); } function xpathFromString($arg) { return new DomXPath($this->loadXML($arg)); } Works perfectly well. And you don't even need to document them because the names speak for themselves. A much simpler (and clearer) solution IMHO. If you want an OO way I'd prefer something like $xpath = $obj->getXPath(); to $xpath = $this->xpath($obj); anyway. This doesn't work with basic types like strings but having a special case there is not a problem IMHO as using those two interchangeably will lead to other problems anyway. - Chrisreturn new DomXPath($arg);} function xpath(XmlTree $arg) {return new DomXPath($this->loadXML($arg->getSource())));} function xpath(string $arg) {return new DomXPath($this->loadXML($arg));} ==