Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:38389 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 60045 invoked from network); 19 Jun 2008 12:59:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jun 2008 12:59:35 -0000 Authentication-Results: pb1.pair.com smtp.mail=MTinsley@dallasairmotive.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=MTinsley@dallasairmotive.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain dallasairmotive.com from 66.138.198.142 cause and error) X-PHP-List-Original-Sender: MTinsley@dallasairmotive.com X-Host-Fingerprint: 66.138.198.142 66-138-198-142.dallasairmotive.com Windows 2000 SP4, XP SP1 Received: from [66.138.198.142] ([66.138.198.142:30213] helo=svr-fp-exch.dalair.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9E/69-10717-6385A584 for ; Thu, 19 Jun 2008 08:59:34 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Date: Thu, 19 Jun 2008 07:58:37 -0500 Message-ID: <0489D0DE749FD2489EEB99455DEB6A7F08178226@svr-fp-exch.dalair.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Overloading Thread-Index: AcjR9+8OaT1kZK9+R+aH/GL3nW8F1gAFBhiw To: Subject: Overloading From: MTinsley@dallasairmotive.com ("Tinsley, Mark") What about the addition of overloading for PHP 6? I am not totally up to date on the developments of the parameter type hints. I briefly read the meeting minutes for PHP 6. What about with the type hints we have now? class moo { public static function foo(FooClass $FooVar) { // do something=20 } public static function foo(BooClass $BooVar) { // do something } } I have a project where we had to do a sort of pseudo overloading Class moo { /** * Accept the superclass or any of its sub classes */ public static function foo(FooSuperClass $Foo) { switch (true) { case $Foo instanceof FooClass: $method =3D 'fooFoo'; break; case $Foo instanceof BooClass: $method =3D 'fooBoo'; break; default: throw new Exception('Unrecognized type: ' . get_class($Foo)); break; } call_user_func(array(self, $method), $Foo); } private static function fooFoo(FooClass $FooVar) { // do something } private static function fooBoo(BooClass $BooVar) { // do something } } Mark