Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:21375 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37085 invoked by uid 1010); 3 Jan 2006 21:37:14 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 37070 invoked from network); 3 Jan 2006 21:37:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Jan 2006 21:37:14 -0000 X-Host-Fingerprint: 147.202.47.146 cruiser.plexpod.net Linux 2.5 (sometimes 2.4) (4) Received: from ([147.202.47.146:48090] helo=cruiser.plexpod.net) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 51/8A-34518-A8EEAB34 for ; Tue, 03 Jan 2006 16:37:14 -0500 Received: from dsl254-067-175.nyc1.dsl.speakeasy.net ([216.254.67.175] helo=desario.homelinux.net) by cruiser.plexpod.net with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.52) id 1Ettq2-0005rT-VC; Tue, 03 Jan 2006 16:37:03 -0500 Received: by desario.homelinux.net (sSMTP sendmail emulation); Tue, 3 Jan 2006 16:33:32 -0500 Date: Tue, 3 Jan 2006 16:33:32 -0500 To: Marcus Boerger Cc: php internals Message-ID: <20060103213332.GG26280@desario.homelinux.net> References: <20060103205728.GF26280@desario.homelinux.net> <1852411085.20060103220656@marcus-boerger.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1852411085.20060103220656@marcus-boerger.de> User-Agent: Mutt/1.5.11 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cruiser.plexpod.net X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - plexpod.com X-Source: X-Source-Args: X-Source-Dir: Subject: Re: [PHP-DEV] __call overload detection From: andrew@plexpod.com (Andrew Yochum) Hi Marcus, On Tue, Jan 03, 2006 at 10:06:56PM +0100, Marcus Boerger wrote: > Hello Andrew, > > right now you can use reflection. > > marcus The reflection APIs do not help I believe. Consider that one may only want __call to respond to a computable set of overloaded method names. Right now, is_callable returns true for any requested method if __call is implemented by the object. Unless I have missed some magic that the Reflection APIs can do, they don't apply here. Consider the following: class a { var $callables = array('foo'); function __call($name, $args) { if ($this->__is_callable($name)) return 'good call'; else return 'bad call'; } function __is_callable($name) { return in_array($name, $this->callables); } } $a = new a(); print "is_callable: " . is_callable(array($a,'foo'),false, $callable) . " as $callable \n"; // prints: is_callable: 1 as a::foo // OK print "is_callable: " . is_callable(array($a,'bar'),false, $callable) . " as $callable \n"; // result: is_callable: 1 as a::bar // desired: is_callable: 0 as // or some other similar behavior if __is_callable is implemented If one were to implement a reflection-like method called __iscallable, you could get this functionality, but couldn't count on other's code using the same convention. Another downside to doing it yourself is that every call to a method must first check __is_callable - this could be handled by the language upon a method call. If I feel it would be a good idea to implement this in the lanaguage for standardization and simplicity. Regards, Andrew -- Andrew Yochum Plexpod andrew@plexpod.com 718-360-0879