Edit report at http://pear.php.net/bugs/bug.php?id=17860&edit=1

ID: 17860
Updated by: gsherwood@squiz.net
Reported By: ljmaskey at gmail dot com
Summary: isReference function fails with references in array
-Status: Open
+Status: Closed
Type: Bug
Package: PHP_CodeSniffer
Operating System: Windows XP
Package Version: 1.2.2
PHP Version: 5.2.9
-Assigned To:
+Assigned To: squiz
Roadmap Versions:
New Comment:

-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: squiz
This bug has been fixed in SVN.

If this was a documentation problem, the fix will appear on pear.php.net
by the end of next Sunday (CET).

If this was a problem with the pear.php.net website, the change should
be live shortly.

Otherwise, the fix will appear in the package's next release.

Thank you for the report and for helping us make PEAR better.

Previous Comments:

[2010-09-10 15:18:15] ljmaskey

When tokenising an array construct whose parameters are references, the
isReference function in File.php incorrectly returns false.

Test script:

$file = new PHP_CodeSniffer_File();
$a = "a";
$b = array(&$a);

echo $a;
$b[0] = "A";
echo $a;
echo 'Looking at tokens 14 and 15: ' . $file->getTokensAsString(14, 2) .
echo 'Is token 14 a reference? ' . ($file->isReference(14) ? 'Yes' :
'No') . "\n";

Expected result:
Expected isReference to return true for the token that is the ampersand
before the $a variable on line 9.

Actual result:
At the moment, it returns false.

This can be resolved by changing line 2147 (in v1.2.2) from:
if ($owner['code'] === T_FUNCTION) {

if (in_array($owner['code'], array(T_FUNCTION, T_ARRAY), true)) {


Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
postedNov 19, '10 at 3:18a
activeNov 19, '10 at 3:18a

1 user in discussion

Gsherwood: 1 post



site design / logo © 2022 Grokbase