AST
9 months ago
Exec
9 months ago
Expr
9 months ago
Filter
9 months ago
Expr.php
9 months ago
FilterCollection.php
9 months ago
Lexer.php
9 months ago
OutputWalker.php
9 months ago
Parameter.php
9 months ago
ParameterTypeInferer.php
9 months ago
Parser.php
9 months ago
ParserResult.php
9 months ago
Printer.php
9 months ago
QueryException.php
9 months ago
QueryExpressionVisitor.php
9 months ago
ResultSetMapping.php
9 months ago
ResultSetMappingBuilder.php
9 months ago
SqlOutputWalker.php
9 months ago
SqlWalker.php
9 months ago
TokenType.php
9 months ago
TreeWalker.php
9 months ago
TreeWalkerAdapter.php
9 months ago
TreeWalkerChain.php
9 months ago
TreeWalkerChainIterator.php
9 months ago
index.php
9 months ago
ParserResult.php
74 lines
| 1 | <?php |
| 2 | declare (strict_types=1); |
| 3 | namespace MailPoetVendor\Doctrine\ORM\Query; |
| 4 | if (!defined('ABSPATH')) exit; |
| 5 | use MailPoetVendor\Doctrine\ORM\Query; |
| 6 | use MailPoetVendor\Doctrine\ORM\Query\Exec\AbstractSqlExecutor; |
| 7 | use MailPoetVendor\Doctrine\ORM\Query\Exec\SqlFinalizer; |
| 8 | use LogicException; |
| 9 | use function sprintf; |
| 10 | class ParserResult |
| 11 | { |
| 12 | private const LEGACY_PROPERTY_MAPPING = ['sqlExecutor' => '_sqlExecutor', 'resultSetMapping' => '_resultSetMapping', 'parameterMappings' => '_parameterMappings', 'sqlFinalizer' => 'sqlFinalizer']; |
| 13 | private $sqlExecutor; |
| 14 | private $sqlFinalizer; |
| 15 | private $resultSetMapping; |
| 16 | private $parameterMappings = []; |
| 17 | public function __construct() |
| 18 | { |
| 19 | $this->resultSetMapping = new ResultSetMapping(); |
| 20 | } |
| 21 | public function getResultSetMapping() |
| 22 | { |
| 23 | return $this->resultSetMapping; |
| 24 | } |
| 25 | public function setResultSetMapping(ResultSetMapping $rsm) |
| 26 | { |
| 27 | $this->resultSetMapping = $rsm; |
| 28 | } |
| 29 | public function setSqlExecutor($executor) |
| 30 | { |
| 31 | $this->sqlExecutor = $executor; |
| 32 | } |
| 33 | public function getSqlExecutor() |
| 34 | { |
| 35 | return $this->sqlExecutor; |
| 36 | } |
| 37 | public function setSqlFinalizer(SqlFinalizer $finalizer) : void |
| 38 | { |
| 39 | $this->sqlFinalizer = $finalizer; |
| 40 | } |
| 41 | public function prepareSqlExecutor(Query $query) : AbstractSqlExecutor |
| 42 | { |
| 43 | if ($this->sqlFinalizer !== null) { |
| 44 | return $this->sqlFinalizer->createExecutor($query); |
| 45 | } |
| 46 | if ($this->sqlExecutor !== null) { |
| 47 | return $this->sqlExecutor; |
| 48 | } |
| 49 | throw new LogicException('This ParserResult lacks both the SqlFinalizer as well as the (legacy) SqlExecutor'); |
| 50 | } |
| 51 | public function addParameterMapping($dqlPosition, $sqlPosition) |
| 52 | { |
| 53 | $this->parameterMappings[$dqlPosition][] = $sqlPosition; |
| 54 | } |
| 55 | public function getParameterMappings() |
| 56 | { |
| 57 | return $this->parameterMappings; |
| 58 | } |
| 59 | public function getSqlParameterPositions($dqlPosition) |
| 60 | { |
| 61 | return $this->parameterMappings[$dqlPosition]; |
| 62 | } |
| 63 | public function __wakeup() : void |
| 64 | { |
| 65 | $this->__unserialize((array) $this); |
| 66 | } |
| 67 | public function __unserialize(array $data) : void |
| 68 | { |
| 69 | foreach (self::LEGACY_PROPERTY_MAPPING as $property => $legacyProperty) { |
| 70 | $this->{$property} = $data[sprintf("\x00%s\x00%s", self::class, $legacyProperty)] ?? $data[self::class][$legacyProperty] ?? $data[sprintf("\x00%s\x00%s", self::class, $property)] ?? $data[self::class][$property] ?? $this->{$property} ?? null; |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 |