Skip to content

Commit d88698a

Browse files
committed
Restore src/Reflection/InitializerExprTypeResolver.php
1 parent 8b6112d commit d88698a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/Reflection/InitializerExprTypeResolver.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,6 +1336,20 @@ public function resolveEqualType(Type $leftType, Type $rightType): BooleanType
13361336
return $this->resolveIdenticalType($leftType, $rightType);
13371337
}
13381338

1339+
if ($leftType->isConstantArray()->yes() && $leftType->isIterableAtLeastOnce()->no() && $rightType instanceof ConstantScalarType) {
1340+
// @phpstan-ignore-next-line
1341+
return new ConstantBooleanType($rightType->getValue() == []); // phpcs:ignore
1342+
}
1343+
if ($rightType->isConstantArray()->yes() && $rightType->isIterableAtLeastOnce()->no() && $leftType instanceof ConstantScalarType) {
1344+
// @phpstan-ignore-next-line
1345+
return new ConstantBooleanType($leftType->getValue() == []); // phpcs:ignore
1346+
}
1347+
1348+
if ($leftType instanceof ConstantScalarType && $rightType instanceof ConstantScalarType) {
1349+
// @phpstan-ignore-next-line
1350+
return new ConstantBooleanType($leftType->getValue() == $rightType->getValue()); // phpcs:ignore
1351+
}
1352+
13391353
if ($leftType instanceof ConstantArrayType && $rightType instanceof ConstantArrayType) {
13401354
return $this->resolveConstantArrayTypeComparison($leftType, $rightType, fn ($leftValueType, $rightValueType): BooleanType => $this->resolveEqualType($leftValueType, $rightValueType));
13411355
}

0 commit comments

Comments
 (0)