rfc:context_sensitive_lexer

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:context_sensitive_lexer [2015/04/20 14:55] – update pull request link + fix some descriptions marciorfc:context_sensitive_lexer [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 3: Line 3:
   * Date: 2015-02-15   * Date: 2015-02-15
   * Author: Márcio Almada   * Author: Márcio Almada
-  * Status: Voting (previously Under Discussion)+  * Status: Implemented (in PHP 7.0)
   * First Published at: http://wiki.php.net/rfc/context_sensitive_lexer   * First Published at: http://wiki.php.net/rfc/context_sensitive_lexer
  
Line 31: Line 31:
  
 This RFC revisits the topic of [[https://wiki.php.net/rfc/keywords_as_identifiers|Keywords as Identifiers]] RFC. But this time This RFC revisits the topic of [[https://wiki.php.net/rfc/keywords_as_identifiers|Keywords as Identifiers]] RFC. But this time
-presenting a minimal and maintainable [[https://github.com/marcioAlmada/php-src/commit/d9d6f0c7e325dcd0d0ff3c3f2dc73c2364c3ad5f|patch]], +presenting a minimal and maintainable [[https://github.com/php/php-src/pull/1221|patch]], restricted to OO scope only, consistently comprehending:
-restricted to OO scope only, consistently comprehending:+
  
   * Properties, constants and methods defined on classes, interfaces and traits   * Properties, constants and methods defined on classes, interfaces and traits
Line 52: Line 51:
 ==== Limitations ==== ==== Limitations ====
  
-On purpose, it's still forbidden to define ''class|object'' constants and methods named as: +On purpose, it's still forbidden to define a **class constant** named as ''class'' because of the class name resolution ''::class'':
- +
-  * ''public'' +
-  * ''protected'' +
-  * ''private'' +
-  * ''abstract'' +
-  * ''final'' +
-  * ''static'' +
- +
-So the following code would still be invalid: +
- +
-<code php> +
-class Foo { +
-  const public|protected|private|static|abstract|final|class = 'foo'; // Fatal error +
-  function public|protected|private|static|abstract|final(){} // Fatal error +
-+
- +
-// Fatal error: Cannot declare a class const named as %d as it is reserved in %s on line %d +
-// Fatal error: Cannot declare a class method named as %d as it is reserved in %s on line %d +
-</code> +
- +
-On purpose, it's still forbidden to define a **class constant** named as ''class'' because of the class name resolution operator ''::class'':+
  
 <code php> <code php>
Line 82: Line 60:
 // Fatal error: Cannot redefine class constant Foo::CLASS as it is reserved in %s on line %d // Fatal error: Cannot redefine class constant Foo::CLASS as it is reserved in %s on line %d
 </code> </code>
 +
 +In practice, it means that we would drop from **64** to only **1** reserved word that affects only class constant names.
  
 ''class|object'' properties **can** have any name because PHP has sigils and code like the following has always been allowed: ''class|object'' properties **can** have any name because PHP has sigils and code like the following has always been allowed:
Line 92: Line 72:
 (new Foo)->list; (new Foo)->list;
 </code> </code>
- 
-In practice, it means that we would drop from **64** to only **6** **globally** reserved words. 
  
 ===== Practical Examples ===== ===== Practical Examples =====
Line 259: Line 237:
  
   - Pull request with all the tests is at [[https://github.com/php/php-src/pull/1221/]]   - Pull request with all the tests is at [[https://github.com/php/php-src/pull/1221/]]
 +
 +==== Later Changes ===
 +
 +The *Patch 2* was merged and, later, method modifiers were allowed as class member names. This was a limitation from the older implementation candidate - Patch 1 - and there was no reason to keep it. The **Limitations** section was updated accordingly. Only the keyword **class** for class constants is reserved now.
  
 ===== References ===== ===== References =====
Line 266: Line 248:
 ===== Rejected Features ===== ===== Rejected Features =====
  
- * Prior to voting, the support for ''namespace|class|traits|traits'' names has been removed from the first patch as it could create some possible issues.+ * Prior to voting, the support for ''namespaces|classes|traits|interfaces'' names has been removed from the first patch as it could create some possible issues.
  
 => The RFC author will try to solve the wider problem on PHP 7.1 => The RFC author will try to solve the wider problem on PHP 7.1
rfc/context_sensitive_lexer.1429541755.txt.gz · Last modified: 2017/09/22 13:28 (external edit)