Re: Proposed refactor of standard (and a major technical problem found with lower-casing namespaces)
| From: | Greg Beaver | Date: | Fri, 07 Aug 2009 20:30:02 +0000 |
| Subject: | Re: Proposed refactor of standard (and a major technical problem found with lower-casing namespaces) | ||
| References: | 1 2 | Groups: | php.standards |
| Request: | Send a blank email to standards-+get-86@lists.php.net to get a copy of this message | ||
David Zülke wrote:
> On 07.08.2009, at 19:51, Greg Beaver wrote:
>
>> Hi,
>
> Hi Greg,
>
>
>> First off, this email is longish. It has 2 sections, the technical
>> problem with the standard, and a concrete proposal for a better
>> standard. The standard is after the line of asterisks.
>
> I'm packing for my vacation right now, so this mail is shortish... I
> can reply in more detail (and answer questions) when I'm back in
> around a week.
>
>
>> Fatal error: Cannot use pear2\test as test because the name is
>> already in use
>>
>> The problem? PHP's namespaces are not case-sensitive, but autoload
>> translation to paths *is* case-sensitive on unix OSes. Design a
>> standard that mixes case and *BEWM* strange fatal errors that the
>> unaided eye may not be able to detect a reason for.
>
> How is that specific to our implementation? It happens either way,
> whether we mandate lowercase or not.
Hi,
Actually, not true, the following code shows the way I would do things
(and have been doing things thus far with the 12000+ LOC of Pyrus):
<?php
namespace pear2\One {
class Myclass {}
}
?>
<?php
namespace pear2\One\Myclass {
class Internal {}
}
?>
<?php
namespace pear2\Another {
use pear2\Myclass;
$a = new Myclass;
$b = new Myclass\Internal;
?>
With the above modified example ($b = new myclass\Internal was the old
example), there is no fatal error, it just works. If the case between a
class and a namespace with the same name is consistent, autoload will be
able to resolve on case-sensitive OSes.
The problem with the old standard is that it mandates a situation where
sub-namespaces have a different case from the class.
Greg