From 676a388d3302c14495a9e6620fef7fd8abc3fc0c Mon Sep 17 00:00:00 2001 From: Valentin Udaltsov Date: Sat, 24 Feb 2024 19:17:10 +0300 Subject: [PATCH] Return array for unsealed array shape without elements --- src/types.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/types.php b/src/types.php index e834b6d..3ada628 100644 --- a/src/types.php +++ b/src/types.php @@ -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,