Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37971 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 85684 invoked from network); 28 May 2008 16:50:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 May 2008 16:50:26 -0000 Authentication-Results: pb1.pair.com smtp.mail=sv_forums@fmethod.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=sv_forums@fmethod.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fmethod.com from 69.16.228.148 cause and error) X-PHP-List-Original-Sender: sv_forums@fmethod.com X-Host-Fingerprint: 69.16.228.148 unknown Linux 2.4/2.6 Received: from [69.16.228.148] ([69.16.228.148:39524] helo=host.fmethod.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 88/91-10063-15D8D384 for ; Wed, 28 May 2008 12:50:25 -0400 Received: from [83.228.56.37] (port=3140 helo=pc) by host.fmethod.com with esmtpa (Exim 4.68) (envelope-from ) id 1K1Oqz-0002PB-0X for internals@lists.php.net; Wed, 28 May 2008 11:50:21 -0500 Message-ID: To: References: <462e563f0805280927w46cb0a3fra8b546e8219dd9ab@mail.gmail.com> Date: Wed, 28 May 2008 19:50:14 +0300 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="UTF-8"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5512 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host.fmethod.com X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - fmethod.com Subject: Re: [PHP-DEV] Name resolution rules From: sv_forums@fmethod.com ("Stan Vassilev | FM") Hi, You examples are showing some quite horrible situations with namespaces. Agreed, the least thing, an error should be thrown on collision. Regards, Stan Vassilev >I find the namespace resolution rules quite confusing. It's become quite > difficult to tell if I'm calling a static method or a function, or > namespaced static method or namespaced function, and so on. I don't quite > fully understand or appreciated the point of namespaces. If some one could > help me out here. > > -- google.php -- > namespace Google; > > function search() { > return 'namespace google search'; > } > > -- test.php -- > require('google.php'); > > class Google { > public static function search() { > return 'class google search'; > } > > public static function test() { > return 'class google test'; > } > } > > function search() { > return 'global function search'; > } > > use Google as Other; > > echo '1 '.__FILE__.' #'.__LINE__.' '.search().'
'; > echo '2 '.__FILE__.' #'.__LINE__.' '.Google::search().'
'; > echo '3 '.__FILE__.' #'.__LINE__.' '.Google::test().'
'; > echo '4 '.__FILE__.' #'.__LINE__.' '.Other::test().'
'; > > 1. behaved as I expected it to. > 2. didn't do what I thought it should have done, now the class is broken, > but wouldn't though any exception. > 3. behaved as I expected it to. > 4. wow strange I've managed to rename my class though namespace resolution > rules. > > I feel that namespaces are going to cause some big problems. Shouldn't it > wait for PHP6 rather than backport to PHP5. > This is only one of the problems I've come across with namespaces. > > Is it going to be possible to get to the google class search method? I > find > it terrible that now a name *DOES* clash, but this time with out so much > as > an error! I preferred it to highlight the fact that I had a class with the > same name. > > Any thoughts? > > /James >