diff options
Diffstat (limited to 'vendor/doctrine/orm/src/Query/ParserResult.php')
| -rw-r--r-- | vendor/doctrine/orm/src/Query/ParserResult.php | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/vendor/doctrine/orm/src/Query/ParserResult.php b/vendor/doctrine/orm/src/Query/ParserResult.php new file mode 100644 index 0000000..8b5ee1f --- /dev/null +++ b/vendor/doctrine/orm/src/Query/ParserResult.php | |||
| @@ -0,0 +1,118 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\ORM\Query; | ||
| 6 | |||
| 7 | use Doctrine\ORM\Query\Exec\AbstractSqlExecutor; | ||
| 8 | use LogicException; | ||
| 9 | |||
| 10 | use function sprintf; | ||
| 11 | |||
| 12 | /** | ||
| 13 | * Encapsulates the resulting components from a DQL query parsing process that | ||
| 14 | * can be serialized. | ||
| 15 | * | ||
| 16 | * @link http://www.doctrine-project.org | ||
| 17 | */ | ||
| 18 | class ParserResult | ||
| 19 | { | ||
| 20 | /** | ||
| 21 | * The SQL executor used for executing the SQL. | ||
| 22 | */ | ||
| 23 | private AbstractSqlExecutor|null $sqlExecutor = null; | ||
| 24 | |||
| 25 | /** | ||
| 26 | * The ResultSetMapping that describes how to map the SQL result set. | ||
| 27 | */ | ||
| 28 | private ResultSetMapping $resultSetMapping; | ||
| 29 | |||
| 30 | /** | ||
| 31 | * The mappings of DQL parameter names/positions to SQL parameter positions. | ||
| 32 | * | ||
| 33 | * @psalm-var array<string|int, list<int>> | ||
| 34 | */ | ||
| 35 | private array $parameterMappings = []; | ||
| 36 | |||
| 37 | /** | ||
| 38 | * Initializes a new instance of the <tt>ParserResult</tt> class. | ||
| 39 | * The new instance is initialized with an empty <tt>ResultSetMapping</tt>. | ||
| 40 | */ | ||
| 41 | public function __construct() | ||
| 42 | { | ||
| 43 | $this->resultSetMapping = new ResultSetMapping(); | ||
| 44 | } | ||
| 45 | |||
| 46 | /** | ||
| 47 | * Gets the ResultSetMapping for the parsed query. | ||
| 48 | * | ||
| 49 | * @return ResultSetMapping The result set mapping of the parsed query | ||
| 50 | */ | ||
| 51 | public function getResultSetMapping(): ResultSetMapping | ||
| 52 | { | ||
| 53 | return $this->resultSetMapping; | ||
| 54 | } | ||
| 55 | |||
| 56 | /** | ||
| 57 | * Sets the ResultSetMapping of the parsed query. | ||
| 58 | */ | ||
| 59 | public function setResultSetMapping(ResultSetMapping $rsm): void | ||
| 60 | { | ||
| 61 | $this->resultSetMapping = $rsm; | ||
| 62 | } | ||
| 63 | |||
| 64 | /** | ||
| 65 | * Sets the SQL executor that should be used for this ParserResult. | ||
| 66 | */ | ||
| 67 | public function setSqlExecutor(AbstractSqlExecutor $executor): void | ||
| 68 | { | ||
| 69 | $this->sqlExecutor = $executor; | ||
| 70 | } | ||
| 71 | |||
| 72 | /** | ||
| 73 | * Gets the SQL executor used by this ParserResult. | ||
| 74 | */ | ||
| 75 | public function getSqlExecutor(): AbstractSqlExecutor | ||
| 76 | { | ||
| 77 | if ($this->sqlExecutor === null) { | ||
| 78 | throw new LogicException(sprintf( | ||
| 79 | 'Executor not set yet. Call %s::setSqlExecutor() first.', | ||
| 80 | self::class, | ||
| 81 | )); | ||
| 82 | } | ||
| 83 | |||
| 84 | return $this->sqlExecutor; | ||
| 85 | } | ||
| 86 | |||
| 87 | /** | ||
| 88 | * Adds a DQL to SQL parameter mapping. One DQL parameter name/position can map to | ||
| 89 | * several SQL parameter positions. | ||
| 90 | */ | ||
| 91 | public function addParameterMapping(string|int $dqlPosition, int $sqlPosition): void | ||
| 92 | { | ||
| 93 | $this->parameterMappings[$dqlPosition][] = $sqlPosition; | ||
| 94 | } | ||
| 95 | |||
| 96 | /** | ||
| 97 | * Gets all DQL to SQL parameter mappings. | ||
| 98 | * | ||
| 99 | * @psalm-return array<int|string, list<int>> The parameter mappings. | ||
| 100 | */ | ||
| 101 | public function getParameterMappings(): array | ||
| 102 | { | ||
| 103 | return $this->parameterMappings; | ||
| 104 | } | ||
| 105 | |||
| 106 | /** | ||
| 107 | * Gets the SQL parameter positions for a DQL parameter name/position. | ||
| 108 | * | ||
| 109 | * @param string|int $dqlPosition The name or position of the DQL parameter. | ||
| 110 | * | ||
| 111 | * @return int[] The positions of the corresponding SQL parameters. | ||
| 112 | * @psalm-return list<int> | ||
| 113 | */ | ||
| 114 | public function getSqlParameterPositions(string|int $dqlPosition): array | ||
| 115 | { | ||
| 116 | return $this->parameterMappings[$dqlPosition]; | ||
| 117 | } | ||
| 118 | } | ||
