Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trailing comma on array declaration #5

Closed
GaryJones opened this issue Dec 29, 2011 · 5 comments
Closed

Trailing comma on array declaration #5

GaryJones opened this issue Dec 29, 2011 · 5 comments

Comments

@GaryJones
Copy link
Member

Originally reported at http://pear.php.net/bugs/bug.php?id=19162 but as https://github.com/pear/PHP_CodeSniffer/tree/master/CodeSniffer/Standards/PEAR/Sniffs doesn't appear to have a Arrays directory (as I assumed the WP were adapted from the PEAR CS) then it's worth reporting here too.

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?
);

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

@ghost ghost assigned mrchrisadams Jan 2, 2012
@mrchrisadams
Copy link
Contributor

Thanks for flagging this up Gary, I'll have a look this later this week.

@gsherwood
Copy link

This sniff is actually from the Squiz standard, but it has a few IF statements commented out, which are producing the error. If you have a way to reproduce the issue using the sniff included from the Squiz standard, please submit a bug report for PHP_CodeSniffer.

@GaryJones
Copy link
Member Author

Running PHPCS against the same file with the Squiz standard did NOT produce the error above.

@Rarst
Copy link
Contributor

Rarst commented May 6, 2013

Probably duplicate of #9 and caused by parenthesis.

@westonruter
Copy link
Member

Fixed in #59

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants