[php-langspec][Issue #238] - Specify when imported names become available
[email protected] Sun, 05 May 2019 01:22:47 +0000
| Newsgroups | php.standards |
|---|---|
| Message-ID | <[email protected]> |
You can view the Issue on github:
https://github.com/php/php-langspec/issues/238
Opened By: mattacosta
Issue Description:
The specification currently states that use declarations bring a name into a scope, but that's not exactly true, as imports are not available prior to the use declaration.
```php
namespace A {
class C {}
}
namespace B {
// Same scope, 'A\C' should be available right?!
$c = new C();
use A\C;
}
```
Without this restriction, an engine could theoretically make an initial pass to import names from all use declarations, and therefore prevent a name resolution error from occurring.
**18-namespaces.md**
> A namespace-use-declaration imports — that is, makes available — one or more names into a scope, optionally giving them each an alias.