rfc:token_as_object

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
Next revisionBoth sides next revision
rfc:token_as_object [2020/02/13 10:22] – Remove T_BAD_CHARACTER from ignorable tokens nikicrfc:token_as_object [2020/02/13 12:45] – Add missing "static" in example code guilliamxavier
Line 46: Line 46:
 </code> </code>
  
-==== Additional methods ====+===== Open Questions =====
  
-There are few useful helper methods that could be added to the ''PhpToken'' classWhether these should be added as part of this proposal is an **open question**.+==== Construction method ==== 
 + 
 +The RFC currently proposes new ''TOKEN_AS_OBJECT'' flag to the existing ''token_get_all()'' functionNicolas Grekas suggested to use a new function or method instead, to make this functionality more easily polyfillable. 
 + 
 +To make the functionality self-contained, a new static method on ''PhpToken'' could be added
 + 
 +<PHP> 
 +class PhpToken { 
 +    /** @return PhpToken[] *
 +    public static function getAll(string $code, int $flags = 0); 
 +
 +</PHP> 
 + 
 +==== Additional methods ====
  
-Three suggestions are given as PHP code below. The ''is()'' method is a useful helper, variations of which will be found in many libraries processing token streams. ''isIgnorable()'' helps the particularly common case of skipping whitespace-like tokens. ''getTokenName()'' avoids going through ''token_name()'' for debug output.+There are a few useful helper methods that could be added to the ''PhpToken'' class. Three suggestions are given as PHP code below. The ''is()'' method is a useful helper, variations of which will be found in many libraries processing token streams. ''isIgnorable()'' helps the particularly common case of skipping whitespace-like tokens. ''getTokenName()'' avoids going through ''token_name()'' for debug output.
  
 <PHP> <PHP>
rfc/token_as_object.txt · Last modified: 2020/11/12 13:33 by nikic