Doc #52526 [Com]: Documentation for T_STRING implying bad programming style
| From: | + at ni-po dot com | Date: | Thu, 05 Aug 2010 10:37:25 +0000 |
| Subject: | Doc #52526 [Com]: Documentation for T_STRING implying bad programming style | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-4797@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52526&edit=1
ID: 52526
Comment by: + at ni-po dot com
Reported by: + at ni-po dot com
Summary: Documentation for T_STRING implying bad programming
style
Status: Re-Opened
Type: Documentation Problem
Package: Documentation problem
PHP Version: Irrelevant
Assigned To: kalle
Block user comment: N
New Comment:
salathe is perfectly right (in all points). I didn't realize, that
"$a[a]" is valid within a string. (Actually I had my thoughts on the
complex variable syntax "{$a[a]}" there it *would* be a notice.) I am
sorry for that. But the point about not mentioning identifiers like
class and function name is still valid.
<row>
<entry><constant>T_STRING</constant></entry>
<entry>"$a[a]", identifier</entry>
<entry>string array index inside string or identifier, e.g. function
or class name</entry>
</row>
Previous Comments:
------------------------------------------------------------------------
[2010-08-04 12:09:04] salathe@php.net
The change does not address the issue. Changing the
"$a[a]" to
"$a['a']" only
serves to break the example (literally, it will generate a parse
error).
The point, I think, was that the reporter (mistakenly) did not like the
idea of
using a "bad practice". However, "$a[a]" is perfectly acceptable
(within a
string!) and will not generate any notices.
The description could do with mentioning that T_STRING also means
class/function/etc. names as well.
------------------------------------------------------------------------
[2010-08-04 11:20:56] kalle@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
------------------------------------------------------------------------
[2010-08-04 11:20:48] kalle@php.net
Automatic comment from SVN on behalf of kalle
Revision: http://svn.php.net/viewvc/?view=revision&revision=301848
Log: Fixed bug #52526 (Documentation for T_STRING implying bad
programming style)
------------------------------------------------------------------------
[2010-08-03 18:17:31] + at ni-po dot com
Description:
------------
The appendix token documentation for T_STRING implies a bad programming
style. As an example it gives "$a[a]". According to the PHP
documentation this is incorrect syntax, the correct one is
"$a['a']"
(which would result in a T_CONSTANT_ENCAPSED_STRING, not T_STRING.)
"$a[a]" works, but only throwing a notice.
Furthermore all the other uses of this allrounder-token are not
mentioned (e.g. for function, class and method names, constant names,
..., ...)
Proposed text:
<row>
<entry><constant>T_STRING</constant></entry>
<entry>identifier</entry>
<entry>identifier, e.g. function or class name</entry>
</row>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52526&edit=1