Skip to content

Commit 927a8fd

Browse files
Try
1 parent 37608db commit 927a8fd

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

src/Reflection/InitializerExprTypeResolver.php

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,9 +1008,16 @@ public function getBitwiseAndTypeFromTypes(Type $leftType, Type $rightType): Typ
10081008
$rightType = $this->optimizeScalarType($rightType);
10091009
}
10101010

1011+
if ($leftType instanceof MixedType && $rightType instanceof MixedType) {
1012+
return new BenevolentUnionType([new IntegerType(), new StringType()]);
1013+
}
1014+
10111015
$leftIsString = $leftType->isString();
10121016
$rightIsString = $rightType->isString();
1013-
if ($leftIsString->yes() && $rightIsString->yes()) {
1017+
if (
1018+
($leftIsString->yes() || $leftType instanceof MixedType)
1019+
&& ($rightIsString->yes() || $leftType instanceof MixedType)
1020+
) {
10141021
return new StringType();
10151022
}
10161023
if ($leftIsString->maybe() && $rightIsString->maybe()) {
@@ -1087,9 +1094,16 @@ public function getBitwiseOrTypeFromTypes(Type $leftType, Type $rightType): Type
10871094
$rightType = $this->optimizeScalarType($rightType);
10881095
}
10891096

1097+
if ($leftType instanceof MixedType && $rightType instanceof MixedType) {
1098+
return new BenevolentUnionType([new IntegerType(), new StringType()]);
1099+
}
1100+
10901101
$leftIsString = $leftType->isString();
10911102
$rightIsString = $rightType->isString();
1092-
if ($leftIsString->yes() && $rightIsString->yes()) {
1103+
if (
1104+
($leftIsString->yes() || $leftType instanceof MixedType)
1105+
&& ($rightIsString->yes() || $leftType instanceof MixedType)
1106+
) {
10931107
return new StringType();
10941108
}
10951109
if ($leftIsString->maybe() && $rightIsString->maybe()) {
@@ -1156,9 +1170,16 @@ public function getBitwiseXorTypeFromTypes(Type $leftType, Type $rightType): Typ
11561170
$rightType = $this->optimizeScalarType($rightType);
11571171
}
11581172

1173+
if ($leftType instanceof MixedType && $rightType instanceof MixedType) {
1174+
return new BenevolentUnionType([new IntegerType(), new StringType()]);
1175+
}
1176+
11591177
$leftIsString = $leftType->isString();
11601178
$rightIsString = $rightType->isString();
1161-
if ($leftIsString->yes() && $rightIsString->yes()) {
1179+
if (
1180+
($leftIsString->yes() || $leftType instanceof MixedType)
1181+
&& ($rightIsString->yes() || $leftType instanceof MixedType)
1182+
) {
11621183
return new StringType();
11631184
}
11641185
if ($leftIsString->maybe() && $rightIsString->maybe()) {

0 commit comments

Comments
 (0)