Commit ec7f890
authored
Add returns global class command for PHP (#2273)
This pull request is related to issue #2266, PR #2271, and PR #2272.
It implements the "returns global class <user.text>" command in
./lang/php/php.talon.
PHP uses
[namespaces](https://www.php.net/manual/en/language.namespaces.definition.php)
for class, interface, function, and constant definitions. Namespaces use
the `\` character to declare subnamespaces, and a global namespace
reference can be made by prefixing it with `\`. When a namespace is
declared, namespace resolution first checks whether proceeding classes
and functions are registered in that namespace. Prefixing them with "\"
explicitly declares they use the global space. Simple example:
```php
<?php
namespace App;
function currentDate(): \DateTime {
return new \DateTime();
}
```
I believe PHP is almost unique in this behavior, which is why I am
submitting this PR to add this command to it instead of the common
language features. I couldn't find any evidence that coding languages
other than C# have a prefix which can declare that a class reference in
a type definition must resolve to the global namespace instead of the
current namespace.1 parent e71eaa3 commit ec7f890
1 file changed
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
28 | 31 | | |
29 | 32 | | |
30 | 33 | | |
| |||
0 commit comments