Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:21376 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42482 invoked by uid 1010); 3 Jan 2006 21:50:10 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 42467 invoked from network); 3 Jan 2006 21:50:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Jan 2006 21:50:10 -0000 X-Host-Fingerprint: 81.169.182.136 ajaxatwork.net Linux 2.4/2.6 Received: from ([81.169.182.136:43726] helo=strato.aixcept.de) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id AD/EA-34518-191FAB34 for ; Tue, 03 Jan 2006 16:50:09 -0500 Received: from [192.168.1.3] (dslb-084-063-009-174.pools.arcor-ip.net [84.63.9.174]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by strato.aixcept.de (Postfix) with ESMTP id 6E05735C1B6; Tue, 3 Jan 2006 22:50:06 +0100 (CET) Date: Tue, 3 Jan 2006 22:50:24 +0100 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <1462157471.20060103225024@marcus-boerger.de> To: Andrew Yochum Cc: php internals In-Reply-To: <20060103213332.GG26280@desario.homelinux.net> References: <20060103205728.GF26280@desario.homelinux.net> <1852411085.20060103220656@marcus-boerger.de> <20060103213332.GG26280@desario.homelinux.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] __call overload detection From: helly@php.net (Marcus Boerger) Hello Andrew, you do not implement __call for a method but you deal with the method name in any sense you like, which also includes ignoring specific __call invocations. Reflection gives you the ability to check whetehr a function is being physically available. If you need more it is up to you to provide the infrastructure. Remember we will not in anyway allow __call to handle inheritance. regards marcus Tuesday, January 3, 2006, 10:33:32 PM, you wrote: > 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 Best regards, Marcus