Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:59770 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 56902 invoked from network); 12 Apr 2012 01:06:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Apr 2012 01:06:40 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 67.192.241.203 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 67.192.241.203 smtp203.dfw.emailsrvr.com Linux 2.6 Received: from [67.192.241.203] ([67.192.241.203:33419] helo=smtp203.dfw.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3D/0C-23245-E9A268F4 for ; Wed, 11 Apr 2012 21:06:39 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp20.relay.dfw1a.emailsrvr.com (SMTP Server) with ESMTP id 97B92258377; Wed, 11 Apr 2012 21:06:35 -0400 (EDT) X-Virus-Scanned: OK Received: by smtp20.relay.dfw1a.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id 4981525815A; Wed, 11 Apr 2012 21:06:35 -0400 (EDT) Message-ID: <4F862A9A.9030602@sugarcrm.com> Date: Wed, 11 Apr 2012 18:06:34 -0700 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:11.0) Gecko/20120313 Thunderbird/11.0 MIME-Version: 1.0 To: Galen Wright-Watson CC: "internals@lists.php.net" References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Access by siblings of (abstract) protected methods From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > handler, which is why it behaves differently from normal methods. In the > time that I looked, I couldn't find where the access behavior for > __construct and __destruct was controlled in the source code. Access for functions is defined by zend_check_protected() and in zend_std_get_method(), this code: if (UNEXPECTED(!zend_check_protected(zend_get_function_root_class(fbc), EG(scope)))) { > In summary: should abstract protected constructors be inaccessible by > siblings, as is true of __clone and __destruct? Should __construct, __clone > and __destruct always be accessible in relatives, as is true of other > methods? Depending on the answers, there could be a documentation issue, or > bugs. In general, function defined in base class should be accessible to all siblings of that class. The rationale behind it is that if you define function (even abstract) in your base class, you saying it will be available to any instance (including extended ones) of this class. So any descendant of this class can use it. Now, I'm not sure why non-abstract ctors don't work this way - may be an artifact of ctor being special function unlike all others. Needs to be checked further in the code, I'll try to do it a bit later. As for __clone, it may be a bug seeing that the same code in zend_std_get_method() uses zend_get_function_root_class() but zend_vm_def code does not. I don't see much reason why it is not there. Same story with __destruct which is zend_objects_destroy_object() - looks like zend_get_function_root_class() is missing there too. I'll double check but from cursory look I see no reason why it's not there. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227