diff --git a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php index 1101165cbd..f63d09c43b 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php @@ -405,8 +405,12 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) $suggestedTypeNames = []; foreach ($typeNames as $typeName) { + if ($typeName === '') { + continue; + } + // Strip nullable operator. - if (isset($typeName[0]) === true && $typeName[0] === '?') { + if ($typeName[0] === '?') { $typeName = substr($typeName, 1); } diff --git a/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc.fixed b/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc.fixed index 330563b0d5..10e939709b 100644 --- a/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc.fixed +++ b/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc.fixed @@ -1050,7 +1050,7 @@ function throwCommentOneLine() {} /** * When two adjacent pipe symbols are used (by mistake), the sniff should not throw a PHP Fatal error * - * @param stdClass||null $object While invalid, this should not throw a PHP Fatal error. + * @param stdClass|null $object While invalid, this should not throw a PHP Fatal error. * @return void */ function doublePipeFatalError(?stdClass $object) {} diff --git a/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php index 632b7c51b2..06ba08f72a 100644 --- a/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php @@ -116,6 +116,7 @@ public function getErrorList() 1004 => 2, 1006 => 1, 1029 => 1, + 1053 => 1, ]; // Scalar type hints only work from PHP 7 onwards.