Skip to content

Commit

Permalink
Optimize type specification intersect logic
Browse files Browse the repository at this point in the history
Don't know if this will have side effects so testing needed but if it
works... oh lord.

Fixes #7421 Slow processing of Class::* type hints
  • Loading branch information
neclimdul authored and ondrejmirtes committed Jun 24, 2022
1 parent 7a3ebe9 commit 517bc8f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Analyser/TypeSpecifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,8 @@ public function specifyTypesInCondition(
}

if ($context->true()) {
$type = TypeCombinator::intersect($scope->getType($expr->right), $scope->getType($expr->left));
$leftTypes = $this->create($expr->left, $type, $context, false, $scope, $rootExpr);
$rightTypes = $this->create($expr->right, $type, $context, false, $scope, $rootExpr);
$leftTypes = $this->create($expr->left, $exprRightType, $context, false, $scope, $rootExpr);
$rightTypes = $this->create($expr->right, $exprLeftType, $context, false, $scope, $rootExpr);
return $leftTypes->unionWith($rightTypes);
} elseif ($context->false()) {
return $this->create($expr->left, $exprLeftType, $context, false, $scope, $rootExpr)->normalize($scope)
Expand Down

0 comments on commit 517bc8f

Please sign in to comment.