Skip to content

Commit 3a776b3

Browse files
identifier
1 parent 9c68958 commit 3a776b3

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/Rules/FunctionDefinitionCheck.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use PhpParser\Node\Identifier;
1111
use PhpParser\Node\IntersectionType;
1212
use PhpParser\Node\Name;
13-
use PhpParser\Node\Name\FullyQualified;
1413
use PhpParser\Node\NullableType;
1514
use PhpParser\Node\Param;
1615
use PhpParser\Node\Stmt\ClassMethod;
@@ -203,7 +202,7 @@ public function checkAnonymousFunction(
203202
if ($returnTypeNode === null) {
204203
return $errors;
205204
}
206-
if ($returnTypeNode instanceof FullyQualified && $returnTypeNode->name === 'void') {
205+
if ($returnTypeNode instanceof Identifier && $returnTypeNode->name === 'void') {
207206
foreach ($attribGroups as $attribGroup) {
208207
foreach ($attribGroup->attrs as $attrib) {
209208
if (strtolower($attrib->name->name) === 'nodiscard') {
@@ -497,7 +496,7 @@ private function checkParametersAcceptor(
497496
}
498497
if ($parametersAcceptor->hasNoDiscardAttribute()->yes()) {
499498
$returnType = $functionNode->getReturnType();
500-
if ($returnType instanceof FullyQualified
499+
if ($returnType instanceof Identifier
501500
&& $returnType->name === 'void'
502501
) {
503502
$errors[] = RuleErrorBuilder::message($noDiscardVoidReturnMessage)

tests/PHPStan/Rules/Functions/ExistingClassesInClosureTypehintsRuleTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ public function testNoDiscardVoid(): void
358358
$this->analyse([__DIR__ . '/data/closure-typehints-nodiscard.php'], [
359359
[
360360
'Attribute NoDiscard cannot be used on void anonymous function.',
361-
17,
361+
5,
362362
],
363363
]);
364364
}

0 commit comments

Comments
 (0)