File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed
rules/TypeDeclaration/NodeAnalyzer Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change 1818use PHPStan \Reflection \Php \PhpPropertyReflection ;
1919use PHPStan \Type \MixedType ;
2020use PHPStan \Type \NeverType ;
21+ use PHPStan \Type \StrictMixedType ;
2122use PHPStan \Type \Type ;
2223use Rector \NodeTypeResolver \NodeTypeResolver ;
2324use 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 }
Original file line number Diff line number Diff 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 /**
You can’t perform that action at this time.
0 commit comments