Re: namespace separator and whining

From: Date: Tue, 04 Nov 2008 23:32:19 +0000
Subject: Re: namespace separator and whining
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17  Groups: php.internals 
Request: Send a blank email to internals+get-41674@lists.php.net to get a copy of this message
On 05.11.2008, at 00:12, Marcus Boerger wrote:
classes: 1) try ns::class 2) autoload ns::class 3) fail
Since we can stack autoload we could provide a c-level autoload function that does the default lookup. function global_autoload($name) { if (($p = strrpos($name, '\\')) !== false) { $name = substr($name, $p); if (__NAMESPACE__ == substr($name, 0, $p -1) && class_exists("\\$name")) {
     use "\\$name";    // if we find a way to do this at C-levle
} } }
just to make sure i understand this correctly .. you are suggesting here that we make it somehow possible in __autoload() to fallback to the global namespace. so that if someone wants the fallback to global namespace behavior for classes, he could get this by calling this standard autoload function (or rather by using the spl autoload stack - noting that spl may not be disabled anymore as of PHP 5.3). more specifically you want to enable use statements inside autoload. i presume that use statement would only be in effect for this single name resolution? as in the use statement would not have an affect on subsequent triggering of autoload, even when originating from the same file? regards, Lukas Kahwe Smith mls@pooteeweet.org

« previous php.internals (#41674) next »