@@ -693,7 +693,7 @@ public function getOffsetValueType(Type $offsetType): Type
693693
694694 public function setOffsetValueType (?Type $ offsetType , Type $ valueType , bool $ unionValues = true ): Type
695695 {
696- if ($ offsetType !== null && $ valueType -> isConstantScalarValue ()-> yes () ) {
696+ if ($ offsetType !== null ) {
697697 if ($ offsetType instanceof IntegerRangeType) {
698698 $ constantScalars = $ offsetType ->getFiniteTypes ();
699699 } else {
@@ -720,24 +720,22 @@ public function setOffsetValueType(?Type $offsetType, Type $valueType, bool $uni
720720
721721 public function setExistingOffsetValueType (Type $ offsetType , Type $ valueType ): Type
722722 {
723- if ($ valueType ->isConstantScalarValue ()->yes ()) {
724- if ($ offsetType instanceof IntegerRangeType) {
725- $ constantScalars = $ offsetType ->getFiniteTypes ();
726- } else {
727- $ constantScalars = $ offsetType ->getConstantScalarTypes ();
728- }
729-
730- $ constantScalarsCount = count ($ constantScalars );
731- if ($ constantScalarsCount > 1 && $ constantScalarsCount < ConstantArrayTypeBuilder::ARRAY_COUNT_LIMIT ) {
732- $ arrays = [];
733- foreach ($ constantScalars as $ constantScalar ) {
734- $ builder = ConstantArrayTypeBuilder::createFromConstantArray ($ this );
735- $ builder ->setOffsetValueType ($ constantScalar , $ valueType );
736- $ arrays [] = $ builder ->getArray ();
737- }
723+ if ($ offsetType instanceof IntegerRangeType) {
724+ $ constantScalars = $ offsetType ->getFiniteTypes ();
725+ } else {
726+ $ constantScalars = $ offsetType ->getConstantScalarTypes ();
727+ }
738728
739- return TypeCombinator::union (...$ arrays );
729+ $ constantScalarsCount = count ($ constantScalars );
730+ if ($ constantScalarsCount > 1 && $ constantScalarsCount < ConstantArrayTypeBuilder::ARRAY_COUNT_LIMIT ) {
731+ $ arrays = [];
732+ foreach ($ constantScalars as $ constantScalar ) {
733+ $ builder = ConstantArrayTypeBuilder::createFromConstantArray ($ this );
734+ $ builder ->setOffsetValueType ($ constantScalar , $ valueType );
735+ $ arrays [] = $ builder ->getArray ();
740736 }
737+
738+ return TypeCombinator::union (...$ arrays );
741739 }
742740
743741 $ builder = ConstantArrayTypeBuilder::createFromConstantArray ($ this );
0 commit comments