[PR][php-src][#438][master] - Added support for keywords for class/method/label/declare/namespace/class const names
| From: | noreply@php.net | Date: | Sat, 28 Feb 2015 13:04:47 +0000 |
| Subject: | [PR][php-src][#438][master] - Added support for keywords for class/method/label/declare/namespace/class const names | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-2519@lists.php.net to get a copy of this message | ||
You can view the Pull Request on github:
https://github.com/php/php-src/pull/438
Warning: according to github, the Pull Request cannot be merged without manual conflict resolution!
Pull Request Description:
This patch adds possibility to use keywords at some places where previously were only
T_STRING's allowed.
Example:
```PHP
class List { // T_LIST, is now enabled
public function default() { // T_DEFAULT
// do some action
}
}
```
For further examples see the rfc at https://wiki.php.net/rfc/keywords_as_identifiers
The goal of the patch is to limit less the user's choice of names for labels, classes,
functions, namespaces etc.
Internals discussion at http://marc.info/?l=php-internals&m=137893452326358&w=2
---
Possible constructs (with
string being a T_STRING or a keyword):
```
string::string;
string::string();
$var->string;
$var->string();
(modifier)* function string() { // methods
function T_STRING ((string) $var, ...) // the optional typehint
declare(string = ..., ...);
(namespace) \(string\)*string;
use string as (modifier) string; // namespace aliasing
new string;
class string (extends string) (implements string, ...) {
trait string (extends string) (implements string, ...) {
interface string (extends string, ...) {
string::…;
string: // label for goto
goto string;
```
What still is impossible: (as function names and constants remain unaffected)
```
keyword(); // fcall
keyword; // constant
```