Skip to content

Commit

Permalink
Fixing nullability of array types of DbalParams
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCelavi committed Aug 15, 2024
1 parent b3a6882 commit aadda5b
Showing 1 changed file with 28 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,17 @@ final public function timeImmutable(string $name, ?\DateTimeInterface $value): s
/**
* Set parameter value as array of integers.
*
* @param string $name Parameter name.
* @param iterable<int> $value Parameter value.
* @param string $name Parameter name.
* @param ?iterable<int> $value Parameter value.
*
* @return self Fluent return.
*/
final public function integerArray(string $name, iterable $value): self
final public function integerArray(string $name, ?iterable $value): self
{
if (null === $value) {
return $this->set($name, null, ArrayParameterType::INTEGER);
}

$value = \is_array($value) ? \array_values($value) : \iterator_to_array($value, false);

return $this->set($name, $value, ArrayParameterType::INTEGER);
Expand All @@ -193,13 +197,17 @@ final public function integerArray(string $name, iterable $value): self
/**
* Set parameter value as array of strings.
*
* @param string $name Parameter name.
* @param iterable<\Stringable|string> $value Parameter value.
* @param string $name Parameter name.
* @param ?iterable<\Stringable|string> $value Parameter value.
*
* @return self Fluent return.
*/
final public function stringArray(string $name, iterable $value): self
final public function stringArray(string $name, ?iterable $value): self
{
if (null === $value) {
return $this->set($name, null, ArrayParameterType::STRING);
}

$value = \array_map(
static fn(\Stringable|string $value): string => $value instanceof \Stringable ? (string)$value : $value,
\is_array($value) ? \array_values($value) : \iterator_to_array($value, false)
Expand All @@ -211,13 +219,17 @@ final public function stringArray(string $name, iterable $value): self
/**
* Set parameter value as array of ascii strings.
*
* @param string $name Parameter name.
* @param iterable<\Stringable|string> $value Parameter value.
* @param string $name Parameter name.
* @param ?iterable<\Stringable|string> $value Parameter value.
*
* @return self Fluent return.
*/
final public function asciiArray(string $name, iterable $value): self
final public function asciiArray(string $name, ?iterable $value): self
{
if (null === $value) {
return $this->set($name, null, ArrayParameterType::ASCII);
}

$value = \array_map(
static fn(\Stringable|string $value): string => $value instanceof \Stringable ? (string)$value : $value,
\is_array($value) ? \array_values($value) : \iterator_to_array($value, false)
Expand All @@ -229,13 +241,17 @@ final public function asciiArray(string $name, iterable $value): self
/**
* Set parameter value as array of binary values.
*
* @param string $name Parameter name.
* @param iterable<mixed> $value Parameter value.
* @param string $name Parameter name.
* @param ?iterable<mixed> $value Parameter value.
*
* @return self Fluent return.
*/
final public function binaryArray(string $name, iterable $value): self
final public function binaryArray(string $name, ?iterable $value): self
{
if (null === $value) {
return $this->set($name, null, ArrayParameterType::BINARY);
}

return $this->set($name, \is_array($value) ? \array_values($value) : \iterator_to_array($value, false), ArrayParameterType::BINARY);
}
}

0 comments on commit aadda5b

Please sign in to comment.