33namespace PHPStan \Type \Constant ;
44
55use PHPStan \ShouldNotHappenException ;
6+ use PHPStan \TrinaryLogic ;
67use PHPStan \Type \Accessory \AccessoryArrayListType ;
78use PHPStan \Type \Accessory \NonEmptyArrayType ;
89use PHPStan \Type \Accessory \OversizedArrayType ;
@@ -42,14 +43,14 @@ private function __construct(
4243 private array $ valueTypes ,
4344 private array $ nextAutoIndexes ,
4445 private array $ optionalKeys ,
45- private bool $ isList ,
46+ private TrinaryLogic $ isList ,
4647 )
4748 {
4849 }
4950
5051 public static function createEmpty (): self
5152 {
52- return new self ([], [], [0 ], [], true );
53+ return new self ([], [], [0 ], [], TrinaryLogic:: createYes () );
5354 }
5455
5556 public static function createFromConstantArray (ConstantArrayType $ startArrayType ): self
@@ -59,7 +60,7 @@ public static function createFromConstantArray(ConstantArrayType $startArrayType
5960 $ startArrayType ->getValueTypes (),
6061 $ startArrayType ->getNextAutoIndexes (),
6162 $ startArrayType ->getOptionalKeys (),
62- $ startArrayType ->isList ()-> yes () ,
63+ $ startArrayType ->isList (),
6364 );
6465
6566 if (count ($ startArrayType ->getKeyTypes ()) > self ::ARRAY_COUNT_LIMIT ) {
@@ -162,7 +163,7 @@ public function setOffsetValueType(?Type $offsetType, Type $valueType, bool $opt
162163 $ min = min ($ this ->nextAutoIndexes );
163164 $ max = max ($ this ->nextAutoIndexes );
164165 if ($ offsetType ->getValue () > $ min ) {
165- $ this ->isList = false ;
166+ $ this ->isList = TrinaryLogic:: createNo () ;
166167 }
167168 if ($ offsetType ->getValue () >= $ max ) {
168169 /** @var int|float $newAutoIndex */
@@ -177,7 +178,7 @@ public function setOffsetValueType(?Type $offsetType, Type $valueType, bool $opt
177178 }
178179 }
179180 } else {
180- $ this ->isList = false ;
181+ $ this ->isList = TrinaryLogic:: createNo () ;
181182 }
182183
183184 if ($ optional ) {
@@ -191,7 +192,7 @@ public function setOffsetValueType(?Type $offsetType, Type $valueType, bool $opt
191192 return ;
192193 }
193194
194- $ this ->isList = false ;
195+ $ this ->isList = TrinaryLogic:: createNo () ;
195196
196197 $ scalarTypes = $ offsetType ->getConstantScalarTypes ();
197198 if (count ($ scalarTypes ) === 0 ) {
@@ -254,7 +255,7 @@ public function setOffsetValueType(?Type $offsetType, Type $valueType, bool $opt
254255 if ($ offsetType === null ) {
255256 $ offsetType = TypeCombinator::union (...array_map (static fn (int $ index ) => new ConstantIntegerType ($ index ), $ this ->nextAutoIndexes ));
256257 } else {
257- $ this ->isList = false ;
258+ $ this ->isList = TrinaryLogic:: createNo () ;
258259 }
259260
260261 $ this ->keyTypes [] = $ offsetType ;
@@ -297,7 +298,7 @@ public function getArray(): Type
297298 $ array = TypeCombinator::intersect ($ array , new OversizedArrayType ());
298299 }
299300
300- if ($ this ->isList ) {
301+ if ($ this ->isList -> yes () ) {
301302 $ array = AccessoryArrayListType::intersectWith ($ array );
302303 }
303304
@@ -306,7 +307,7 @@ public function getArray(): Type
306307
307308 public function isList (): bool
308309 {
309- return $ this ->isList ;
310+ return $ this ->isList -> yes () ;
310311 }
311312
312313}
0 commit comments