Skip to content

Commit 46664d7

Browse files
committed
fix: use strict mixed in StrictTypeSafetyChecker
1 parent ae6af2e commit 46664d7

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

rules/TypeDeclaration/NodeAnalyzer/StrictTypeSafetyChecker.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use PHPStan\Reflection\Php\PhpPropertyReflection;
1919
use PHPStan\Type\MixedType;
2020
use PHPStan\Type\NeverType;
21+
use PHPStan\Type\StrictMixedType;
2122
use PHPStan\Type\Type;
2223
use Rector\NodeTypeResolver\NodeTypeResolver;
2324
use Rector\NodeTypeResolver\PHPStan\ParametersAcceptorSelectorVariantsWrapper;
@@ -197,6 +198,11 @@ private function isPropertyAssignSafe(Assign $assign): bool
197198

198199
private function isTypeSafeForStrictMode(Type $declaredType, Type $valueType): bool
199200
{
201+
if ($valueType instanceof MixedType) {
202+
/** @phpstan-ignore phpstanApi.constructor (need to be strict with mixed) */
203+
$valueType = new StrictMixedType();
204+
}
205+
200206
return $declaredType->accepts($valueType, strictTypes: true)
201207
->yes();
202208
}

src/Config/Level/CodeQualityLevel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ final class CodeQualityLevel
184184
SortCallLikeNamedArgsRector::class,
185185
SortAttributeNamedArgsRector::class,
186186
RemoveReadonlyPropertyVisibilityOnReadonlyClassRector::class,
187-
// SafeDeclareStrictTypesRector::class,
187+
SafeDeclareStrictTypesRector::class,
188188
];
189189

190190
/**

0 commit comments

Comments
 (0)