Skip to content

Commit 93840bd

Browse files
committed
Fix nullable parameter for empty array
1 parent 9def3f2 commit 93840bd

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/Types/AnArray.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
class AnArray extends Base
99
{
1010

11-
private Base $items;
11+
private ?Base $items;
1212
private ?int $minItems, $maxItems;
1313
private ?bool $uniqueItems;
1414

1515
#[Pure]
16-
private function __construct($items)
16+
private function __construct(?Base $items)
1717
{
1818

1919
$this->minItems = null;
@@ -26,7 +26,7 @@ private function __construct($items)
2626
final public static function naked(): self
2727
{
2828

29-
return new self([]);
29+
return new self(null);
3030
}
3131

3232
/**
@@ -89,7 +89,10 @@ final public function jsonSerialize(): array
8989

9090
$return = parent::jsonSerialize();
9191
$return['type'] = 'array';
92-
$return['items'] = $this->items;
92+
93+
if ($this->items !== null) {
94+
$return['items'] = $this->items;
95+
}
9396

9497
if ($this->minItems !== null) {
9598
$return['minItems'] = $this->minItems;

0 commit comments

Comments
 (0)