diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/FunctionCommentSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/FunctionCommentSniff.php index 0c8bc0a322826097a24fe840ebae7c369851f9d8..24d6d0891c9ac75a8675d4b62b502e7760ec996c 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/FunctionCommentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/FunctionCommentSniff.php @@ -696,6 +696,13 @@ class FunctionCommentSniff implements Sniff } $suggestedType = implode('|', $suggestedNames); + + // Support variadic arguments. + if (preg_match('/(\s+)\.{3}$/', $param['type'], $matches) === 1) { + $param['type_space'] = strlen($matches[1]); + $param['type'] = preg_replace('/\s+\.{3}$/', '', $param['type']); + } + if (preg_match('/\s/', $param['type']) === 1) { $error = 'Parameter type "%s" must not contain spaces'; $data = [$param['type']]; diff --git a/tests/Drupal/good/good.php b/tests/Drupal/good/good.php index 2f36e561d73fcd61ce5fe4305cfbb4d3c6f9c791..90a98cb76c52f3e3c4f763641ba1b1a68196f8b1 100644 --- a/tests/Drupal/good/good.php +++ b/tests/Drupal/good/good.php @@ -1576,6 +1576,16 @@ function test23(): TestReturnType { return foo(); } +/** + * Variadic arguments with proper declaration. + * + * @param \Drupal\mymodule\Element ...$element + * The variadic parameter comment. + */ +function test24(Element ...$element) { + +} + /** * Test class. */