Skip to content

Commit 55c990e

Browse files
committed
Do not report first class callables
1 parent f2097d2 commit 55c990e

File tree

6 files changed

+18
-0
lines changed

6 files changed

+18
-0
lines changed

src/Rules/Functions/CallToFunctionStatementWithNoDiscardRule.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ public function processNode(Node $node, Scope $scope): array
3434
return [];
3535
}
3636

37+
if ($node->expr->isFirstClassCallable()) {
38+
return [];
39+
}
40+
3741
$funcCall = $node->expr;
3842
if ($funcCall->name instanceof Node\Name) {
3943
if (!$this->reflectionProvider->hasFunction($funcCall->name, $scope)) {

src/Rules/Methods/CallToMethodStatementWithNoDiscardRule.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ public function processNode(Node $node, Scope $scope): array
3737
return [];
3838
}
3939

40+
if ($node->expr->isFirstClassCallable()) {
41+
return [];
42+
}
43+
4044
$funcCall = $node->expr;
4145
if (!$funcCall->name instanceof Node\Identifier) {
4246
return [];

src/Rules/Methods/CallToStaticMethodStatementWithNoDiscardRule.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ public function processNode(Node $node, Scope $scope): array
4040
return [];
4141
}
4242

43+
if ($node->expr->isFirstClassCallable()) {
44+
return [];
45+
}
46+
4347
$funcCall = $node->expr;
4448
if (!$funcCall->name instanceof Node\Identifier) {
4549
return [];

tests/PHPStan/Rules/Functions/data/function-call-statement-result-discarded.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,5 @@ function differentCase(): array {
4343
$b = $arrowWithNoDiscard();
4444

4545
$arrowWithNoDiscard();
46+
47+
withSideEffects(...);

tests/PHPStan/Rules/Methods/data/method-call-statement-result-discarded.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ public function differentCase(): array {
2828
}
2929

3030
$o->differentCase();
31+
32+
$o->instanceMethod(...);

tests/PHPStan/Rules/Methods/data/static-method-call-statement-result-discarded.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,5 @@ public static function differentCase(): array {
2525
}
2626

2727
ClassWithStaticSideEffects::differentCase();
28+
29+
ClassWithStaticSideEffects::staticMethod(...);

0 commit comments

Comments
 (0)