From 9eabd9eb927d2ed6a38c0c3c22840357f23e8c82 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Mon, 29 Jan 2024 16:44:50 +0100 Subject: [PATCH] Fix a Psalm complaint --- lib/Doctrine/ORM/Query.php | 4 ++-- lib/Doctrine/ORM/Query/ParserResult.php | 10 +++++++--- psalm-baseline.xml | 17 ++++++++++++++++- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/lib/Doctrine/ORM/Query.php b/lib/Doctrine/ORM/Query.php index a8ccf3ae503..34c349de45f 100644 --- a/lib/Doctrine/ORM/Query.php +++ b/lib/Doctrine/ORM/Query.php @@ -149,8 +149,8 @@ class Query extends AbstractQuery */ private $parserResult; - /** @var AbstractSqlExecutor */ - private $sqlExecutor = null; + /** @var ?AbstractSqlExecutor */ + private $sqlExecutor; /** * The first result to return (the "offset"). diff --git a/lib/Doctrine/ORM/Query/ParserResult.php b/lib/Doctrine/ORM/Query/ParserResult.php index ef78cc5e4cf..fedbfe28837 100644 --- a/lib/Doctrine/ORM/Query/ParserResult.php +++ b/lib/Doctrine/ORM/Query/ParserResult.php @@ -28,16 +28,16 @@ class ParserResult /** * The SQL executor used for executing the SQL. * - * @var AbstractSqlExecutor + * @var ?AbstractSqlExecutor */ private $sqlExecutor; /** * The SQL executor used for executing the SQL. * - * @var SqlFinalizer + * @var ?SqlFinalizer */ - private $sqlFinalizer = null; + private $sqlFinalizer; /** * The ResultSetMapping that describes how to map the SQL result set. @@ -101,6 +101,10 @@ public function setSqlExecutor($executor) */ public function getSqlExecutor() { + if ($this->sqlExecutor === null) { + throw new RuntimeException('This ParserResult was not created with an SqlExecutor'); + } + return $this->sqlExecutor; } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 90cbc63a1c0..49851534536 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1445,12 +1445,18 @@ $sqlParams + + AbstractSqlExecutor + - parse()->getSqlExecutor()->getSqlStatements()]]> + getSqlExecutor()->getSqlStatements()]]> |string]]> + + sqlExecutor]]> + getDQL()]]> @@ -1866,6 +1872,15 @@ _sqlStatements = &$this->sqlStatements]]> + + + getSqlStatements()]]> + + + FinalizedSelectExecutor + FinalizedSelectExecutor + + $numDeleted