JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr */ private array $convertedSQL = []; /** @var list */ private array $convertedParameters = []; /** @var array,string|ParameterType|Type> */ private array $convertedTypes = []; /** * @param array|array $parameters * @psalm-param WrapperParameterTypeArray $types */ public function __construct( private readonly array $parameters, private readonly array $types, ) { } public function acceptPositionalParameter(string $sql): void { $index = $this->originalParameterIndex; if (! array_key_exists($index, $this->parameters)) { throw MissingPositionalParameter::new($index); } $this->acceptParameter($index, $this->parameters[$index]); $this->originalParameterIndex++; } public function acceptNamedParameter(string $sql): void { $name = substr($sql, 1); if (! array_key_exists($name, $this->parameters)) { throw MissingNamedParameter::new($name); } $this->acceptParameter($name, $this->parameters[$name]); } public function acceptOther(string $sql): void { $this->convertedSQL[] = $sql; } public function getSQL(): string { return implode('', $this->convertedSQL); } /** @return list */ public function getParameters(): array { return $this->convertedParameters; } private function acceptParameter(int|string $key, mixed $value): void { if (! isset($this->types[$key])) { $this->convertedSQL[] = '?'; $this->convertedParameters[] = $value; return; } $type = $this->types[$key]; if (! $type instanceof ArrayParameterType) { $this->appendTypedParameter([$value], $type); return; } if (count($value) === 0) { $this->convertedSQL[] = 'NULL'; return; } $this->appendTypedParameter($value, ArrayParameterType::toElementParameterType($type)); } /** @return array,string|ParameterType|Type> */ public function getTypes(): array { return $this->convertedTypes; } /** @param list $values */ private function appendTypedParameter(array $values, string|ParameterType|Type $type): void { $this->convertedSQL[] = implode(', ', array_fill(0, count($values), '?')); $index = count($this->convertedParameters); foreach ($values as $value) { $this->convertedParameters[] = $value; $this->convertedTypes[$index] = $type; $index++; } } }