A pre-RFC discussion on the PHP internals mailing list proposes a new function, tentatively named `spl_namespace_register($callback, $prepend)`, that would allow developers to register a callback triggered the first time PHP encounters a namespace declaration. The idea is tangential to the ongoing function autoload discussion and aims to enable functions and constants within a namespace to be declared before they are called, potentially reducing the need for many small files. A follow-up response raises open questions about callback invocation order for nested namespaces (e.g., whether `Foo\Bar\Baz` triggers one call or three), and how propagation should work when multiple sub-namespaces are declared.

3m read timeFrom externals.io
Post cover image
101 Impressions