Skip to content

Commit b940dc5

Browse files
committed
fix sa errors
1 parent 4e0694f commit b940dc5

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

phpstan-baseline.neon

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,12 @@ parameters:
10771077
count: 2
10781078
path: src/Type/Enum/EnumCaseObjectType.php
10791079

1080+
-
1081+
rawMessage: 'Doing instanceof PHPStan\Type\ErrorType is error-prone and deprecated. Use Type::isError() instead.'
1082+
identifier: phpstanApi.instanceofType
1083+
count: 1
1084+
path: src/Type/ErrorType.php
1085+
10801086
-
10811087
rawMessage: 'Doing instanceof PHPStan\Type\ConstantScalarType is error-prone and deprecated. Use Type::isConstantScalarValue() or Type::getConstantScalarTypes() or Type::getConstantScalarValues() instead.'
10821088
identifier: phpstanApi.instanceofType
@@ -1479,6 +1485,12 @@ parameters:
14791485
count: 1
14801486
path: src/Type/ObjectType.php
14811487

1488+
-
1489+
rawMessage: 'Doing instanceof PHPStan\Type\ErrorType is error-prone and deprecated. Use Type::isError() instead.'
1490+
identifier: phpstanApi.instanceofType
1491+
count: 4
1492+
path: src/Type/ObjectType.php
1493+
14821494
-
14831495
rawMessage: Doing instanceof PHPStan\Type\Generic\GenericObjectType is error-prone and deprecated.
14841496
identifier: phpstanApi.instanceofType

src/Rules/Properties/AccessStaticPropertiesCheck.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ private function processSingleProperty(Scope $scope, StaticPropertyFetch $node,
154154
static fn (Type $type): bool => $type->canAccessProperties()->yes() && $type->hasStaticProperty($name)->yes(),
155155
);
156156
$classType = $classTypeResult->getType();
157-
if ($classType instanceof ErrorType) {
157+
if ($classType->isError()->yes()) {
158158
return $classTypeResult->getUnknownClassErrors();
159159
}
160160
}

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)