Re: Method overloading by method signature
| From: | Johannes Schlüter | Date: | Mon, 15 Oct 2007 19:24:10 +0000 |
| Subject: | Re: Method overloading by method signature | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-32792@lists.php.net to get a copy of this message | ||
Hi,
On Mon, 2007-10-15 at 20:47 +0200, "Timm Friebe" wrote:
> function xpath(DomDocument $arg) {
> return new DomXPath($arg);
> }
>
> function xpath(XmlTree $arg) {
> return new DomXPath($this->loadXML($arg->getSource())));
> }
>
> function xpath($arg) { // Untyped = default
> if (!is_string($arg)) {
> throw new IllegalArgumentException('Unsupported argument type');
> }
> return new DomXPath($this->loadXML($arg));
> }
>
> ==
>
> If we consider the readability argument only: Which one of the above more
> readable? You decide:)
Allowing an untyped version next to a typed one is imo the worst thing
one can do: f I want to read the code and first see the untyped
implementation I certainly go crazy while trying to debug the code.
johannes