rfc:token-get-always-tokens

Differences

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

Link to this comparison view

Next revision
Previous revision
rfc:token-get-always-tokens [2016/01/04 22:54] – created pollitarfc:token-get-always-tokens [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ====== PHP RFC: token_get_all() flag to return consistent elements ====== ====== PHP RFC: token_get_all() flag to return consistent elements ======
-  * Version: 0.1+  * Version: 1.1
   * Date: 2016-01-04   * Date: 2016-01-04
   * Author: Sara Golemon <pollita@php.net>   * Author: Sara Golemon <pollita@php.net>
-  * Status: Draft+  * Status: Under Discussion
   * First Published at: http://wiki.php.net/rfc/token-get-always-tokens   * First Published at: http://wiki.php.net/rfc/token-get-always-tokens
  
Line 21: Line 21:
  
 ===== Proposal ===== ===== Proposal =====
-This proposal aims to normalize the output of token_get_all (when requested) by always using associative arrays as the sub-elements in the output.  For example, token_get_all("<?php ;", TOKEN_FULL) would output:+This proposal aims to normalize the output of token_get_all (when requested) by always using associative arrays as the sub-elements in the output.  For example, token_get_all("<?php ;", TOKEN_ASSOC) would output:
  
   Array (   Array (
     [0] => Array (     [0] => Array (
-      [token] => int(374)+      [id] => int(374)
       [text] => string(6)"<?php "       [text] => string(6)"<?php "
       [line] => int(1)       [line] => int(1)
     )     )
     [1] => Array (     [1] => Array (
-      [token] => int(59)  // 59 == ord(';')+      [id] => int(59)  // 59 == ord(';')
       [text] => string(1) ";"       [text] => string(1) ";"
       [line] => int(1)       [line] => int(1)
Line 36: Line 36:
   )    ) 
  
-Note the use of a new constant TOKEN_FULL to be used with the flags parameter introduced in PHP 7.0+Note the use of a new constant TOKEN_ASSOC to be used with the flags parameter introduced in PHP 7.0 
 + 
 +==== Additional changes ==== 
 +In order to reduce boilerplate in code which uses token_get_all(), the token_name() function will be updated to so that token_name($element['token']) is always a valid call.  That is, single-character token values will return the character value for that ordinal. 
 + 
 +In terms of psuedo-code: 
 + 
 +  function token_name($id) { 
 +    if ($id < 256) { 
 +      return chr($id); 
 +    } 
 +    return current_token_name($id); 
 +  }
  
 ==== New Constants ==== ==== New Constants ====
-TOKEN_FULL - When present, token_get_all() will use the new format+TOKEN_ASSOC - When present, token_get_all() will use the new format
  
 ===== Future Scope ===== ===== Future Scope =====
Line 45: Line 57:
  
 ===== Proposed Voting Choices ===== ===== Proposed Voting Choices =====
-Introduce TOKEN_FULL and new scanner output format? 50% majority required+Introduce TOKEN_ASSOC and new scanner output format? 50% majority required
  
rfc/token-get-always-tokens.1451948082.txt.gz · Last modified: 2017/09/22 13:28 (external edit)