Importing functions from a static class would equally require to have all
functions in the same file. I was proposing an alternative to that, not
"symbol to file" autoloading.

Though, I know that problem well, sadly. I've suggested PHP should just
deprecate the fallback to root namespace, and remove the feature altogether
in PHP8.

Imho it's the only way to actually solve this. Some say it would be a huge
BC break, but in reality old applications could maintain compatibility only
by adding a simple autoloader that would alias the global function/constant
into the calling namespace. Roave wrote this
https://github.com/Roave/FunctionFQNReplacer , PHPStorm is supporting the
no-fallback referencing:
https://youtrack.jetbrains.com/issue/WI-27425 (recently implemented)
https://youtrack.jetbrains.com/issue/WI-34446 (recently implemented)
https://youtrack.jetbrains.com/issue/WI-34858
So... it could be the right time to deprecate the fallback to root
namespace, before PHP8 gets too close.

Reply via email to