On Fri, Aug 23, 2024, at 10:08, Nick Lockheart wrote:
> 
> > 
> > If we were to go with any major change in the current lookup where it
> > is perf or nothing, this is what I would propose for php 9.0
> > (starting with an immediate deprecation):
> >    1. any unqualified call simply calls the current namespace
> >    2. >= php 9.0: no fallback to global
> >    3. < php 9.0: emit deprecation notice if falls back to global
> > This is how classes work (pretty sure), so it would be consistent.
> > 
> > Going the other way (global first) doesn't really make sense because
> > it is inconsistent, IMHO. Will it suck? Probably. Will it be easy to
> > fix? Probably via Rector.
> > 
> > — Rob
> 
> 
> A third option, which I haven't seen come up on the list yet, is that
> unqualified functions that are PHP built-ins are treated as global, and
> using a function having the same name as a built-in, in a namespace
> scope, requires a fully qualified name to override the built-in.
> 
> It seems that if someone is writing `array_key_exists()` or similar
> they probably mean the built-in function, and in the rare cases where
> they do mean `\foo\array_key_exists()`, they can write it explicitly.
> 
> Functions that are *not* on the built-in function list could default to
> the local namespace.

I was actually thinking of doing something like this for function autoloading, 
where extensions could register global functions that bypass the autoloader and 
go straight to global if it isn't defined in the local namespace already. I 
decided not to even bring it up because it felt controversial (it would 
effectively be global first, except for user functions). Though, it might be a 
nice compromise?

— Rob

Reply via email to