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

ID: 19162
Updated by: cweiske@php.net
Reported By: gary at garyjones dot co dot uk
Summary: Trailing comma on array declaration
Status: Open
Type: Bug
Package: PHP_CodeSniffer
Operating System: Windows 7
Package Version: 1.3.2
PHP Version: 5.3.8
Roadmap Versions:
New Comment:

The problem's source is probably
https://github.com/mrchrisadams/WordPress-Coding-Standards/blob/master/Sniffs/Arrays/ArrayDeclarationSniff.php#L431


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

[2011-12-29 10:37:50] garyj

Description:
------------
Running PHP_CodeSniffer via a phing build on Jenkins, I get that
one of the arrays has no trailing comma, yet I believe it has.

It's only a single item in the array, and the value of it is multiple
nested function calls which itself includes an array.

I've got a similar bit of code lower down in my file which also
produces the same error.

Test script:
---------------
$actions = array(
'install' => sprintf( // Line 1179
'<a href="%1$s" title="Install %2$s">Install</a>',
wp_nonce_url(
add_query_arg(
array(
'page' => TGM_Plugin_Activation::$instance->menu,
'plugin' => $item['slug'],
'plugin_name' => $item['sanitized_plugin'],
'plugin_source' => $item['url'],
'tgmpa-install' => 'install-plugin',
),
admin_url( TGM_Plugin_Activation::$instance->parent_url_slug )
),
'tgmpa-install'
),
$item['sanitized_plugin']
), // <-- This comma not seen by PHP_CodeSniffer?
);

Expected result:
----------------
I'd expect no array trailing comma warning to appear.

Actual result:
--------------
class-tgm-plugin-activation.php:1179, ArrayDeclaration, Priority:
High
Each line in an array declaration must end in a comma

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

Search Discussions

  • Cweiske at Dec 29, 2011 at 10:19 am
    Edit report at https://pear.php.net/bugs/bug.php?id=19162&edit=1

    ID: 19162
    Updated by: cweiske@php.net
    Reported By: gary at garyjones dot co dot uk
    Summary: Trailing comma on array declaration
    -Status: Open
    +Status: Bogus
    Type: Bug
    Package: PHP_CodeSniffer
    Operating System: Windows 7
    Package Version: 1.3.2
    PHP Version: 5.3.8
    Roadmap Versions:
    New Comment:

    -Status: Open
    +Status: Bogus
    Moved to
    https://github.com/mrchrisadams/WordPress-Coding-Standards/issues/5


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

    [2011-12-29 11:06:59] cweiske

    The problem's source is probably
    https://github.com/mrchrisadams/WordPress-Coding-Standards/blob/master/Sniffs/Arrays/ArrayDeclarationSniff.php#L431

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

    [2011-12-29 10:37:50] garyj

    Description:
    ------------
    Running PHP_CodeSniffer via a phing build on Jenkins, I get that
    one of the arrays has no trailing comma, yet I believe it has.

    It's only a single item in the array, and the value of it is multiple
    nested function calls which itself includes an array.

    I've got a similar bit of code lower down in my file which also
    produces the same error.

    Test script:
    ---------------
    $actions = array(
    'install' => sprintf( // Line 1179
    '<a href="%1$s" title="Install %2$s">Install</a>',
    wp_nonce_url(
    add_query_arg(
    array(
    'page' => TGM_Plugin_Activation::$instance->menu,
    'plugin' => $item['slug'],
    'plugin_name' => $item['sanitized_plugin'],
    'plugin_source' => $item['url'],
    'tgmpa-install' => 'install-plugin',
    ),
    admin_url( TGM_Plugin_Activation::$instance->parent_url_slug )
    ),
    'tgmpa-install'
    ),
    $item['sanitized_plugin']
    ), // <-- This comma not seen by PHP_CodeSniffer?
    );

    Expected result:
    ----------------
    I'd expect no array trailing comma warning to appear.

    Actual result:
    --------------
    class-tgm-plugin-activation.php:1179, ArrayDeclaration, Priority:
    High
    Each line in an array declaration must end in a comma

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedDec 29, '11 at 10:06a
activeDec 29, '11 at 10:19a
posts2
users1
websitepear.php.net

1 user in discussion

Cweiske: 2 posts

People

Translate

site design / logo © 2022 Grokbase