Re: [RFC] Function Autoloading (mark 5)

From: Date: Wed, 17 Jun 2026 14:47:22 +0000
Subject: Re: [RFC] Function Autoloading (mark 5)
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-131350@lists.php.net to get a copy of this message
On 17 June 2026 11:03:07 BST, Anton Smirnov <sandfox@sandfox.me> wrote: >Imagine we have an old guzzle/psr7 with stream_for function, and they use it without a >qualifier. I defined a global stream_for so now I hijacked the internal library logic. Is it >correct? > >The previous attempt with namespace pinning made more sense to me The concern that occurred to me is similar: if I rely on function autoloading, but forget to fully-qualify a name in the current namespace, it would accidentally work as long as some other code triggered loading of that function first. Then some small refactoring - or even a different path through the code at runtime - and it will silently fall back to a function in the global namespace instead. I think if autoloading is going to require some extra "ceremony" in the code, it would be preferable to have a declare() at the top of the file forcing the interpretation of all unqualified names (either "always assume current namespace" or "always assume global namespace"). That way, code would not change behaviour based on hard-to-predict side effects elsewhere. Rowan Tommins [IMSoP]

« previous php.internals (#131350) next »