Skip to content

Commit 5f04b25

Browse files
committed
simplify
1 parent bad4940 commit 5f04b25

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

src/Analyser/TypeSpecifier.php

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2277,28 +2277,26 @@ public function resolveIdentical(Expr\BinaryOp\Identical $expr, Scope $scope, Ty
22772277
&& in_array($unwrappedRightExpr->name->toLowerString(), ['count', 'sizeof'], true)
22782278
&& count($unwrappedRightExpr->getArgs()) >= 1
22792279
) {
2280-
$leftArrayType = $scope->getType($unwrappedLeftExpr->getArgs()[0]->value);
2281-
$rightArrayType = $scope->getType($unwrappedRightExpr->getArgs()[0]->value);
2280+
$argType = $scope->getType($unwrappedRightExpr->getArgs()[0]->value);
2281+
$sizeType = $scope->getType($leftExpr);
22822282

2283-
if ($leftArrayType->isArray()->yes() && $rightArrayType->isArray()->yes()) {
2284-
$argType = $scope->getType($unwrappedRightExpr->getArgs()[0]->value);
2285-
$sizeType = $scope->getType($leftExpr);
2286-
2287-
if ($sizeType instanceof IntegerRangeType || $sizeType->isConstantScalarValue()->yes()) {
2288-
$specifiedTypes = $this->specifyTypesForCountFuncCall($unwrappedRightExpr, $argType, $sizeType, $context, $scope, $expr);
2289-
if ($specifiedTypes !== null) {
2290-
return $specifiedTypes;
2291-
}
2292-
}
2283+
$specifiedTypes = $this->specifyTypesForCountFuncCall($unwrappedRightExpr, $argType, $sizeType, $context, $scope, $expr);
2284+
if ($specifiedTypes !== null) {
2285+
return $specifiedTypes;
2286+
}
22932287

2294-
if (!$rightType->isConstantScalarValue()->yes()) {
2295-
if ($leftArrayType->isIterableAtLeastOnce()->yes() || $rightArrayType->isIterableAtLeastOnce()->yes()) {
2296-
$arrayTypes = $this->create($unwrappedLeftExpr->getArgs()[0]->value, new NonEmptyArrayType(), $context, $scope)->setRootExpr($expr);
2297-
return $arrayTypes->unionWith(
2298-
$this->create($unwrappedRightExpr->getArgs()[0]->value, new NonEmptyArrayType(), $context, $scope)->setRootExpr($expr),
2299-
);
2300-
}
2301-
}
2288+
$leftArrayType = $scope->getType($unwrappedLeftExpr->getArgs()[0]->value);
2289+
$rightArrayType = $scope->getType($unwrappedRightExpr->getArgs()[0]->value);
2290+
if (
2291+
$leftArrayType->isArray()->yes()
2292+
&& $rightArrayType->isArray()->yes()
2293+
&& !$rightType->isConstantScalarValue()->yes()
2294+
&& ($leftArrayType->isIterableAtLeastOnce()->yes() || $rightArrayType->isIterableAtLeastOnce()->yes())
2295+
) {
2296+
$arrayTypes = $this->create($unwrappedLeftExpr->getArgs()[0]->value, new NonEmptyArrayType(), $context, $scope)->setRootExpr($expr);
2297+
return $arrayTypes->unionWith(
2298+
$this->create($unwrappedRightExpr->getArgs()[0]->value, new NonEmptyArrayType(), $context, $scope)->setRootExpr($expr),
2299+
);
23022300
}
23032301
}
23042302

0 commit comments

Comments
 (0)