Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:38416 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 83662 invoked from network); 19 Jun 2008 16:12:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jun 2008 16:12:11 -0000 Authentication-Results: pb1.pair.com header.from=saulovallory@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=saulovallory@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 66.249.82.237 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: saulovallory@gmail.com X-Host-Fingerprint: 66.249.82.237 wx-out-0506.google.com Received: from [66.249.82.237] ([66.249.82.237:32312] helo=wx-out-0506.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AC/44-63224-B558A584 for ; Thu, 19 Jun 2008 12:12:11 -0400 Received: by wx-out-0506.google.com with SMTP id s12so211853wxc.26 for ; Thu, 19 Jun 2008 09:12:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type:references; bh=aSxZcNpruQjWDktoZVyurWfN+sb+8FiDfVTCCgHMtCY=; b=Ef4gvqRE0FR6EaullIPIu35Cm+xbZN2eNtl0gnQlPzSEhbJy260w4RKvUwGmCenF1R cS5qEGmSJ+47IjeeNelCFu6bvBmAqE+cEDXL7MJP3Hr8+FUGU9Y+evgtjzMApKOfnQYz 3uqVRgBCrEDZ/Elj2d7CmZFgLOT6qa0/jEunY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:references; b=Tn9tU2tVT1Vu+PnrdZlzP7Eybnr5OScEmDPeZdL+2CW9e9i/LZvgDAW5/aHsPHIF6E bOE8KvXjVjN/tdKoQhVj0xT08leY8y1KlGkR2JFg4rtVTMUB27fu8IM+va2doXfMlMv8 1vECf8lyItYoQueQPe0Gcu8KQbuS+YGLU/dfI= Received: by 10.100.214.3 with SMTP id m3mr3540148ang.74.1213891928858; Thu, 19 Jun 2008 09:12:08 -0700 (PDT) Received: by 10.100.253.13 with HTTP; Thu, 19 Jun 2008 09:12:08 -0700 (PDT) Message-ID: Date: Thu, 19 Jun 2008 13:12:08 -0300 To: "internals Mailing List" In-Reply-To: <0489D0DE749FD2489EEB99455DEB6A7F08178226@svr-fp-exch.dalair.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_10041_20823748.1213891928847" References: <0489D0DE749FD2489EEB99455DEB6A7F08178226@svr-fp-exch.dalair.com> Subject: Re: [PHP-DEV] Overloading From: saulovallory@gmail.com ("Saulo Vallory") ------=_Part_10041_20823748.1213891928847 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline I'm developing a PHP framework and had the same issue sometimes... I think it was already discussed in the list, did you searched the archives? Saulo On Thu, Jun 19, 2008 at 9:58 AM, Tinsley, Mark wrote: > 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 > } > > 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 = 'fooFoo'; > break; > > case $Foo instanceof BooClass: > $method = '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 > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > ------=_Part_10041_20823748.1213891928847--