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 committed Jun 23, 2022
1 parent 55caf64 commit eca9bf2
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Analyser/TypeSpecifier.php
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 eca9bf2

Please sign in to comment.