Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
621 lars 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace Doctrine\DBAL\Driver\PgSQL;
6
 
7
use Doctrine\DBAL\SQL\Parser\Visitor;
8
 
9
use function count;
10
use function implode;
11
 
12
final class ConvertParameters implements Visitor
13
{
14
    /** @var list<string> */
15
    private array $buffer = [];
16
 
17
    /** @var array<array-key, int> */
18
    private array $parameterMap = [];
19
 
20
    public function acceptPositionalParameter(string $sql): void
21
    {
22
        $position                      = count($this->parameterMap) + 1;
23
        $this->parameterMap[$position] = $position;
24
        $this->buffer[]                = '$' . $position;
25
    }
26
 
27
    public function acceptNamedParameter(string $sql): void
28
    {
29
        $position                 = count($this->parameterMap) + 1;
30
        $this->parameterMap[$sql] = $position;
31
        $this->buffer[]           = '$' . $position;
32
    }
33
 
34
    public function acceptOther(string $sql): void
35
    {
36
        $this->buffer[] = $sql;
37
    }
38
 
39
    public function getSQL(): string
40
    {
41
        return implode('', $this->buffer);
42
    }
43
 
44
    /** @return array<array-key, int> */
45
    public function getParameterMap(): array
46
    {
47
        return $this->parameterMap;
48
    }
49
}