mrchrisadams/WordPress-Coding-Standards — Issue #5: Trailing comma on array declaration
Author: GaryJones
Created: 2011-12-29 10:15:52+00:00
State: open

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
'Install',
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