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
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -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']];
+10 −0
Original line number Diff line number Diff line
@@ -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.
 */