Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:33919 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 56727 invoked by uid 1010); 11 Dec 2007 09:01:40 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 56712 invoked from network); 11 Dec 2007 09:01:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Dec 2007 09:01:40 -0000 Authentication-Results: pb1.pair.com header.from=dz@bitxtender.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=dz@bitxtender.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain bitxtender.com from 80.237.132.12 cause and error) X-PHP-List-Original-Sender: dz@bitxtender.com X-Host-Fingerprint: 80.237.132.12 wp005.webpack.hosteurope.de Received: from [80.237.132.12] ([80.237.132.12:56310] helo=wp005.webpack.hosteurope.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8E/EC-58921-3F15E574 for ; Tue, 11 Dec 2007 04:01:40 -0500 Received: from dslb-088-064-090-129.pools.arcor-ip.net ([88.64.90.129] helo=localhost); authenticated by wp005.webpack.hosteurope.de running ExIM using esmtpsa (TLSv1:RC4-SHA:128) id 1J20ze-0007It-Td; Tue, 11 Dec 2007 10:01:35 +0100 Cc: "Sam Barrow" , Message-ID: To: Matthias Pigulla In-Reply-To: <00A2E2156BEE8446A81C8881AE117F199A0715@companyweb> Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Apple Message framework v915) Date: Tue, 11 Dec 2007 10:01:34 +0100 References: <11970653983080000@9866357972520000.9866341568840000> <475BDDF1.7040605@ctindustries.net> <1723341090.20071210220025@marcus-boerger.de> <1197323296.3922.5.camel@sbarrow-desktop> <00A2E2156BEE8446A81C8881AE117F199A0715@companyweb> X-Mailer: Apple Mail (2.915) X-bounce-key: webpack.hosteurope.de;dz@bitxtender.com;1197363700;b00adeb2; Subject: Re: AW: [PHP-DEV] Namespace resolution From: dz@bitxtender.com (=?ISO-8859-1?Q?David_Z=FClke?=) The problem I see with that is that if I have an application that uses =20= a 3rd-party library which does not use namespaces, I need to =20 use ::LibClass everywhere. Until they switch to namespaces - then I =20 need to touch hundreds and thousands lines of code. If LibClass were =20 looked up in the global namespace, too, I could simply add the =20 appropriate import statements at the top of each file. Anyways, the process you described seems flawed in another fashion: It =20= looks up a class in the namespace first, then an internal php class, =20 then it tries an autoload. That does not make sense. Lets say I run =20 some code as you described, and there is a class C(), but it's not =20 been autoloaded yet. The internal class C is used. Then, later, the =20 autoloading of A::B::C() is somehow forced. Now, if the same code runs =20= again, a different class is used. That sounds like nonsense. David Am 11.12.2007 um 08:31 schrieb Matthias Pigulla: > > >> -----Urspr=FCngliche Nachricht----- >> Von: Sam Barrow [mailto:sam@sambarrow.com] >> Gesendet: Montag, 10. Dezember 2007 22:48 >> An: internals@lists.php.net >> Betreff: [PHP-DEV] Namespace resolution >> >> Ok, it's supposed to be this way right? If i define a custom class in >> the global namespace called "myClass" and I'm in another namespace, I >> can only access it using ::myClass, not just myClass (without the >> colons)? Seems to me that it should check the local namespace and =20 >> then >> the global, but it only checks the globl if i specifically tell it to >> with the preceding "::". > >> =46rom http://www.php.net/manual/en/language.namespaces.rules.php: > > -- > Inside namespace (say A::B), calls to unqualified class names are =20 > resolved at run-time. Here is how a call to new C() is resolved: > > 1. It looks for a class from the current namespace : A::B::C(). > 2. It tries to find and call the internal class C(). > 3. It attemts to autoload A::B::C(). C(). > > To reference a user defined class in the global namespace, new ::C() =20= > has to be used. > -- > > Which is exactly what you observed. > > -mp. > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >