Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/Type/Constant/ConstantArrayType.php
Original file line number Diff line number Diff line change
Expand Up @@ -913,10 +913,7 @@ public function shiftArray(): Type

public function shuffleArray(): Type
{
$builder = ConstantArrayTypeBuilder::createFromConstantArray($this->getValuesArray());
$builder->degradeToGeneralArray();

return $builder->getArray();
return $this->getValuesArray()->degradeToGeneralArray();
}

public function sliceArray(Type $offsetType, Type $lengthType, TrinaryLogic $preserveKeys): Type
Expand All @@ -937,10 +934,7 @@ public function sliceArray(Type $offsetType, Type $lengthType, TrinaryLogic $pre
}

if ($offset === null || $length === null) {
$builder = ConstantArrayTypeBuilder::createFromConstantArray($this);
$builder->degradeToGeneralArray();

return $builder->getArray()
return $this->degradeToGeneralArray()
->sliceArray($offsetType, $lengthType, $preserveKeys);
}

Expand Down Expand Up @@ -1252,6 +1246,14 @@ public function generalizeValues(): self
return new self($this->keyTypes, $valueTypes, $this->nextAutoIndexes, $this->optionalKeys, $this->isList);
}

private function degradeToGeneralArray(): Type
{
$builder = ConstantArrayTypeBuilder::createFromConstantArray($this);
$builder->degradeToGeneralArray();

return $builder->getArray();
}

public function getKeysArray(): self
{
return $this->getKeysOrValuesArray($this->keyTypes);
Expand Down
Loading