@@ -5630,7 +5630,7 @@ static function (): void {
5630
5630
$ propertyNativeType = $ propertyReflection ->getNativeType ();
5631
5631
5632
5632
$ assignedTypeIsCompatible = false ;
5633
- foreach (TypeUtils::flattenTypes ($ propertyNativeType ) as $ type ) {
5633
+ foreach (TypeUtils::flattenTypes ($ propertyNativeType ) as $ type ) {
5634
5634
if ($ type ->isSuperTypeOf ($ assignedNativeType )->yes ()) {
5635
5635
$ assignedTypeIsCompatible = true ;
5636
5636
break ;
@@ -5641,7 +5641,7 @@ static function (): void {
5641
5641
$ scope = $ scope ->assignExpression (
5642
5642
$ var ,
5643
5643
TypeCombinator::intersect ($ assignedExprType ->toCoercedArgumentType (true ), $ propertyNativeType ),
5644
- TypeCombinator::intersect ($ assignedNativeType ->toCoercedArgumentType (true ), $ propertyNativeType )
5644
+ TypeCombinator::intersect ($ assignedNativeType ->toCoercedArgumentType (true ), $ propertyNativeType ),
5645
5645
);
5646
5646
} else {
5647
5647
$ scope = $ scope ->assignExpression ($ var , $ assignedExprType , $ assignedNativeType );
@@ -5714,13 +5714,9 @@ static function (): void {
5714
5714
$ nodeCallback (new PropertyAssignNode ($ var , $ assignedExpr , $ isAssignOp ), $ scope );
5715
5715
if ($ propertyReflection !== null && $ propertyReflection ->canChangeTypeAfterAssignment ()) {
5716
5716
if ($ propertyReflection ->hasNativeType () && $ scope ->isDeclareStrictTypes ()) {
5717
- $ assignedNativeType = $ scope ->getNativeType ($ assignedExpr );
5718
5717
$ propertyNativeType = $ propertyReflection ->getNativeType ();
5719
5718
5720
- $ newAssignedType = TypeCombinator::intersect ($ assignedExprType ->toCoercedArgumentType (true ), $ propertyNativeType );
5721
- $ newAssignedNativeType = TypeCombinator::intersect ($ assignedNativeType ->toCoercedArgumentType (true ), $ propertyNativeType );
5722
-
5723
- $ scope = $ scope ->assignExpression ($ var , $ newAssignedType , $ newAssignedNativeType );
5719
+ $ scope = $ scope ->assignExpression ($ var , TypeCombinator::intersect ($ assignedExprType ->toCoercedArgumentType (true ), $ propertyNativeType ), TypeCombinator::intersect ($ scope ->getNativeType ($ assignedExpr )->toCoercedArgumentType (true ), $ propertyNativeType ));
5724
5720
} else {
5725
5721
$ scope = $ scope ->assignExpression ($ var , $ assignedExprType , $ scope ->getNativeType ($ assignedExpr ));
5726
5722
}
0 commit comments