Skip to content

Commit d267c73

Browse files
committed
cleanup
1 parent 9867a23 commit d267c73

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/Analyser/TypeSpecifier.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,11 +2242,23 @@ public function resolveEqual(Expr\BinaryOp\Equal $expr, Scope $scope, TypeSpecif
22422242

22432243
public function resolveIdentical(Expr\BinaryOp\Identical $expr, Scope $scope, TypeSpecifierContext $context): SpecifiedTypes
22442244
{
2245-
$specifiedTypes = $this->resolveNormalizedIdentical($expr, $scope, $context);
2246-
2247-
// merge result of fn1() === fn2() and fn2() === fn1()
22482245
$leftExpr = $expr->left;
22492246
$rightExpr = $expr->right;
2247+
2248+
// Normalize to: fn() === expr
2249+
if ($rightExpr instanceof FuncCall && !$leftExpr instanceof FuncCall) {
2250+
$specifiedTypes = $this->resolveNormalizedIdentical(new Expr\BinaryOp\Identical(
2251+
$rightExpr,
2252+
$leftExpr,
2253+
), $scope, $context);
2254+
} else {
2255+
$specifiedTypes = $this->resolveNormalizedIdentical(new Expr\BinaryOp\Identical(
2256+
$leftExpr,
2257+
$rightExpr,
2258+
), $scope, $context);
2259+
}
2260+
2261+
// merge result of fn1() === fn2() and fn2() === fn1()
22502262
if ($rightExpr instanceof FuncCall && $leftExpr instanceof FuncCall) {
22512263
return $specifiedTypes->unionWith(
22522264
$this->resolveNormalizedIdentical(new Expr\BinaryOp\Identical(
@@ -2261,12 +2273,8 @@ public function resolveIdentical(Expr\BinaryOp\Identical $expr, Scope $scope, Ty
22612273

22622274
private function resolveNormalizedIdentical(Expr\BinaryOp\Identical $expr, Scope $scope, TypeSpecifierContext $context): SpecifiedTypes
22632275
{
2264-
// Normalize to: fn() === expr
22652276
$leftExpr = $expr->left;
22662277
$rightExpr = $expr->right;
2267-
if ($rightExpr instanceof FuncCall && !$leftExpr instanceof FuncCall) {
2268-
[$leftExpr, $rightExpr] = [$rightExpr, $leftExpr];
2269-
}
22702278

22712279
$unwrappedLeftExpr = $leftExpr;
22722280
if ($leftExpr instanceof AlwaysRememberedExpr) {

0 commit comments

Comments
 (0)