Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:32791 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13204 invoked by uid 1010); 15 Oct 2007 19:18:33 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 13188 invoked from network); 15 Oct 2007 19:18:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Oct 2007 19:18:33 -0000 Authentication-Results: pb1.pair.com header.from=hans.moog@mkj-computing.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=hans.moog@mkj-computing.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mkj-computing.de from 213.239.209.74 cause and error) X-PHP-List-Original-Sender: hans.moog@mkj-computing.de X-Host-Fingerprint: 213.239.209.74 web-002.server-ip.de Linux 2.4/2.6 Received: from [213.239.209.74] ([213.239.209.74:56501] helo=web-002.server-ip.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FD/76-39149-80DB3174 for ; Mon, 15 Oct 2007 15:18:33 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by web-002.server-ip.de (Postfix) with ESMTP id 73530108D037; Mon, 15 Oct 2007 21:17:03 +0200 (CEST) Received: from web-002.server-ip.de ([127.0.0.1]) by localhost (web-002.server-ip.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 03339-01; Mon, 15 Oct 2007 21:17:02 +0200 (CEST) Received: from win-001.server-ip.de (static.88-198-106-164.clients.your-server.de [88.198.106.164]) by web-002.server-ip.de (Postfix) with ESMTP id 9E331108CFED; Mon, 15 Oct 2007 21:17:02 +0200 (CEST) Date: Mon, 15 Oct 2007 21:18:23 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Message-ID: <7C37FF3A0196094F95430BA95952032211B7D2@s1.mkj.lan> In-Reply-To: <002f01c80f5b$d645d340$15b2a8c0@unterwegs> Content-class: urn:content-classes:message X-MS-Has-Attach: X-MimeOLE: Produced By Microsoft Exchange V6.5 X-MS-TNEF-Correlator: Thread-Topic: [PHP-DEV] Method overloading by method signature thread-index: AcgPXN0oIZFJDBc7TSS7N1SqsfB+PgAAGkzg References: <7C37FF3A0196094F95430BA95952032211B7C5@s1.mkj.lan> <7C37FF3A0196094F95430BA95952032211B7C7@s1.mkj.lan> <72129346.20071014092922@marcus-boerger.de> <7C37FF3A0196094F95430BA95952032211B7CC@s1.mkj.lan> <19939840.20071014231353@marcus-boerger.de> <002f01c80f5b$d645d340$15b2a8c0@unterwegs> To: "Timm Friebe" Cc: X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at mkj-computing.com, mkj-computing.de Subject: AW: [PHP-DEV] Method overloading by method signature From: hans.moog@mkj-computing.de ("Hans Moog") When it would be: =3D=3D function xpath(DomDocument $arg) { return new DomXPath($arg); } function xpath(XmlTree $arg) { return new DomXPath($this->loadXML($arg->getSource()))); } function xpath(string $arg) { return new DomXPath($this->loadXML($arg)); } =3D=3D =20 (since when method overloding by sigantures wer put into php, scalar = types should be possible, too, shouldn't they?) I would prefer the second one because I understand the behaviour much = faster than analyzing the if switch (and this if switch is really simple = to understand because there is only one command in every block). The = second reason for me to select the second version is, that I am able to = write better documentation for each behaviour (although, in this = situation there isn't that much to be commented). =20 -----Urspr=FCngliche Nachricht----- Von: Timm Friebe [mailto:thekid@thekid.de]=20 Gesendet: Montag, 15. Oktober 2007 20:47 An: internals@lists.php.net Betreff: Re: [PHP-DEV] Method overloading by method signature Hi, [...] > Later we added type hints to help code readability. Let me jump at this: =3D=3D function xpath($arg) { if ($arg instanceof DomDocument) { return new DomXPath($arg); } else if ($arg instanceof XmlTree) { return new DomXPath($this->loadXML($arg->getSource())); } else if (is_string($arg)) { return new DomXPath($this->loadXML($arg)); } else { throw new IllegalArgumentException('Unsupported argument type'); } } =3D=3D vs. =3D=3D function xpath(DomDocument $arg) { return new DomXPath($arg); } function xpath(XmlTree $arg) { return new DomXPath($this->loadXML($arg->getSource()))); } function xpath($arg) { // Untyped =3D default if (!is_string($arg)) { throw new IllegalArgumentException('Unsupported argument type'); } return new DomXPath($this->loadXML($arg)); } =3D=3D If we consider the readability argument only: Which one of the above = more=20 readable? You decide:) - Timm=20 --=20 PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php