Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:40821 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 90458 invoked from network); 1 Oct 2008 16:33:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Oct 2008 16:33:26 -0000 Authentication-Results: pb1.pair.com header.from=derick@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=derick@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 82.94.239.7 as permitted sender) X-PHP-List-Original-Sender: derick@php.net X-Host-Fingerprint: 82.94.239.7 mail.jdi-ict.nl Linux 2.6 Received: from [82.94.239.7] ([82.94.239.7:40339] helo=mail.jdi-ict.nl) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7E/60-04812-256A3E84 for ; Wed, 01 Oct 2008 12:33:24 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.jdi-ict.nl (8.13.7/8.12.11) with ESMTP id m91GX10W029277; Wed, 1 Oct 2008 18:33:11 +0200 Date: Wed, 1 Oct 2008 18:33:04 +0200 (CEST) X-X-Sender: derick@kossu.ez.no To: Greg Beaver cc: internals@lists.php.net In-Reply-To: <48D47532.8080102@chiaraquartet.net> Message-ID: References: <48D47532.8080102@chiaraquartet.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=UTF-8 Subject: Re: [PHP-DEV] solving the namespace conflict issues between function/static method class constant/ns constant From: derick@php.net (Derick Rethans) On Fri, 19 Sep 2008, Greg Beaver wrote: > Hi all, > > There is a problem in the namespace implementation. This code demonstrates > the issue: > > code.inc: > namespace foo; > class test { > const my = 1; > static function bar(){} > } > > namespace foo::test; > const my = 2; > function bar(){} > ?> > > main.php: > include 'code.inc'; > foo::test::bar(); // always calls namespace function > call_user_func(array('foo::test', 'bar')); // the only way to call static > method > echo foo::test::my; // always 2 > $a = new foo::test; > echo $a::my; // the only way to access foo::test::my > ?> > > There are 5 ways to solve this: > > 1) document it and hope no one uses it [this is the current strategy, minus > the documentation part] > 2) add a fatal error on conflicting names. Uh, if we don't have functions in namespaces, then the second "function bar(){}" would define the bar function in the global scope only and not as part of the foo::test namespace... so one more reason to remove functions (and constants) from namespaces? regards, Derick -- HEAD before 5_3!: http://tinyurl.com/6d2esb http://derickrethans.nl | http://ezcomponents.org | http://xdebug.org