rfc:namespaced_names_as_token

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
rfc:namespaced_names_as_token [2020/06/15 17:05] nikicrfc:namespaced_names_as_token [2020/06/16 08:48] nikic
Line 2: Line 2:
   * Date: 2020-06-15   * Date: 2020-06-15
   * Author: Nikita Popov <nikic@php.net>   * Author: Nikita Popov <nikic@php.net>
-  * Status: Draft+  * Status: Under Discussion
   * Target Version: PHP 8.0   * Target Version: PHP 8.0
   * Implementation: https://github.com/php/php-src/pull/5720   * Implementation: https://github.com/php/php-src/pull/5720
Line 8: Line 8:
 ===== Introduction ===== ===== Introduction =====
  
-PHP currently treats namespaced names like ''Foo\Bar'' as a sequence of identifier and namespace separator tokens. This RFC proposed to treat namespaced names as a single token, and as such allow reserved keywords to appear inside them. At the same time, it proposes to lift reserved keyword restrictions for class, function and constant declarations.+PHP currently treats namespaced names like ''Foo\Bar'' as a sequence of identifiers and namespace separator tokens. This RFC proposes to treat namespaced names as a single token, and as such allow reserved keywords to appear inside them. At the same time, it proposes to lift reserved keyword restrictions for class, function and constant declarations.
  
 The motivation is to reduce the backwards compatibility impact of new reserved keyword additions in future versions of PHP. To give a specific example, PHP 7.4 added the ''fn'' keyword as part of arrow function support. This broke my [[https://github.com/nikic/iter|iter library]], because it was using ''fn'' as part of a namespace name. However, this breakage was entirely unnecessary! Here is a typical usage example: The motivation is to reduce the backwards compatibility impact of new reserved keyword additions in future versions of PHP. To give a specific example, PHP 7.4 added the ''fn'' keyword as part of arrow function support. This broke my [[https://github.com/nikic/iter|iter library]], because it was using ''fn'' as part of a namespace name. However, this breakage was entirely unnecessary! Here is a typical usage example:
Line 74: Line 74:
 // Before: T_NS_SEPARATOR T_STRING // Before: T_NS_SEPARATOR T_STRING
 // After:  T_NAME_FULLY_QUALIFIED // After:  T_NAME_FULLY_QUALIFIED
-// Rule:   {LABEL}("\\"{LABEL})*+// Rule:   ("\\"{LABEL})+
  
 namespace\Foo; namespace\Foo;
Line 164: Line 164:
  
 As such, the practical impact is very limited, and any issues are trivial to fix. On the other hand, this change will reduce the backwards-compatibility impact from any future keyword additions. As such, the practical impact is very limited, and any issues are trivial to fix. On the other hand, this change will reduce the backwards-compatibility impact from any future keyword additions.
 +
 +Additionally tooling based on ''token_get_all()'' will need to be adjusted to handle the new ''T_NAME_*'' tokens.
  
 ===== Vote ===== ===== Vote =====
rfc/namespaced_names_as_token.txt · Last modified: 2020/07/31 12:54 by nikic