samedi 7 mars 2020

Why don't class name fallback to global class name in namespaces?

I have been reading the Using namespaces: fallback to global function/constant on php.net and it says the language is designed in the following way:

Class names always resolve to the current namespace name. Thus to access internal or non-namespaced user classes, one must refer to them with their fully qualified Name.... .....For functions and constants, PHP will fall back to global functions or constants if a namespaced function or constant does not exist.

My question is what would be wrong if the classes could fallback to global classes, like functions and constants, when they are not defined in the current namespace? What would be the ideological or technical hardships of that design choice?

Aucun commentaire:

Enregistrer un commentaire