Skip to content

Commit 8c84123

Browse files
committed
Skip empty types
1 parent c38bb12 commit 8c84123

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,12 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart)
405405
$suggestedTypeNames = [];
406406

407407
foreach ($typeNames as $typeName) {
408+
if ($typeName === '') {
409+
continue;
410+
}
411+
408412
// Strip nullable operator.
409-
if (isset($typeName[0]) === true && $typeName[0] === '?') {
413+
if ($typeName[0] === '?') {
410414
$typeName = substr($typeName, 1);
411415
}
412416

src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ function throwCommentOneLine() {}
10501050
/**
10511051
* When two adjacent pipe symbols are used (by mistake), the sniff should not throw a PHP Fatal error
10521052
*
1053-
* @param stdClass||null $object While invalid, this should not throw a PHP Fatal error.
1053+
* @param stdClass|null $object While invalid, this should not throw a PHP Fatal error.
10541054
* @return void
10551055
*/
10561056
function doublePipeFatalError(?stdClass $object) {}

src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ public function getErrorList()
116116
1004 => 2,
117117
1006 => 1,
118118
1029 => 1,
119+
1053 => 1,
119120
];
120121

121122
// Scalar type hints only work from PHP 7 onwards.

0 commit comments

Comments
 (0)