Skip to content
Snippets Groups Projects
Unverified Commit d3286d57 authored by Peter Decuyper's avatar Peter Decuyper Committed by GitHub
Browse files

fix(FunctionComment): Add support for variadic function argument comment (#2878783 by zero2one)

parent 6db342aa
Branches
Tags
1 merge request!4Issue #3217297: False positive in closure usage of USE keyword.
...@@ -696,6 +696,13 @@ class FunctionCommentSniff implements Sniff ...@@ -696,6 +696,13 @@ class FunctionCommentSniff implements Sniff
} }
$suggestedType = implode('|', $suggestedNames); $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) { if (preg_match('/\s/', $param['type']) === 1) {
$error = 'Parameter type "%s" must not contain spaces'; $error = 'Parameter type "%s" must not contain spaces';
$data = [$param['type']]; $data = [$param['type']];
......
...@@ -1576,6 +1576,16 @@ function test23(): TestReturnType { ...@@ -1576,6 +1576,16 @@ function test23(): TestReturnType {
return foo(); return foo();
} }
/**
* Variadic arguments with proper declaration.
*
* @param \Drupal\mymodule\Element ...$element
* The variadic parameter comment.
*/
function test24(Element ...$element) {
}
/** /**
* Test class. * Test class.
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment