@@ -126,8 +126,8 @@ public function isSuperTypeOf(Type $type): TrinaryLogic
126
126
public function equals (Type $ type ): bool
127
127
{
128
128
return $ type instanceof self
129
- && ! $ type instanceof ConstantArrayType
130
- && $ this ->getItemType ()->equals ($ type ->getItemType ())
129
+ && $ type-> isConstantArray ()-> no ()
130
+ && $ this ->getItemType ()->equals ($ type ->getIterableValueType ())
131
131
&& $ this ->keyType ->equals ($ type ->keyType );
132
132
}
133
133
@@ -238,6 +238,11 @@ public function isArray(): TrinaryLogic
238
238
return TrinaryLogic::createYes ();
239
239
}
240
240
241
+ public function isConstantArray (): TrinaryLogic
242
+ {
243
+ return TrinaryLogic::createNo ();
244
+ }
245
+
241
246
public function isOversizedArray (): TrinaryLogic
242
247
{
243
248
return TrinaryLogic::createMaybe ();
@@ -509,19 +514,19 @@ public function traverse(callable $cb): Type
509
514
510
515
public function tryRemove (Type $ typeToRemove ): ?Type
511
516
{
512
- if ($ typeToRemove instanceof ConstantArrayType && $ typeToRemove ->isIterableAtLeastOnce ()->no ()) {
517
+ if ($ typeToRemove-> isConstantArray ()-> yes () && $ typeToRemove ->isIterableAtLeastOnce ()->no ()) {
513
518
return TypeCombinator::intersect ($ this , new NonEmptyArrayType ());
514
519
}
515
520
516
521
if ($ typeToRemove instanceof NonEmptyArrayType) {
517
522
return new ConstantArrayType ([], []);
518
523
}
519
524
520
- if ($ this instanceof ConstantArrayType && $ typeToRemove instanceof HasOffsetType) {
525
+ if ($ this -> isConstantArray ()-> yes () && $ typeToRemove instanceof HasOffsetType) {
521
526
return $ this ->unsetOffset ($ typeToRemove ->getOffsetType ());
522
527
}
523
528
524
- if ($ this instanceof ConstantArrayType && $ typeToRemove instanceof HasOffsetValueType) {
529
+ if ($ this -> isConstantArray ()-> yes () && $ typeToRemove instanceof HasOffsetValueType) {
525
530
return $ this ->unsetOffset ($ typeToRemove ->getOffsetType ());
526
531
}
527
532
0 commit comments