rfc:token_as_object

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
rfc:token_as_object [2020/03/02 17:53]
nikic
rfc:token_as_object [2020/04/23 10:50]
nikic
Line 2: Line 2:
   * Date: 2020-02-13   * Date: 2020-02-13
   * Author: Nikita Popov <nikic@php.net>   * Author: Nikita Popov <nikic@php.net>
-  * Status: Under Discussion+  * Status: Implemented
   * Target Version: PHP 8.0   * Target Version: PHP 8.0
   * Implementation: https://github.com/php/php-src/pull/5176   * Implementation: https://github.com/php/php-src/pull/5176
Line 137: Line 137:
 The ''is()'' method allows checking for certain tokens, while abstracting over whether it is a single-char token ''%%$token->is(';')%%'', a multi-char token ''%%$token->is(T_FUNCTION)%%'', or whether multiple tokens are allowed ''%%$token->is([T_CLASS, T_TRAIT, T_INTERFACE])%%''. The ''is()'' method allows checking for certain tokens, while abstracting over whether it is a single-char token ''%%$token->is(';')%%'', a multi-char token ''%%$token->is(T_FUNCTION)%%'', or whether multiple tokens are allowed ''%%$token->is([T_CLASS, T_TRAIT, T_INTERFACE])%%''.
  
-While non-generic code can easily check the appropriate property, such as ''%%$token->text == ';'%%'' or ''%%$token->id == T_FUNCTION%%'', token stream implementations commonly need to be generic over different token kinds and need to support specification of multiple token kind. For example:+While non-generic code can easily check the appropriate property, such as ''%%$token->text == ';'%%'' or ''%%$token->id == T_FUNCTION%%'', token stream implementations commonly need to be generic over different token kinds and need to support specification of multiple token kinds. For example:
  
 <PHP> <PHP>
 +// An example, NOT part of the PhpToken interface.
 public function findRight($pos, $findTokenKind) { public function findRight($pos, $findTokenKind) {
     $tokens = $this->tokens;     $tokens = $this->tokens;
Line 180: Line 181:
 ===== Vote ===== ===== Vote =====
  
-Yes No.+Voting opened 2020-03-06 and closes 2020-03-20. 
 + 
 +<doodle title="Add object-based token_get_all() alternative?" auth="nikic" voteType="single" closed="true"> 
 +   Yes 
 +   No 
 +</doodle>
  
rfc/token_as_object.txt · Last modified: 2020/11/12 13:33 by nikic