Doc #52927 [Opn->Dup]: T_STRING token used for function and class names but documented for strings
| From: | salathe@php.net | Date: | Mon, 27 Sep 2010 07:57:03 +0000 |
| Subject: | Doc #52927 [Opn->Dup]: T_STRING token used for function and class names but documented for strings | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-5121@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52927&edit=1
ID: 52927
Updated by: salathe@php.net
Reported by: stephan dot soller at helionweb dot de
Summary: T_STRING token used for function and class names but
documented for strings
-Status: Open
+Status: Duplicate
Type: Documentation Problem
Package: Documentation problem
PHP Version: 5.3.3
Block user comment: N
New Comment:
See #52526
Previous Comments:
------------------------------------------------------------------------
[2010-09-26 22:19:15] stephan dot soller at helionweb dot de
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 this bug report at http://bugs.php.net/bug.php?id=52927&edit=1