Skip to content
Merged
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
4 changes: 4 additions & 0 deletions src/SelectTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ public function prepend(Closure|array|null $prepend = null): static

if (is_array($this->prepend) && isset($this->prepend['name'], $this->prepend['value'])) {
$this->prepend['value'] = (string) $this->prepend['value'];
} else if (is_null($this->prepend)){
# Avoid throwing an exception in case $prepend is explicitly set to null, or a Closure evaluates to null.
} else {
throw new InvalidArgumentException('The provided prepend value must be an array with "name" and "value" keys.');
}
Expand All @@ -326,6 +328,8 @@ public function append(Closure|array|null $append = null): static

if (is_array($this->append) && isset($this->append['name'], $this->append['value'])) {
$this->append['value'] = (string) $this->append['value'];
} else if (is_null($this->append)) {
// Avoid throwing an exception in case $append is explicitly set to null, or a Closure evaluates to null.
} else {
throw new \InvalidArgumentException('The provided append value must be an array with "name" and "value" keys.');
}
Expand Down