Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart)
$commentLines = [];
if ($tokens[($tag + 2)]['code'] === T_DOC_COMMENT_STRING) {
$matches = [];
preg_match('/([^$&.]+)(?:((?:\.\.\.)?(?:\$|&)[^\s]+)(?:(\s+)(.*))?)?/', $tokens[($tag + 2)]['content'], $matches);
preg_match('/((?:(?![$.]|&(?=\$)).)*)(?:((?:\.\.\.)?(?:\$|&)[^\s]+)(?:(\s+)(.*))?)?/', $tokens[($tag + 2)]['content'], $matches);

if (empty($matches) === false) {
$typeLen = strlen($matches[1]);
Expand All @@ -323,7 +323,10 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart)
}
}

if (isset($matches[2]) === true) {
if ($tokens[($tag + 2)]['content'][0] === '$') {
$error = 'Missing parameter type';
$phpcsFile->addError($error, $tag, 'MissingParamType');
} else if (isset($matches[2]) === true) {
$var = $matches[2];
$varLen = strlen($var);
if ($varLen > $maxVar) {
Expand Down Expand Up @@ -366,9 +369,6 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart)
$phpcsFile->addError($error, $tag, 'MissingParamComment');
$commentLines[] = ['comment' => ''];
}//end if
} else if ($tokens[($tag + 2)]['content'][0] === '$') {
$error = 'Missing parameter type';
$phpcsFile->addError($error, $tag, 'MissingParamType');
} else {
$error = 'Missing parameter name';
$phpcsFile->addError($error, $tag, 'MissingParamName');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1158,3 +1158,12 @@ function paramVariation3($hasTypeNoComment): void {}
* @return void
*/
function paramVariation4($hasTypehasComment): void {}

/**
* @param (Foo&Bar)|null $a Comment.
* @return void
*/
public function setTranslator($a): void
{
$this->translator = $translator;
}
Original file line number Diff line number Diff line change
Expand Up @@ -1158,3 +1158,12 @@ function paramVariation3($hasTypeNoComment): void {}
* @return void
*/
function paramVariation4($hasTypehasComment): void {}

/**
* @param (Foo&Bar)|null $a Comment.
* @return void
*/
public function setTranslator($a): void
{
$this->translator = $translator;
}
Loading