Bug #19290 [Opn->Csd]: Generic indent sniffer fails for anonymous functions
| From: | gsherwood at squiz dot net | Date: | Wed, 22 Feb 2012 00:55:41 +0000 |
| Subject: | Bug #19290 [Opn->Csd]: Generic indent sniffer fails for anonymous functions | ||
| References: | 1 | Groups: | php.pear.bugs |
| Request: | Send a blank email to pear-bugs+get-8302@lists.php.net to get a copy of this message | ||
Edit report at https://pear.php.net/bugs/bug.php?id=19290&edit=1
ID: 19290
Updated by: gsherwood@squiz.net
Reported By: ashutosh at harekrishna dot ru
Summary: Generic indent sniffer fails for anonymous functions
-Status: Open
+Status: Closed
Type: Bug
Package: PHP_CodeSniffer
Operating System: Linux
Package Version: 1.3.2
PHP Version: 5.3.3
-Assigned To:
+Assigned To: squiz
Roadmap Versions:
New Comment:
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: squiz
Fixed in Git repo:
https://github.com/squizlabs/PHP_CodeSniffer/commit/53ec9ec0157c749bf92a566a8
8d1ffca4fc1e283
Previous Comments:
------------------------------------------------------------------------
[2012-02-13 11:44:16] ashutosh108
Description:
------------
When I run
phpcs --standard=Generic --
sniffs=Generic.WhiteSpace.ScopeIndent.Incorrect phpcs-
test.php
(with phpcs-test.php being the file from "Test script") I see
error message about indent inside anonymous function: Line
indented incorrectly; expected 4 spaces, found 8
Basically, phpcs suggests me to indent
$a = 403;
at 8 chars (I agree here) but indent the next line
if ($a === 404) {
at 4 chars.
I think it's a bug.
Note: Originally I came upon this using PEAR coding standard,
but traced it towards the "Generic". When using Zend coding
standard, this file gives no errors.
I found similar closed bug https://pear.php.net/bugs/bug.php?
id=18657 but this one is still reproducible in 1.3.2.
Test script:
---------------
<?php
// test with e.g. phpcs --standard=Generic
--sniffs=Generic.WhiteSpace.ScopeIndent.Incorrect phpcs-test.php
some_function(
function() {
$a = 403;
if ($a === 404) {
}
}
);
Expected result:
----------------
I expect no errors reported, whitespace indenting in this file looks
fine to me.
Actual result:
--------------
FILE: /home/HarekrRu/tmp-www/phpcs-test.php
------------------------------------------------------------------------
--------
FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
------------------------------------------------------------------------
--------
5 | ERROR | Line indented incorrectly; expected 4 spaces,
found 8
------------------------------------------------------------------------
--------
Time: 1 second, Memory: 2.50Mb
------------------------------------------------------------------------
--
Edit this bug report at https://pear.php.net/bugs/bug.php?id=19290&edit=1