Skip to content

Commit 2fe66c5

Browse files
committed
Update NodeScopeResolver.php
1 parent 812d947 commit 2fe66c5

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

Diff for: src/Analyser/NodeScopeResolver.php

+3-7
Original file line numberDiff line numberDiff line change
@@ -5630,7 +5630,7 @@ static function (): void {
56305630
$propertyNativeType = $propertyReflection->getNativeType();
56315631

56325632
$assignedTypeIsCompatible = false;
5633-
foreach(TypeUtils::flattenTypes($propertyNativeType) as $type) {
5633+
foreach (TypeUtils::flattenTypes($propertyNativeType) as $type) {
56345634
if ($type->isSuperTypeOf($assignedNativeType)->yes()) {
56355635
$assignedTypeIsCompatible = true;
56365636
break;
@@ -5641,7 +5641,7 @@ static function (): void {
56415641
$scope = $scope->assignExpression(
56425642
$var,
56435643
TypeCombinator::intersect($assignedExprType->toCoercedArgumentType(true), $propertyNativeType),
5644-
TypeCombinator::intersect($assignedNativeType->toCoercedArgumentType(true), $propertyNativeType)
5644+
TypeCombinator::intersect($assignedNativeType->toCoercedArgumentType(true), $propertyNativeType),
56455645
);
56465646
} else {
56475647
$scope = $scope->assignExpression($var, $assignedExprType, $assignedNativeType);
@@ -5714,13 +5714,9 @@ static function (): void {
57145714
$nodeCallback(new PropertyAssignNode($var, $assignedExpr, $isAssignOp), $scope);
57155715
if ($propertyReflection !== null && $propertyReflection->canChangeTypeAfterAssignment()) {
57165716
if ($propertyReflection->hasNativeType() && $scope->isDeclareStrictTypes()) {
5717-
$assignedNativeType = $scope->getNativeType($assignedExpr);
57185717
$propertyNativeType = $propertyReflection->getNativeType();
57195718

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));
57245720
} else {
57255721
$scope = $scope->assignExpression($var, $assignedExprType, $scope->getNativeType($assignedExpr));
57265722
}

0 commit comments

Comments
 (0)