@@ -699,7 +699,7 @@ public function getOffsetValueType(Type $offsetType): Type
699699
700700 public function setOffsetValueType (?Type $ offsetType , Type $ valueType , bool $ unionValues = true ): Type
701701 {
702- if ($ offsetType !== null && $ valueType -> isConstantScalarValue ()-> yes () ) {
702+ if ($ offsetType !== null ) {
703703 if ($ offsetType instanceof IntegerRangeType) {
704704 $ constantScalars = $ offsetType ->getFiniteTypes ();
705705 } else {
@@ -726,24 +726,22 @@ public function setOffsetValueType(?Type $offsetType, Type $valueType, bool $uni
726726
727727 public function setExistingOffsetValueType (Type $ offsetType , Type $ valueType ): Type
728728 {
729- if ($ valueType ->isConstantScalarValue ()->yes ()) {
730- if ($ offsetType instanceof IntegerRangeType) {
731- $ constantScalars = $ offsetType ->getFiniteTypes ();
732- } else {
733- $ constantScalars = $ offsetType ->getConstantScalarTypes ();
734- }
735-
736- $ constantScalarsCount = count ($ constantScalars );
737- if ($ constantScalarsCount > 1 && $ constantScalarsCount < ConstantArrayTypeBuilder::ARRAY_COUNT_LIMIT ) {
738- $ arrays = [];
739- foreach ($ constantScalars as $ constantScalar ) {
740- $ builder = ConstantArrayTypeBuilder::createFromConstantArray ($ this );
741- $ builder ->setOffsetValueType ($ constantScalar , $ valueType );
742- $ arrays [] = $ builder ->getArray ();
743- }
729+ if ($ offsetType instanceof IntegerRangeType) {
730+ $ constantScalars = $ offsetType ->getFiniteTypes ();
731+ } else {
732+ $ constantScalars = $ offsetType ->getConstantScalarTypes ();
733+ }
744734
745- return TypeCombinator::union (...$ arrays );
735+ $ constantScalarsCount = count ($ constantScalars );
736+ if ($ constantScalarsCount > 1 && $ constantScalarsCount < ConstantArrayTypeBuilder::ARRAY_COUNT_LIMIT ) {
737+ $ arrays = [];
738+ foreach ($ constantScalars as $ constantScalar ) {
739+ $ builder = ConstantArrayTypeBuilder::createFromConstantArray ($ this );
740+ $ builder ->setOffsetValueType ($ constantScalar , $ valueType );
741+ $ arrays [] = $ builder ->getArray ();
746742 }
743+
744+ return TypeCombinator::union (...$ arrays );
747745 }
748746
749747 $ builder = ConstantArrayTypeBuilder::createFromConstantArray ($ this );
0 commit comments