Hi Stephen On Sat, Aug 24, 2024 at 1:54 PM Stephen Reay <php-li...@koalephant.com> wrote: > > Thanks for clarifying. Out of curiosity, how much optimisation do you imagine > would be possible if the lookups were done the same was as classes (ie no > fallback, names must be local, qualified or imported with `use`)?
I haven't measured this case specifically, but if unqualified calls to local functions are indeed rare (which the last analysis seems to indicate), then it should make barely any difference. Of course, if your code makes lots of use of them, then the story might be different. That said, the penalty of an ambiguous internal call is much higher than that of a user, local call, given that internal calls sometimes have special optimizations or can even be entirely executed at compile time. For local calls, it will simply lead to a double lookup on first execution. > I am aware this is a BC break. But if it's kosher to discuss introducing a > never ending BC break I don't see why this isn't a valid discussion either. > It would give *everyone* that elusive 2-4% performance boost, would resolve > any ambiguity about which function a person intended to call (the claimed > security issue) and would bring consistency with the way classes/etc are > referenced. >From my analysis, there were 2 967 unqualified calls to local functions in the top 1 000 repositories. (Disclaimer: There might be a "use function" at the top for some of these, the analysis isn't that sophisticated.) I also ran the script to check for unqualified calls to global functions (or at least functions that weren't statically visible in that scope in any of the repositories files), and there were ~139 000 of them. It seems like this is quite a different beast. To summarize: 1. Flipping lookup order: ~a few dozens of changes 2. Global only: ~3 000 changes 3. Local only: ~139 000 changes While much of this can be automated, huge diffs still require reviewing time, and can lead to many merge conflicts which also take time to resolve. I would definitely prefer to go with 1. or potentially 2. Ilija