Skip to content

Commit 56dcef3

Browse files
committed
Fix up param sniff.
1 parent 953f7d9 commit 56dcef3

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

PhpCollective/Sniffs/Commenting/DocBlockParamAllowDefaultValueSniff.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ public function process(File $phpCsFile, $stackPointer): void
7474
$classNameIndex = $i + 2;
7575

7676
if ($tokens[$classNameIndex]['type'] !== 'T_DOC_COMMENT_STRING') {
77-
$phpCsFile->addError('Missing type in param doc block', $i, 'TypeMissing');
78-
77+
// Let DocBlockParam sniff handle this
7978
continue;
8079
}
8180

PhpCollective/Sniffs/Commenting/DocBlockParamNotJustNullSniff.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,22 @@ public function process(File $phpCsFile, $stackPointer): void
7575
}
7676

7777
$content = $tokens[$classNameIndex]['content'];
78+
if (!$content) {
79+
continue;
80+
}
81+
82+
$varIndex = strpos($content, '$');
83+
if ($varIndex === false) {
84+
continue;
85+
}
86+
87+
$content = trim(substr($content, 0, $varIndex));
88+
if (!$content) {
89+
$phpCsFile->addError('Param type is empty', $classNameIndex, 'EmptyType');
7890

79-
//$appendix = '';
80-
$spaceIndex = strpos($content, ' ');
81-
if ($spaceIndex) {
82-
//$appendix = substr($content, $spaceIndex);
83-
$content = substr($content, 0, $spaceIndex);
91+
continue;
8492
}
93+
8594
if ($content !== 'null') {
8695
continue;
8796
}

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ parameters:
55
- PhpCollectiveStrict/
66
bootstrapFiles:
77
- '%rootDir%/../../../tests/bootstrap.php'
8-
checkGenericClassInNonGenericObjectType: false
98
ignoreErrors:
9+
- identifier: missingType.generics

0 commit comments

Comments
 (0)