Bug #66649 [Opn->Nab]: token_get_all() does not tag new bracket array syntax as T_ARRAY

From: Date: Wed, 05 Feb 2014 20:31:54 +0000
Subject: Bug #66649 [Opn->Nab]: token_get_all() does not tag new bracket array syntax as T_ARRAY
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184172@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66649&edit=1 ID: 66649 Updated by: nikic@php.net Reported by: bishop@php.net Summary: token_get_all() does not tag new bracket array syntax as T_ARRAY -Status: Open +Status: Not a bug Type: Bug Package: Scripting Engine problem Operating System: n/a PHP Version: 5.4.24 Block user comment: N Private report: N New Comment: T_ARRAY represents the keyword "array", not the semantic concept of an array. The '[' will be provided like any other single-character token. Previous Comments: ------------------------------------------------------------------------ [2014-02-05 20:09:21] bishop@php.net Description: ------------ token_get_all() identifies the start of an array using array () syntax with T_ARRAY. I expected token_get_all() to do the same for arrays using the new bracket [] syntax. Instead, token_get_all() ignores bracket style array notation altogether. This means that anyone relying on T_ARRAY parsing will not be able to see the new array syntax notation. Test script: --------------- <?php array_map( function ($string) { array_map( function ($token) { if (is_array($token)) { echo token_name($token[0]) . ', '; } }, token_get_all($string) ); echo PHP_EOL; }, array ('<?php $a = array (1);', '<?php $a = [1]') ); Expected result: ---------------- T_OPEN_TAG, T_VARIABLE, T_WHITESPACE, T_WHITESPACE, T_ARRAY, T_WHITESPACE, T_LNUMBER, T_OPEN_TAG, T_VARIABLE, T_WHITESPACE, T_WHITESPACE, T_ARRAY, T_WHITESPACE, T_LNUMBER, Actual result: -------------- T_OPEN_TAG, T_VARIABLE, T_WHITESPACE, T_WHITESPACE, T_ARRAY, T_WHITESPACE, T_LNUMBER, T_OPEN_TAG, T_VARIABLE, T_WHITESPACE, T_WHITESPACE, T_LNUMBER, ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=66649&edit=1

« previous php.bugs (#184172) next »