Skip to content

Commit 686b4c7

Browse files
takaramondrejmirtes
authored andcommitted
Use Type::isNull() in Nullsafe(MethodCall|PropertyFetch)Rule
1 parent 809fb6b commit 686b4c7

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

src/Rules/Methods/NullsafeMethodCallRule.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use PHPStan\Analyser\Scope;
77
use PHPStan\Rules\Rule;
88
use PHPStan\Rules\RuleErrorBuilder;
9-
use PHPStan\Type\NullType;
109
use PHPStan\Type\VerbosityLevel;
1110
use function sprintf;
1211

@@ -23,13 +22,8 @@ public function getNodeType(): string
2322

2423
public function processNode(Node $node, Scope $scope): array
2524
{
26-
$nullType = new NullType();
2725
$calledOnType = $scope->getType($node->var);
28-
if ($calledOnType->equals($nullType)) {
29-
return [];
30-
}
31-
32-
if (!$calledOnType->isSuperTypeOf($nullType)->no()) {
26+
if (!$calledOnType->isNull()->no()) {
3327
return [];
3428
}
3529

src/Rules/Properties/NullsafePropertyFetchRule.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use PHPStan\Analyser\Scope;
77
use PHPStan\Rules\Rule;
88
use PHPStan\Rules\RuleErrorBuilder;
9-
use PHPStan\Type\NullType;
109
use PHPStan\Type\VerbosityLevel;
1110
use function sprintf;
1211

@@ -27,13 +26,8 @@ public function getNodeType(): string
2726

2827
public function processNode(Node $node, Scope $scope): array
2928
{
30-
$nullType = new NullType();
3129
$calledOnType = $scope->getType($node->var);
32-
if ($calledOnType->equals($nullType)) {
33-
return [];
34-
}
35-
36-
if (!$calledOnType->isSuperTypeOf($nullType)->no()) {
30+
if (!$calledOnType->isNull()->no()) {
3731
return [];
3832
}
3933

0 commit comments

Comments
 (0)