Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:21380 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 74314 invoked by uid 1010); 3 Jan 2006 23:54:29 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 74299 invoked from network); 3 Jan 2006 23:54:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Jan 2006 23:54:28 -0000 X-Host-Fingerprint: 80.74.107.235 mail.zend.com Linux 2.5 (sometimes 2.4) (4) Received: from ([80.74.107.235:39080] helo=mail.zend.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 8A/BD-34518-4BE0BB34 for ; Tue, 03 Jan 2006 18:54:28 -0500 Received: (qmail 1624 invoked from network); 3 Jan 2006 23:54:24 -0000 Received: from localhost (HELO ?127.0.0.1?) (127.0.0.1) by localhost with SMTP; 3 Jan 2006 23:54:24 -0000 Message-ID: <43BB0EAD.60708@zend.com> Date: Tue, 03 Jan 2006 15:54:21 -0800 User-Agent: Mozilla Thunderbird 1.0.5 (Windows/20050711) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Marcus Boerger CC: php internals References: <20060103205728.GF26280@desario.homelinux.net> <1852411085.20060103220656@marcus-boerger.de> <20060103213332.GG26280@desario.homelinux.net> <1462157471.20060103225024@marcus-boerger.de> In-Reply-To: <1462157471.20060103225024@marcus-boerger.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] __call overload detection From: mike.n@zend.com (Mike Naberezny) Marcus Boerger wrote: > If you need more it is up to you to provide > the infrastructure. Remember we will not in anyway allow __call to handle > inheritance. Hi Marcus, If one is determined enough, at least visibility can be faked by exception trace introspection. Below demonstrates protected, replace __CLASS__ with get_class($this) for private. I see very little or no real world application for this and the procedure is quite expensive. nonexistant; } public function __get($offset) { try { throw new Exception(); } catch (Exception $e) { $trace = $e->getTrace(); $caller = isset($trace[2]['class']) ? $trace[2]['class'] : null; if ($caller === null || $caller != __CLASS__ && !is_subclass_of($caller, __CLASS__)) { throw new Exception('Access to protected ' .__CLASS__. '::' .$offset. ' from context '. $caller); } } return 'hello'; } } $t = new Test(); // hello echo $t->nonexistant; // exception ?> Mike