On Fri, Jul 3, 2026 at 8:50 AM Paul M. Jones <[email protected]> wrote:

> Hi Michael,
>
>
> > On Jul 2, 2026, at 09:41, Michael Morris <[email protected]> wrote:
> >
> > This is tangential to the function autoload discussion.
> >
> > An idea that popped into my head an hour ago, that I don't have another
> PHP Dev to talk to about, what if you could register a function that is
> called by PHP the first time it sees a namespace declared?
>
> That's a neat idea ...
>
> >
> > This would allow functions and for that matter constants of the
> namespace to be declared before they get called.  It isn't as clean as
> waiting until the function call itself is being called, but maybe that's
> for the best. After all, if you have a dozen 10 line utility functions do
> you necessarily want 10 files.
>
> ... but do note that function autoloading need not be 1-file-per-function,
> as is the typical case with classes (cf. PSR-0 and PSR-4).  For example,
> the Moto autoloader allows more-than-one class or function per file.
>
>   https://github.com/motophp/autoload
>
> That's only one option for multiples-per-file, so that those "dozen 10
> line utility functions" can be in a single file.
>
>
> -- pmj
>

How autoloaders/callbacks use this hook is independent of the hook
implementation itself. It does need to be kept in mind, but it also doesn't
need to be addressed directly in any RFC that rises out of this.

Reply via email to