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

ID: 19521
Updated by: gsherwood@squiz.net
Reported By: hinikato at mail dot ru
Summary: The PSR-2 standard don't recognize valid Closure
arguments.
-Status: Open
+Status: Feedback
Type: Bug
Package: PHP_CodeSniffer
Operating System: Windows 7
Package Version: 1.3.5
PHP Version: 5.3.9
-Assigned To:
+Assigned To: squiz
Roadmap Versions:
New Comment:

-Status: Open
+Status: Feedback
-Assigned To:
+Assigned To: squiz
The PSR-2 standard in 1.3.5 is not complete, which is why it is not
listed in the
changelog and why I haven't announced it.

If you want to test the in-progress PSR standards, you need to clone the
git repo and
use PHPCS directly from there:
https://github.com/squizlabs/PHP_CodeSniffer

This issue was fixed when the closure part of the standard was written,
just after the
1.3.5 release. But I'm still interested in testing, so would love to
know if the code in
the git repo is working for you when testing closures.


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

[2012-07-20 04:00:49] hinikato

Description:
------------
The phpcs reports:
phpcs --standard=PSR2 lib/Myak/Version.php

FILE: D:\system\home\project\myak2\src\lib\Myak\Version.php
--------------------------------------------------------------------------------
FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
18 | ERROR | The first parameter of a multi-line function declaration
must be
on the line after the opening bracket
--------------------------------------------------------------------------------

But according PSR-2 this report should not occur.

Here is example from the PSR-2 README:
$closureWithArgs = function ($arg1, $arg2) {
// body
};


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

class Version
{
const MAJOR = 0;
const MINOR = 1;
const TINY = 0;
const PRE = null;

public function __toString()
{
return self::current();
}

public static function current()
{
$callback = function ($arg) {
if ($arg === null) {
return false;
}

return true;
};
return implode(
'.',
array_filter(
array(
self::MAJOR,
self::MINOR,
self::TINY,
self::PRE
),
$callback
)
);
}
}

Expected result:
----------------
The ERROR should not be displayed.

Actual result:
--------------
FILE: D:\system\home\project\myak2\src\lib\Myak\Version.php
--------------------------------------------------------------------------------
FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
18 | ERROR | The first parameter of a multi-line function declaration
must be
on the line after the opening bracket
--------------------------------------------------------------------------------

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

Search Discussions

  • Hinikato at Aug 3, 2012 at 5:38 am
    Edit report at https://pear.php.net/bugs/bug.php?id=19521&edit=1

    ID: 19521
    Updated by: hinikato@mail.ru
    Reported By: hinikato at mail dot ru
    Summary: The PSR-2 standard don't recognize valid Closure
    arguments.
    Status: Feedback
    Type: Bug
    Package: PHP_CodeSniffer
    Operating System: Windows 7
    Package Version: 1.3.5
    PHP Version: 5.3.9
    Assigned To: squiz
    Roadmap Versions:
    New Comment:

    Hi,

    Okay, I checked phpcs from github and it handles the Version.php file
    and Closures in it properly.

    Thank you for this fix.


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

    [2012-07-23 05:10:55] squiz

    -Status: Open
    +Status: Feedback
    -Assigned To:
    +Assigned To: squiz
    The PSR-2 standard in 1.3.5 is not complete, which is why it is not
    listed in the
    changelog and why I haven't announced it.

    If you want to test the in-progress PSR standards, you need to clone the
    git repo and
    use PHPCS directly from there:
    https://github.com/squizlabs/PHP_CodeSniffer

    This issue was fixed when the closure part of the standard was written,
    just after the
    1.3.5 release. But I'm still interested in testing, so would love to
    know if the code in
    the git repo is working for you when testing closures.

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

    [2012-07-20 04:00:49] hinikato

    Description:
    ------------
    The phpcs reports:
    phpcs --standard=PSR2 lib/Myak/Version.php

    FILE: D:\system\home\project\myak2\src\lib\Myak\Version.php
    --------------------------------------------------------------------------------
    FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
    --------------------------------------------------------------------------------
    18 | ERROR | The first parameter of a multi-line function declaration
    must be
    on the line after the opening bracket
    --------------------------------------------------------------------------------

    But according PSR-2 this report should not occur.

    Here is example from the PSR-2 README:
    $closureWithArgs = function ($arg1, $arg2) {
    // body
    };


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

    class Version
    {
    const MAJOR = 0;
    const MINOR = 1;
    const TINY = 0;
    const PRE = null;

    public function __toString()
    {
    return self::current();
    }

    public static function current()
    {
    $callback = function ($arg) {
    if ($arg === null) {
    return false;
    }

    return true;
    };
    return implode(
    '.',
    array_filter(
    array(
    self::MAJOR,
    self::MINOR,
    self::TINY,
    self::PRE
    ),
    $callback
    )
    );
    }
    }

    Expected result:
    ----------------
    The ERROR should not be displayed.

    Actual result:
    --------------
    FILE: D:\system\home\project\myak2\src\lib\Myak\Version.php
    --------------------------------------------------------------------------------
    FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
    --------------------------------------------------------------------------------
    18 | ERROR | The first parameter of a multi-line function declaration
    must be
    on the line after the opening bracket
    --------------------------------------------------------------------------------

    ------------------------------------------------------------------------
  • Hinikato at Aug 3, 2012 at 5:38 am
    Edit report at https://pear.php.net/bugs/bug.php?id=19521&edit=1

    ID: 19521
    Updated by: hinikato@mail.ru
    Reported By: hinikato at mail dot ru
    Summary: The PSR-2 standard don't recognize valid Closure
    arguments.
    -Status: Feedback
    +Status: Closed
    Type: Bug
    Package: PHP_CodeSniffer
    Operating System: Windows 7
    Package Version: 1.3.5
    PHP Version: 5.3.9
    Assigned To: squiz
    Roadmap Versions:
    New Comment:

    -Status: Feedback
    +Status: Closed



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

    [2012-07-23 12:06:54] hinikato

    Hi,

    Okay, I checked phpcs from github and it handles the Version.php file
    and Closures in it properly.

    Thank you for this fix.

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

    [2012-07-23 05:10:55] squiz

    -Status: Open
    +Status: Feedback
    -Assigned To:
    +Assigned To: squiz
    The PSR-2 standard in 1.3.5 is not complete, which is why it is not
    listed in the
    changelog and why I haven't announced it.

    If you want to test the in-progress PSR standards, you need to clone the
    git repo and
    use PHPCS directly from there:
    https://github.com/squizlabs/PHP_CodeSniffer

    This issue was fixed when the closure part of the standard was written,
    just after the
    1.3.5 release. But I'm still interested in testing, so would love to
    know if the code in
    the git repo is working for you when testing closures.

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

    [2012-07-20 04:00:49] hinikato

    Description:
    ------------
    The phpcs reports:
    phpcs --standard=PSR2 lib/Myak/Version.php

    FILE: D:\system\home\project\myak2\src\lib\Myak\Version.php
    --------------------------------------------------------------------------------
    FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
    --------------------------------------------------------------------------------
    18 | ERROR | The first parameter of a multi-line function declaration
    must be
    on the line after the opening bracket
    --------------------------------------------------------------------------------

    But according PSR-2 this report should not occur.

    Here is example from the PSR-2 README:
    $closureWithArgs = function ($arg1, $arg2) {
    // body
    };


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

    class Version
    {
    const MAJOR = 0;
    const MINOR = 1;
    const TINY = 0;
    const PRE = null;

    public function __toString()
    {
    return self::current();
    }

    public static function current()
    {
    $callback = function ($arg) {
    if ($arg === null) {
    return false;
    }

    return true;
    };
    return implode(
    '.',
    array_filter(
    array(
    self::MAJOR,
    self::MINOR,
    self::TINY,
    self::PRE
    ),
    $callback
    )
    );
    }
    }

    Expected result:
    ----------------
    The ERROR should not be displayed.

    Actual result:
    --------------
    FILE: D:\system\home\project\myak2\src\lib\Myak\Version.php
    --------------------------------------------------------------------------------
    FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
    --------------------------------------------------------------------------------
    18 | ERROR | The first parameter of a multi-line function declaration
    must be
    on the line after the opening bracket
    --------------------------------------------------------------------------------

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedAug 3, '12 at 5:37a
activeAug 3, '12 at 5:38a
posts3
users2
websitepear.php.net

2 users in discussion

Hinikato: 2 posts Gsherwood: 1 post

People

Translate

site design / logo © 2022 Grokbase