@@ -2568,7 +2568,7 @@ private function resolveNormalizedIdentical(Expr\BinaryOp\Identical $expr, Scope
25682568 $argType = $scope->getType($unwrappedLeftExpr->getArgs()[0]->value);
25692569 $isZero = (new ConstantIntegerType(0))->isSuperTypeOf($rightType);
25702570 if ($isZero->yes()) {
2571- $funcTypes = $this->create($unwrappedLeftExpr , $rightType, $context, $scope)->setRootExpr($expr);
2571+ $funcTypes = $this->create($leftExpr , $rightType, $context, $scope)->setRootExpr($expr);
25722572
25732573 if ($context->truthy() && !$argType->isArray()->yes()) {
25742574 $newArgType = new UnionType([
@@ -2586,11 +2586,15 @@ private function resolveNormalizedIdentical(Expr\BinaryOp\Identical $expr, Scope
25862586
25872587 $specifiedTypes = $this->specifyTypesForCountFuncCall($unwrappedLeftExpr, $argType, $rightType, $context, $scope, $expr);
25882588 if ($specifiedTypes !== null) {
2589+ if ($leftExpr !== $unwrappedLeftExpr) {
2590+ $funcTypes = $this->create($leftExpr, $rightType, $context, $scope)->setRootExpr($expr);
2591+ return $specifiedTypes->unionWith($funcTypes);
2592+ }
25892593 return $specifiedTypes;
25902594 }
25912595
25922596 if ($context->truthy() && $argType->isArray()->yes()) {
2593- $funcTypes = $this->create($unwrappedLeftExpr , $rightType, $context, $scope)->setRootExpr($expr);
2597+ $funcTypes = $this->create($leftExpr , $rightType, $context, $scope)->setRootExpr($expr);
25942598 if (IntegerRangeType::fromInterval(1, null)->isSuperTypeOf($rightType)->yes()) {
25952599 return $funcTypes->unionWith(
25962600 $this->create($unwrappedLeftExpr->getArgs()[0]->value, new NonEmptyArrayType(), $context, $scope)->setRootExpr($expr),
@@ -2616,7 +2620,7 @@ private function resolveNormalizedIdentical(Expr\BinaryOp\Identical $expr, Scope
26162620
26172621 $isZero = (new ConstantIntegerType(0))->isSuperTypeOf($rightType);
26182622 if ($isZero->yes()) {
2619- $funcTypes = $this->create($unwrappedLeftExpr , $rightType, $context, $scope)->setRootExpr($expr);
2623+ $funcTypes = $this->create($leftExpr , $rightType, $context, $scope)->setRootExpr($expr);
26202624 return $funcTypes->unionWith(
26212625 $this->create($unwrappedLeftExpr->getArgs()[0]->value, new ConstantStringType(''), $context, $scope)->setRootExpr($expr),
26222626 );
@@ -2625,7 +2629,7 @@ private function resolveNormalizedIdentical(Expr\BinaryOp\Identical $expr, Scope
26252629 if ($context->truthy() && IntegerRangeType::fromInterval(1, null)->isSuperTypeOf($rightType)->yes()) {
26262630 $argType = $scope->getType($unwrappedLeftExpr->getArgs()[0]->value);
26272631 if ($argType->isString()->yes()) {
2628- $funcTypes = $this->create($unwrappedLeftExpr , $rightType, $context, $scope)->setRootExpr($expr);
2632+ $funcTypes = $this->create($leftExpr , $rightType, $context, $scope)->setRootExpr($expr);
26292633
26302634 $accessory = new AccessoryNonEmptyStringType();
26312635 if (IntegerRangeType::fromInterval(2, null)->isSuperTypeOf($rightType)->yes()) {
0 commit comments