Re: Function auto-loading

From: Date: Tue, 09 Aug 2016 16:17:39 +0000
Subject: Re: Function auto-loading
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.internals 
Request: Send a blank email to internals+get-94970@lists.php.net to get a copy of this message
On 09/08/2016 17:05, Rasmus Schultz wrote:
I'm suggesting the use-statement be the trigger, rather than actually calling the function. In other words, calls to substr() does not trigger the resolve - a statement like "use function substr" on the other hand, does.
Ah, I see. The problem with that is, you still have to explicitly list every function you're going to use, so you might as well just use require_once, or call "load_function('substr')" directly.
I think, in practice, it's not going to work much differently from the other proposed work-around though - if only qualified references trigger auto-loading, then this would trigger auto-loading:
    \foo\bar();
And this would too:
    use foo\bar;
    bar();
But this would not:
    bar();
Yep, that's about the size of it. If I could go back and time and join the discussion at the time of PHP 6 / PHP 5.3, I'd argue for simplifying the name resolution, so the last one was either always the current namespace or always a global name. Pass me that faster-than-light telephone... ;) Regards, -- Rowan Collins [IMSoP]

« previous php.internals (#94970) next »