Bug #17420 [Asn]: Uncaught exception when comment before function brace
| From: | gsherwood at squiz dot net | Date: | Mon, 21 Jun 2010 02:50:35 +0000 |
| Subject: | Bug #17420 [Asn]: Uncaught exception when comment before function brace | ||
| References: | 1 | Groups: | php.pear.bugs |
| Request: | Send a blank email to pear-bugs+get-3963@lists.php.net to get a copy of this message | ||
Edit report at http://pear.php.net/bugs/bug.php?id=17420&edit=1
ID: 17420
Updated by: gsherwood@squiz.net
Reported By: andreazzini at gmail dot com
-Summary: Uncaught exception
+Summary: Uncaught exception when comment before function brace
Status: Assigned
Type: Bug
Package: PHP_CodeSniffer
Operating System: Debian Lenny (testing) x64
Package Version: 1.2.2
PHP Version: 5.3.2
Assigned To: squiz
Roadmap Versions:
New Comment:
-Summary: Uncaught exception
+Summary: Uncaught exception when comment before function brace
Previous Comments:
------------------------------------------------------------------------
[2010-06-01 07:51:39] endi
Thank you for replying.
Yes, in the meantime i did some good old trial-and-error and isolated
the problem in my code (and failed to report it here - sorry for that).
PHPCS ran perfectly after I moved those blocks after the opening {.
Anyway, the problem was kind of obscure, and the traceback was no good
in solving anything, so I still wish PHPCS reported a little more
explicit error descriptions... and possibly expected (arbitrarily long?)
block comments mostly anywhere :)
------------------------------------------------------------------------
[2010-06-01 05:11:36] squiz
-Assigned To:
+Assigned To: squiz
First, thank you for supplying code. It is almost impossible to debug
issues like this
without code.
Second, the issue is caused by the comments you put between the function
declaration and the opening function brace. PHPCS, when checking for a
brace,
stops looking after a couple of lines and assumes it wont find anything.
This is to
stop PHPCS looking through massive files for braces that may not be
there (like
inline blocks and abstract functions).
I'll try and get it to ignore the rule for comments, but moving them to
standard
phpdoc-style function comments will stop PHPCS from being confused as
well.
------------------------------------------------------------------------
[2010-05-20 18:01:32] endi
No way to attach a PHP file - a pretty bad limitation for the bug
tracking system IMHO.
You can download the file at
http://allievi.sssup.it/user/endi/JIncludes.php.txt
------------------------------------------------------------------------
[2010-05-20 17:55:23] endi
Description:
------------
PHP Fatal error: Uncaught PHP_CodeSniffer_Exception: $stackPtr is not a
class member var in
/usr/share/php/PHP/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php
on line 51
I am attaching the file being tested, which is 237 lines x 8KB. It is
not a stand alone file, rather a Joomla! plugin, so you can test it with
phpcs but not run it directly.
Actual result:
--------------
PHP Fatal error: Uncaught PHP_CodeSniffer_Exception: $stackPtr is not a
class member var in
/usr/share/php/PHP/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php
on line 51
#0
/usr/share/php/PHP/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php(51):
PHP_CodeSniffer_File->getMemberProperties(336)
#1
/usr/share/php/PHP/CodeSniffer/Standards/AbstractVariableSniff.php(154):
PEAR_Sniffs_NamingConventions_ValidVariableNameSniff->processMemberVar(Object(PHP_CodeSniffer_File),
336)
#2 /usr/share/php/PHP/CodeSniffer/Standards/AbstractScopeSniff.php(190):
PHP_CodeSniffer_Standards_AbstractVariableSniff->processTokenWithinScope(Object(PHP_CodeSniffer_File),
336, 40)
#3 /usr/share/php/PHP/CodeSniffer/File.php(431):
PHP_CodeSniffer_Standards_AbstractScopeSniff->process(Object(PHP_CodeSniffer_File),
336)
#4 /usr/share/php/PHP/CodeSniffer.php(900):
PHP_CodeSniffer_File->start(NULL)
#5 /usr/share/php/PHP/CodeSniffer.php(815):
PHP_CodeSniffer->_processFile('/home/andrea/tr...', NULL)
#6 in /usr/share/php/PHP/CodeSniffer/File.php on line 2047
------------------------------------------------------------------------
--
Edit this bug report at http://pear.php.net/bugs/bug.php?id=17420&edit=1