@@ -5647,6 +5647,12 @@ static function (): void {
5647
5647
TypeCombinator::intersect ($ assignedExprType ->toCoercedArgumentType (true ), $ propertyNativeType ),
5648
5648
TypeCombinator::intersect ($ assignedNativeType ->toCoercedArgumentType (true ), $ propertyNativeType ),
5649
5649
);
5650
+ } elseif (TypeCombinator::containsNull ($ propertyNativeType ) && !TypeCombinator::containsNull ($ assignedNativeType )) {
5651
+ $ scope = $ scope ->assignExpression (
5652
+ $ var ,
5653
+ TypeCombinator::removeNull ($ propertyReflection ->hasPhpDocType () ? $ propertyReflection ->getPhpDocType () : $ propertyNativeType ),
5654
+ TypeCombinator::removeNull ($ propertyNativeType ),
5655
+ );
5650
5656
}
5651
5657
} else {
5652
5658
$ scope = $ scope ->assignExpression ($ var , $ assignedExprType , $ scope ->getNativeType ($ assignedExpr ));
@@ -5735,6 +5741,12 @@ static function (): void {
5735
5741
TypeCombinator::intersect ($ assignedExprType ->toCoercedArgumentType (true ), $ propertyNativeType ),
5736
5742
TypeCombinator::intersect ($ assignedNativeType ->toCoercedArgumentType (true ), $ propertyNativeType ),
5737
5743
);
5744
+ } elseif (TypeCombinator::containsNull ($ propertyNativeType ) && !TypeCombinator::containsNull ($ assignedNativeType )) {
5745
+ $ scope = $ scope ->assignExpression (
5746
+ $ var ,
5747
+ TypeCombinator::removeNull ($ propertyReflection ->hasPhpDocType () ? $ propertyReflection ->getPhpDocType () : $ propertyNativeType ),
5748
+ TypeCombinator::removeNull ($ propertyNativeType ),
5749
+ );
5738
5750
}
5739
5751
} else {
5740
5752
$ scope = $ scope ->assignExpression ($ var , $ assignedExprType , $ scope ->getNativeType ($ assignedExpr ));
0 commit comments