Re: [RFC] Function Autoloading (mark 5)

From: Date: Fri, 19 Jun 2026 04:01:23 +0000
Subject: Re: [RFC] Function Autoloading (mark 5)
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-131398@lists.php.net to get a copy of this message
Hi all, > On Jun 17, 2026, at 09:47, Rowan Tommins [IMSoP] <imsop.php@rwec.co.uk> wrote: > > 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. Theodore Brown mentioned something like that as well in <https://externals.io/message/105757>. Please see the following PR against my own branch to see what it would look like if added to the function-autoloading (mark 5) branch. https://github.com/pmjones/php-src/pull/1 Hypothetically this could be its own separate, precursor RFC and PR, but it's small enough it might go well here. Thoughts? -- pmj

« previous php.internals (#131398) next »