Skip to content

Commit 302a9b7

Browse files
committed
Fix a Psalm complaint
1 parent 4f0c01f commit 302a9b7

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

lib/Doctrine/ORM/Query.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ class Query extends AbstractQuery
149149
*/
150150
private $parserResult;
151151

152-
/** @var AbstractSqlExecutor */
153-
private $sqlExecutor = null;
152+
/** @var ?AbstractSqlExecutor */
153+
private $sqlExecutor;
154154

155155
/**
156156
* The first result to return (the "offset").

lib/Doctrine/ORM/Query/ParserResult.php

+7-3
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ class ParserResult
2828
/**
2929
* The SQL executor used for executing the SQL.
3030
*
31-
* @var AbstractSqlExecutor
31+
* @var ?AbstractSqlExecutor
3232
*/
3333
private $sqlExecutor;
3434

3535
/**
3636
* The SQL executor used for executing the SQL.
3737
*
38-
* @var SqlFinalizer
38+
* @var ?SqlFinalizer
3939
*/
40-
private $sqlFinalizer = null;
40+
private $sqlFinalizer;
4141

4242
/**
4343
* The ResultSetMapping that describes how to map the SQL result set.
@@ -101,6 +101,10 @@ public function setSqlExecutor($executor)
101101
*/
102102
public function getSqlExecutor()
103103
{
104+
if ($this->sqlExecutor === null) {
105+
throw new RuntimeException('This ParserResult was not created with an SqlExecutor');
106+
}
107+
104108
return $this->sqlExecutor;
105109
}
106110

psalm-baseline.xml

+16-6
Original file line numberDiff line numberDiff line change
@@ -1445,12 +1445,18 @@
14451445
<InvalidArgument>
14461446
<code>$sqlParams</code>
14471447
</InvalidArgument>
1448+
<InvalidNullableReturnType>
1449+
<code>AbstractSqlExecutor</code>
1450+
</InvalidNullableReturnType>
14481451
<LessSpecificReturnStatement>
1449-
<code><![CDATA[$this->parse()->getSqlExecutor()->getSqlStatements()]]></code>
1452+
<code><![CDATA[$this->getSqlExecutor()->getSqlStatements()]]></code>
14501453
</LessSpecificReturnStatement>
14511454
<MoreSpecificReturnType>
14521455
<code><![CDATA[list<string>|string]]></code>
14531456
</MoreSpecificReturnType>
1457+
<NullableReturnStatement>
1458+
<code><![CDATA[$this->sqlExecutor]]></code>
1459+
</NullableReturnStatement>
14541460
<PossiblyNullArgument>
14551461
<code><![CDATA[$this->getDQL()]]></code>
14561462
</PossiblyNullArgument>
@@ -1866,6 +1872,15 @@
18661872
<code><![CDATA[$this->_sqlStatements = &$this->sqlStatements]]></code>
18671873
</UnsupportedPropertyReferenceUsage>
18681874
</file>
1875+
<file src="lib/Doctrine/ORM/Query/Exec/FinalizedSelectExecutor.php">
1876+
<PossiblyInvalidArgument>
1877+
<code><![CDATA[$this->getSqlStatements()]]></code>
1878+
</PossiblyInvalidArgument>
1879+
<PropertyNotSetInConstructor>
1880+
<code>FinalizedSelectExecutor</code>
1881+
<code>FinalizedSelectExecutor</code>
1882+
</PropertyNotSetInConstructor>
1883+
</file>
18691884
<file src="lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php">
18701885
<InvalidReturnStatement>
18711886
<code>$numDeleted</code>
@@ -2058,11 +2073,6 @@
20582073
<code>$token === Lexer::T_IDENTIFIER</code>
20592074
</RedundantConditionGivenDocblockType>
20602075
</file>
2061-
<file src="lib/Doctrine/ORM/Query/ParserResult.php">
2062-
<PropertyNotSetInConstructor>
2063-
<code>$sqlExecutor</code>
2064-
</PropertyNotSetInConstructor>
2065-
</file>
20662076
<file src="lib/Doctrine/ORM/Query/QueryExpressionVisitor.php">
20672077
<InvalidReturnStatement>
20682078
<code><![CDATA[new ArrayCollection($this->parameters)]]></code>

0 commit comments

Comments
 (0)