Skip to content

Commit

Permalink
Return array for unsealed array shape without elements
Browse files Browse the repository at this point in the history
  • Loading branch information
vudaltsov committed Feb 24, 2024
1 parent dc8f72f commit 676a388
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/types.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ public static function arrayElement(Type $type, bool $optional = false): ArrayEl
*/
public static function arrayShape(array $elements = [], bool $sealed = true): Type
{
if (!$sealed && $elements === []) {
return self::array;
}

return new ArrayShapeType(
array_map(
static fn(Type|ArrayElement $element): ArrayElement => $element instanceof Type ? new ArrayElement($element) : $element,
Expand Down

0 comments on commit 676a388

Please sign in to comment.