Re: [PHP-DEV] Pre-RFC spitball - Namespace Load event

[email protected] ("Larry Garfield")
Newsgroups php.internals
Message-ID <[email protected]>
On Fri, Jul 3, 2026, at 7:32 AM, Michael Morris wrote:

> And this applies for use statements as well.  For example, if `use 
> A\foo;` is foo a class? a function, a constant? Who knows, but this is 
> the moment to find out and execute this handler.

It's known because the syntax says what it is.

use Foo\Bar; // Bar is a class, or a namespace prefix.
use function Foo\Bar\baz; // baz is a function.
use const Foo\Bar\Beep; // Beep is a constant.

This feels somewhat similar to Python, where a given module can have an __init__.py file that is automatically loaded the first time the module is referenced.  I'm not sure how well that maps into PHP (see previous module/package/namespace threads), but it's an interesting model to explore for function autoloading.

--Larry Garfield
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.