Skip to content

Commit

Permalink
PHP 8.0 | Squiz.Commenting.FunctionComment: add support for mixed param
Browse files Browse the repository at this point in the history
  • Loading branch information
javer committed Mar 31, 2021
1 parent 1030040 commit cf92acd
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,12 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart)
}
}

if ($this->phpVersion >= 80000) {
if ($suggestedName === 'mixed') {
$suggestedTypeHint = 'mixed';
}
}

if ($suggestedTypeHint !== '' && isset($realParams[$pos]) === true) {
$typeHint = $realParams[$pos]['type_hint'];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1012,3 +1012,12 @@ public function foo($a, $b) {}
* {@inheritDoc}
*/
public function foo($a, $b) {}

/**
* Foo.
*
* @param mixed $a Comment.
*
* @return mixed
*/
public function foo(mixed $a): mixed {}
Original file line number Diff line number Diff line change
Expand Up @@ -1012,3 +1012,12 @@ public function foo($a, $b) {}
* {@inheritDoc}
*/
public function foo($a, $b) {}

/**
* Foo.
*
* @param mixed $a Comment.
*
* @return mixed
*/
public function foo(mixed $a): mixed {}
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@ public function getErrorList()
$errors[992] = 2;
}

// Mixed type hints only work from PHP 8.0 onwards.
if (PHP_VERSION_ID >= 80000) {
$errors[265] = 1;
$errors[459] = 1;
$errors[893] = 3;
} else {
$errors[1023] = 1;
}

return $errors;

}//end getErrorList()
Expand Down

0 comments on commit cf92acd

Please sign in to comment.