Skip to content

Commit d5e485d

Browse files
committed
fix sa errors
1 parent 614a59d commit d5e485d

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

phpstan-baseline.neon

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,12 @@ parameters:
11311131
count: 2
11321132
path: src/Type/Enum/EnumCaseObjectType.php
11331133

1134+
-
1135+
rawMessage: 'Doing instanceof PHPStan\Type\ErrorType is error-prone and deprecated. Use Type::isError() instead.'
1136+
identifier: phpstanApi.instanceofType
1137+
count: 1
1138+
path: src/Type/ErrorType.php
1139+
11341140
-
11351141
rawMessage: 'Doing instanceof PHPStan\Type\ConstantScalarType is error-prone and deprecated. Use Type::isConstantScalarValue() or Type::getConstantScalarTypes() or Type::getConstantScalarValues() instead.'
11361142
identifier: phpstanApi.instanceofType
@@ -1533,6 +1539,12 @@ parameters:
15331539
count: 1
15341540
path: src/Type/ObjectType.php
15351541

1542+
-
1543+
rawMessage: 'Doing instanceof PHPStan\Type\ErrorType is error-prone and deprecated. Use Type::isError() instead.'
1544+
identifier: phpstanApi.instanceofType
1545+
count: 4
1546+
path: src/Type/ObjectType.php
1547+
15361548
-
15371549
rawMessage: Doing instanceof PHPStan\Type\Generic\GenericObjectType is error-prone and deprecated.
15381550
identifier: phpstanApi.instanceofType

src/Rules/Properties/AccessStaticPropertiesCheck.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use PHPStan\Rules\RuleErrorBuilder;
2020
use PHPStan\Rules\RuleLevelHelper;
2121
use PHPStan\Type\Constant\ConstantStringType;
22-
use PHPStan\Type\ErrorType;
2322
use PHPStan\Type\StringType;
2423
use PHPStan\Type\ThisType;
2524
use PHPStan\Type\Type;
@@ -154,7 +153,7 @@ private function processSingleProperty(Scope $scope, StaticPropertyFetch $node,
154153
static fn (Type $type): bool => $type->canAccessProperties()->yes() && $type->hasStaticProperty($name)->yes(),
155154
);
156155
$classType = $classTypeResult->getType();
157-
if ($classType instanceof ErrorType) {
156+
if ($classType->isError()->yes()) {
158157
return $classTypeResult->getUnknownClassErrors();
159158
}
160159
}

src/Type/Generic/TemplateTypeTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
77
use PHPStan\TrinaryLogic;
88
use PHPStan\Type\AcceptsResult;
9-
use PHPStan\Type\ErrorType;
109
use PHPStan\Type\IntersectionType;
1110
use PHPStan\Type\IsSuperTypeOfResult;
1211
use PHPStan\Type\MixedType;
@@ -18,6 +17,7 @@
1817
use PHPStan\Type\TypeUtils;
1918
use PHPStan\Type\UnionType;
2019
use PHPStan\Type\VerbosityLevel;
20+
use function is_string;
2121
use function sprintf;
2222

2323
/**
@@ -74,7 +74,7 @@ public function describe(VerbosityLevel $level): string
7474
$defaultDescription = '';
7575
if ($this->default !== null) {
7676
$recursionGuard = RecursionGuard::runOnObjectIdentity($this->default, fn () => $this->default->describe($level));
77-
if (!$recursionGuard instanceof ErrorType) {
77+
if (is_string($recursionGuard)) {
7878
$defaultDescription .= sprintf(' = %s', $recursionGuard);
7979
}
8080
}

src/Type/ObjectType.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public function hasProperty(string $propertyName): TrinaryLogic
156156
}
157157

158158
$classHasProperty = RecursionGuard::run($this, static fn (): bool => $classReflection->hasProperty($propertyName));
159-
if ($classHasProperty === true || $classHasProperty instanceof ErrorType) {
159+
if ($classHasProperty !== false) {
160160
return TrinaryLogic::createYes();
161161
}
162162

@@ -262,7 +262,7 @@ public function hasInstanceProperty(string $propertyName): TrinaryLogic
262262
}
263263

264264
$classHasProperty = RecursionGuard::run($this, static fn (): bool => $classReflection->hasInstanceProperty($propertyName));
265-
if ($classHasProperty === true || $classHasProperty instanceof ErrorType) {
265+
if ($classHasProperty !== false) {
266266
return TrinaryLogic::createYes();
267267
}
268268

@@ -368,7 +368,7 @@ public function hasStaticProperty(string $propertyName): TrinaryLogic
368368
}
369369

370370
$classHasProperty = RecursionGuard::run($this, static fn (): bool => $classReflection->hasStaticProperty($propertyName));
371-
if ($classHasProperty === true || $classHasProperty instanceof ErrorType) {
371+
if ($classHasProperty !== false) {
372372
return TrinaryLogic::createYes();
373373
}
374374

0 commit comments

Comments
 (0)