Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:38617 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 6604 invoked from network); 25 Jun 2008 19:42:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Jun 2008 19:42:36 -0000 Authentication-Results: pb1.pair.com header.from=greg@chiaraquartet.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=greg@chiaraquartet.net; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain chiaraquartet.net from 38.99.98.18 cause and error) X-PHP-List-Original-Sender: greg@chiaraquartet.net X-Host-Fingerprint: 38.99.98.18 beast.bluga.net Linux 2.6 Received: from [38.99.98.18] ([38.99.98.18:55913] helo=mail.bluga.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 78/4F-20985-AAF92684 for ; Wed, 25 Jun 2008 15:42:35 -0400 Received: from mail.bluga.net (localhost.localdomain [127.0.0.1]) by mail.bluga.net (Postfix) with ESMTP id 8287DC1339B; Wed, 25 Jun 2008 12:42:38 -0700 (MST) Received: from [192.168.1.120] (static-64-115-191-39.isp.broadviewnet.net [64.115.191.39]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.bluga.net (Postfix) with ESMTP id C1CAAC13394; Wed, 25 Jun 2008 12:42:37 -0700 (MST) Message-ID: <48629FA5.3050201@chiaraquartet.net> Date: Wed, 25 Jun 2008 14:42:29 -0500 User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 To: Derick Rethans CC: Andi Gutmans , Stanislav Malyshev , Dmitry Stogov , internals Mailing List References: <485BD1C0.8040302@chiaraquartet.net> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV using ClamSMTP Subject: Re: [PHP-DEV] simple solution to another namespace conundrum? From: greg@chiaraquartet.net (Greg Beaver) Derick Rethans wrote: > On Fri, 20 Jun 2008, Gregory Beaver wrote: > >> The user is obviously intentionally creating a "DateTime" class, and >> doesn't care about the internal classname in this script. >> >> The attached patch against PHP_5_3 would fix the issue by eliminating >> the check for conflict with CG(class_table) in the global namespace for >> internal classes. It however preserves this check for userspace classes >> so that (for instance) php-src/tests/Zend/ns_030.phpt does not fail. >> The basic idea is that we do have control over the userspace classes we >> include, but have no control over the internal classes. > > I am not so sure this is a good idea. I mean, for the developer that > writes the code it's obvious that his version of DateTime is used. But > for a second developer to come back later this could be a great WTF > factor a few years down the road - wondering why the DateTime > documentation on php.net doesn't match with what the class does. Hi Derick, This is (as Rasmus points out) a hazard of using namespaces, but it need not be a large hazard. I've said this before, but it would be wise to implement a namespace-expansion similar to whitespace-stripping option in php, so that one can convert use statements to namespace names. Of course, a PHP script to do this would be about 25 lines long, so that is an option too, but I would guarantee that if you're finding this wtf to be a problem, there are going to be more problems in the script than just use statements that alias to internal classnames. To be more direct - the "use" statement only applies to the current file, which makes debugging this situation much easier. The real WTF comes into play when you have a static method that resolves to the same name as a namespaced function, something that absolutely must be worked out prior to PHP 5.3's release. I know a few ideas are percolating about on this one from the people I've talked to on and off-list, I am looking forward to the ultimate resolution. Greg