Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:32882 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 53970 invoked by uid 1010); 20 Oct 2007 20:56:18 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 53954 invoked from network); 20 Oct 2007 20:56:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Oct 2007 20:56:18 -0000 Authentication-Results: pb1.pair.com smtp.mail=stas@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=stas@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.25.124.162 as permitted sender) X-PHP-List-Original-Sender: stas@zend.com X-Host-Fingerprint: 212.25.124.162 mail.zend.com Windows 2000 SP4, XP SP1 Received: from [212.25.124.162] ([212.25.124.162:13394] helo=mx1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 05/F7-03598-34B6A174 for ; Sat, 20 Oct 2007 16:56:17 -0400 Received: from us-ex1.zend.com ([192.168.16.5]) by mx1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Sat, 20 Oct 2007 22:55:16 +0200 Received: from [192.168.17.1] ([192.168.17.1]) by us-ex1.zend.com with Microsoft SMTPSVC(6.0.3790.1830); Sat, 20 Oct 2007 13:55:13 -0700 Message-ID: <471A6B32.3080401@zend.com> Date: Sat, 20 Oct 2007 13:55:14 -0700 Organization: Zend Technologies User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 To: Chuck Hagenbuch CC: internals@lists.php.net References: <20071019224202.20245u5zry52h5c8@technest.org> In-Reply-To: <20071019224202.20245u5zry52h5c8@technest.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 20 Oct 2007 20:55:13.0124 (UTC) FILETIME=[826DBA40:01C8135B] Subject: Re: [PHP-DEV] Order of class resolution with namespaces and autoload From: stas@zend.com (Stanislav Malyshev) > ::Exception, because the class resolution order seems to look like this: > > - does the class exist (_already defined_) in the current namespace? > - does the class exist in the global (non-prefixed or "::") namespace? > - then try autoload That's exactly how it works, with the amendment that only internal classes are considered on step 2. > What I think should happen is: > > - does the class exist in the current namespace? > - can the class be autoloaded with the current namespace? > - does the class exist in the global scope > - global autoload If it worked this way, you couldn't easily use global classes and old applications would be much harder to convert to namespaces. We think that using global Exception is much more frequent than defining your own Exception - and in the latter case you have the choice to name it something that is not the same as existing class, while in the latter case you do not. So we decided to make resolution rules so that it makes easier to work with the most frequent case and makes easier to work with existing code. > The other alternative would be to say that if you want to use a global > class inside a namespace you MUST prefix it with ::. I think this is We consider it not the best choice. Using of global classes is ubiquitous in current applications, always requiring :: would make it very hard to convert them to namespaced code. We think it would require much more work than just having "require_once" in places when you override the internal classes. > reasonable since if you have a namespaced file it's already not going to > work with anything before PHP 5.3, and that would remove the two The problem is not working with PHP before 5.3, the problem is using code that was written before 5.3. We try to make this code as easy as possible to upgrade, and it seems that blocking access to internal classes would not do us much good. -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com