On 13.08.2008, at 15:35, Lars Strojny wrote:

Hi Markus

Am Mittwoch, den 13.08.2008, 15:21 +0200 schrieb Marcus Boerger:
[...]
Namespaces are new, so it never worked before. But yes, this would trigger a warning in the compiler which means you are told to not do this with apc
or other compiler caches.

You are aware that this is used in a number of PHP libraries/ frameworks?
Additionally, a lot have code like this:

class ...
 public function foo()
 {
    if (!$this->_something) {
        require_once 'Foo/Exception.php';
        throw new FooException();
    }
 }

Right, this is quite common. So is including drivers inside factory methods. Even if they are not explicit, there is obviously also autoload.

Just so that I get straight why we are doing this:
The namespace of the file is not magically applied to the included code, so instead one would expect the included code to set the relevant namespace itself.

Now for any library that would use namespaces and have an include inside that namespace, it would also set a namespace in the included file or its likely a bug. Not sure if we could only throw a warning if we do an include without a namespace being defined in the file that is being included? That starts being quite fancy in terms of error handling though, which even if doable probably adds overhead?

The other situation I see would be a namespaced template engine that loads some template who's content is not namespaced explicitly. It does not really make sense to start defining namespaces in templates just to get around that warning.

I guess most of the time those using OP caches know what they are doing.
So why should a warning be triggered here?


Thats a pretty big assumption.

regards,
Lukas Kahwe Smith
[EMAIL PROTECTED]




--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to