Le ven. 24 janv. 2020 à 17:10, Nicolas Grekas <nicolas.grekas+...@gmail.com> a écrit :
> > One option that I haven't seem much discussion on is the opposite: Always >> only look in the global namespace. Any unimported unqualified usages will >> be treated as fully qualified names. This would match the proposed >> semantics for functions/consts and change the resolution rules for >> classes. >> I think this would have relatively little impact on how code is written, >> as >> classes already tend to make extensive use of cross-namespace references >> and the import is usually IDE managed. >> > > > Quick reaction: that'd make sense to me! > > Adding a "use CurrentNamespace\Foo" or using "namespace\Foo" looks easy > enough to adopt. > Does this mean you're suggesting to use declare(symbol_lookup='global')? > Or shorter: declare(lookup='global'), or maybe even > declare(global_lookup=1) as I'm not sure we need 3 options here? > Hello Tyson, can we please discuss this alternative? In another reply, you link to https://wiki.php.net/rfc/use_global_elements#deprecate_the_fallback_to_the_root_namespace_instead But this new proposal derived from Nikita's idea is different as it doesn't need to deprecate anything. I'm not comfortable with having a 3-ways declare directive. Who will pick which of the 3 and for what reason? That's going to be a mess to review. If we're looking for a forward path, there should be only one opt-in way: a boolean flag. declare(global_lookup=1) I think that's all we need to make all symbols resolve in the same way, known at compile time. You mention this should be another RFC. But process-wise, I think it would be better to vote only once on a specific topic, vs having several iterations that undo previous RFCs before having a stable consensus. Thanks for considering, Nicolas