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

ID: 17818
Updated by: gsherwood@squiz.net
Reported By: amace at hollytree dot co dot uk
Summary: Exception thrown when PHPCS mis-identifies local
variable as a class variable.
-Status: Open
+Status: Closed
Type: Bug
Package: PHP_CodeSniffer
Operating System: Mac OS X
Package Version: 1.2.2
PHP Version: 5.3.2
-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.

This is a duplicate of bug #17420 , which is fixed in the 1.3.0a1
release.

If you don't have your own custom standard, you can upgrade to this
version with no problems. Otherwise you'd need to convert your
standard's PHP class into a ruleset.xml file, which I don't have doc for
yet.


Previous Comments:
------------------------------------------------------------------------

[2010-08-25 14:22:16] #4fe2cdc158d07c3f128

Description:
------------
As shown in the example, if a comment appears between the
method signature and the opening brace with mention of
variables in it, PHPCS appears to think these variables are class
members. Upon usage of those variables it throws an exception
in the Zend ValidVariableName sniff.

Test script:
---------------
phpcs --standard=Zend Foo.php

Foo.php contains:
<?php
class Foo {

function bar($baz)
// $foo = Something
// $baz = Something else
{
if (true) {
$baz = intval($baz);
}
}

}


Expected result:
----------------
Standard output of coding standard violations.

Actual result:
--------------
PHP Fatal error: Uncaught PHP_CodeSniffer_Exception:
$stackPtr is not a class member var in
/usr/lib/php/PHP/CodeSniffer/Standards/Zend/Sniffs/NamingC
onventions/ValidVariableNameSniff.php on line 154
#0
/usr/lib/php/PHP/CodeSniffer/Standards/Zend/Sniffs/NamingC
onventions/ValidVariableNameSniff.php(154):
PHP_CodeSniffer_File->getMemberProperties(39)
#1
/usr/lib/php/PHP/CodeSniffer/Standards/AbstractVariableSniff.
php(154):
Zend_Sniffs_NamingConventions_ValidVariableNameSniff-
processMemberVar(Object(PHP_CodeSniffer_File), 39)
#2
/usr/lib/php/PHP/CodeSniffer/Standards/AbstractScopeSniff.ph
p(190):
PHP_CodeSniffer_Standards_AbstractVariableSniff-
processTokenWithinScope(Object(PHP_CodeSniffer_File), 39,
1)
#3 /usr/lib/php/PHP/CodeSniffer/File.php(431):
PHP_CodeSniffer_Standards_AbstractScopeSniff-
process(Object(PHP_CodeSniffer_File), 39)
#4 /usr/lib/php/PHP/CodeSniffer.php(900):
PHP_CodeSniffer_File->start(NULL)
#5 /usr/lib/php/PHP/CodeSniffer.php(815): PHP_CodeSniffer-
_processFile('/Users/amace/Si...', NULL)
#6 /usr/lib/php/PHP in /usr/lib/php/PHP/CodeSniffer/File.php
on line 2047

------------------------------------------------------------------------

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedAug 26, '10 at 1:04a
activeAug 26, '10 at 1:04a
posts1
users1
websitepear.php.net

1 user in discussion

Gsherwood: 1 post

People

Translate

site design / logo © 2022 Grokbase