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

ID: 19687
Updated by: gsherwood@squiz.net
Reported By: stephen at rees-carter dot net
-Summary: Anonymous functions marked as indented incorrectly in
PSR2
+Summary: Anonymous functions inside arrays marked as indented
incorrectly in PSR2
Status: Open
Type: Bug
Package: PHP_CodeSniffer
Operating System: Ubuntu 12.10
Package Version: SVN
PHP Version: 5.4.6
-Assigned To:
+Assigned To: squiz
Roadmap Versions:
New Comment:

-Summary: Anonymous functions marked as indented
incorrectly in PSR2
+Summary: Anonymous functions inside arrays marked as
indented incorrectly in PSR2
-Assigned To:
+Assigned To: squiz



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

[2012-10-31 19:48:59] valorin

Description:
------------
Anonymous functions that are nested within an Array within a Function
are incorrectly
marked as having the wrong indentation in the PSR2 standard.

I've tested with the latest commit from GitHub (2b1adc7).

Test script:
---------------
<?php
namespace Testing;

class AnonymousFn
{
public function getAnonFn()
{
return array(
'functions' => Array(
'function1' => function ($a, $b, $c) {
$a = $b + $c;
$b = $c / 2;
return Array($a, $b, $c);
},
),
);
}
}


Expected result:
----------------
There should be no coding violations reported for this code.

Actual result:
--------------
valorin@gandalf:~/workspace/$ php ./vendor/PHP_CodeSniffer/scripts/phpcs
--
standard=PSR2
./AnonymousFn.php

FILE: /home/valorin/workspace/AnonymousFn.php
--------------------------------------------------------------------------------
FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
10 | ERROR | Line indented incorrectly; expected 8 spaces, found 16
--------------------------------------------------------------------------------

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


--
Edit this bug report at https://pear.php.net/bugs/bug.php?id=19687&edit=1

Search Discussions

  • Gsherwood at Oct 31, 2012 at 10:01 pm
    Edit report at https://pear.php.net/bugs/bug.php?id=19687&edit=1

    ID: 19687
    Updated by: gsherwood@squiz.net
    Reported By: stephen at rees-carter dot net
    Summary: Anonymous functions inside arrays marked as indented
    incorrectly in PSR2
    -Status: Assigned
    +Status: Closed
    Type: Bug
    Package: PHP_CodeSniffer
    Operating System: Ubuntu 12.10
    Package Version: SVN
    PHP Version: 5.4.6
    Assigned To: squiz
    Roadmap Versions:
    New Comment:

    -Status: Assigned
    +Status: Closed
    Fixed in github repo:
    https://github.com/squizlabs/PHP_CodeSniffer/commit/20ea734e1a1689a8ea581068
    12af6e1719db8308


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

    [2012-10-31 21:59:38] squiz

    -Summary: Anonymous functions marked as indented
    incorrectly in PSR2
    +Summary: Anonymous functions inside arrays marked as
    indented incorrectly in PSR2
    -Assigned To:
    +Assigned To: squiz


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

    [2012-10-31 19:48:59] valorin

    Description:
    ------------
    Anonymous functions that are nested within an Array within a Function
    are incorrectly
    marked as having the wrong indentation in the PSR2 standard.

    I've tested with the latest commit from GitHub (2b1adc7).

    Test script:
    ---------------
    <?php
    namespace Testing;

    class AnonymousFn
    {
    public function getAnonFn()
    {
    return array(
    'functions' => Array(
    'function1' => function ($a, $b, $c) {
    $a = $b + $c;
    $b = $c / 2;
    return Array($a, $b, $c);
    },
    ),
    );
    }
    }


    Expected result:
    ----------------
    There should be no coding violations reported for this code.

    Actual result:
    --------------
    valorin@gandalf:~/workspace/$ php ./vendor/PHP_CodeSniffer/scripts/phpcs
    --
    standard=PSR2
    ./AnonymousFn.php

    FILE: /home/valorin/workspace/AnonymousFn.php
    --------------------------------------------------------------------------------
    FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
    --------------------------------------------------------------------------------
    10 | ERROR | Line indented incorrectly; expected 8 spaces, found 16
    --------------------------------------------------------------------------------

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


    --
    Edit this bug report at https://pear.php.net/bugs/bug.php?id=19687&edit=1

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedOct 31, '12 at 9:59p
activeOct 31, '12 at 10:01p
posts2
users1
websitepear.php.net

1 user in discussion

Gsherwood: 2 posts

People

Translate

site design / logo © 2022 Grokbase