Currently Drupal CS assuming wrong the declaration that you can see on the screenshot, however PHPStorm allows that spec. Would be nice to have support for variadic arguments, introduced in PHP7.

| Comment | File | Size | Author |
|---|---|---|---|
| #9 | coder-variadics-2878783-9.patch | 1.38 KB | zero2one |
| #5 | coder-variadics-2878783-5.patch | 1.04 KB | zero2one |
| #3 | coder-variadics-2878783-3.patch | 973 bytes | dsnopek |
| phpcs_drupal_variadic.png | 140.03 KB | br0ken |
Comments
Comment #2
dsnopek+1 to this!
Comment #3
dsnopekHere's a temporary hack to disable this check on variadics. This isn't a good long-term solution, but it works for us to integrate PHPStan into our CI, where PHPStan wanted the correct type hint, but phpcs/coder was erroring on it.
Comment #4
dsnopekComment #5
zero2one commentedThere is still an error after applying the patch.
I created a new patch that:
This allows the rest of the checks to further validate the parameter type annotation.
Comment #6
Bird-Kid commentedPatch from #5 had done the trick for us! It removed the false negative (error saying 1 space was expected, but 0 found), and correctly adds an error if there is more than one space.
Note that we are using named variadic parameter documentation as shown off in the OP (
...$arguments, instead of just...). However, this patch seems to be compatible with both formats, which is nice.Comment #7
klausiGood to hear and thanks for the manual testing!
Next steps here are to create a pull request against https://github.com/pfrenssen/coder and add a test case.
Comment #8
seamus_lee commentedIn the CiviCRM Community we have applied patch #5 to our version of coder and have confirmed it fixed the issue for us without any ill affects.
Comment #9
zero2one commentedUpdated patch for drupal/coder v8.3.12.
Comment #10
zero2one commentedComment #11
zero2one commentedComment #13
klausiMerged, thanks!