> and that you have to explicitly say that you use the current namespace for 
> that name:
> 
> <?php
> declare(function_and_const_lookup='global');
> namespace MyNS;
> use function MyNS\foo;
> // or, equivalently: use function namespace\foo:
>
> function foo() { }
>
> foo(); // <-- this is the function defined just above

That's a good solution to the ambiguity that I hadn't considered. Functions and 
constants should be relatively uncommon for most projects, although I can see 
it getting repetitive for a file with dozens of constants.
(e.g. with namespace-scoped declares)
define() or declare(function_and_const_lookup='global') should be adequate 
workarounds.
- A subsequent RFC could reduce the restriction and make "const X = ..." always 
act as though it was immediately preceded by "use const X"
  This works better for constants than functions because constants can't be 
declared anywhere but the top level.

`use function namespace\foo;` is a syntax error, though. It can only be used as 
`namespace\foo();`. It may be useful to add if projects adopt 
function_and_const_lookup, or other changes to namespace resolution get made.

- Tyson
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to