Doc #52526 [Com]: Documentation for T_STRING implying bad programming style

From: Date: Wed, 29 Sep 2010 17:57:42 +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-5148@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: stephan dot soller at helionweb dot de 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: I'm sorry for the duplicate (#52927). I've tested the original syntax "$a[b]" and it reports b as a T_STRING token. If I understand this correctly within strings it's permitted to use identifiers as string indices to avoid complex escaping. However outside of a string it's (rightfully) considered bad style. If this is correct T_STRING is ALWAYS an identifier and "$a[b]" is just a special case where it's ok to use an identifier as a string index. Previous Comments: ------------------------------------------------------------------------ [2010-09-27 09:58:34] salathe@php.net See also #52927 referencing the misinformation from the committed "fix" for this bug. ------------------------------------------------------------------------ [2010-08-05 13:01:12] + at ni-po dot com Better turn it round or it is ambiguous (array index inside identifier one could think): <row> <entry><constant>T_STRING</constant></entry> <entry>identifier, "$a[a]"</entry> <entry>identifier ( e.g. function or class name) or string array index inside string</entry> </row> ------------------------------------------------------------------------ [2010-08-05 12:37:24] + at ni-po dot com 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> ------------------------------------------------------------------------ [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. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/bug.php?id=52526 -- Edit this bug report at http://bugs.php.net/bug.php?id=52526&edit=1

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