Doc #52927 [NEW]: T_STRING token used for function and class names but documented for strings

From: Date: Sun, 26 Sep 2010 20:19:16 +0000
Subject: Doc #52927 [NEW]: T_STRING token used for function and class names but documented for strings
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-5120@lists.php.net to get a copy of this message
From: Operating system: PHP version: 5.3.3 Package: Documentation problem Bug Type: Documentation Problem Bug description:T_STRING token used for function and class names but documented for strings Description: ------------ The documentation page about the PHP parser tokens (http://php.net/tokens) states that the T_STRING token is an "string array index inside string" with this example code: "$a['a']". Instead of this the T_STRING token is used for general symbol names (e.g. functions, classes, interfaces, constants). The attached CLI test script lists the tokens for the example code of the documentation ("$a['a']") and it does not contain any T_STRING tokens. The second test source code with a function, class and constant however contains three T_STRING tokens, one for each symbol name (fun, TestClass and tconst). I'm using the Ubuntu 10.04 PHP package: $ php -v PHP 5.3.2-1ubuntu4.5 with Suhosin-Patch (cli) (built: Sep 17 2010 13:49:46) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies It would be nice if the documentation can mention the correct use of T_STRING. Test script: --------------- <?php function inspect_tokens($code){ print('Tokens for code: ' . $code . "\n"); $tokens = token_get_all($code); foreach($tokens as $token) print( (is_string($token) ? $token : token_name($token[0]) . ': ' . $token[1]) . "\n"); } inspect_tokens('<?php $a = array("a" => 1); $s = "$a[\'a\']"; ?>'); print("\n----------\n\n"); inspect_tokens('<?php function test(){} class Test(){ const test = 123; } ?>'); ?> -- Edit bug report at http://bugs.php.net/bug.php?id=52927&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52927&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52927&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52927&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=52927&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52927&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=52927&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=52927&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=52927&r=needscript Try newer version: http://bugs.php.net/fix.php?id=52927&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=52927&r=support Expected behavior: http://bugs.php.net/fix.php?id=52927&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=52927&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=52927&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=52927&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52927&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=52927&r=dst IIS Stability: http://bugs.php.net/fix.php?id=52927&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=52927&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=52927&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=52927&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=52927&r=mysqlcfg

« previous php.doc.bugs (#5120) next »