Skip to content

Commit

Permalink
Fix a Psalm complaint
Browse files Browse the repository at this point in the history
  • Loading branch information
mpdude committed Jan 29, 2024
1 parent 4f0c01f commit 9eabd9e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -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").
Expand Down
10 changes: 7 additions & 3 deletions lib/Doctrine/ORM/Query/ParserResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}

Expand Down
17 changes: 16 additions & 1 deletion psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1445,12 +1445,18 @@
<InvalidArgument>
<code>$sqlParams</code>
</InvalidArgument>
<InvalidNullableReturnType>
<code>AbstractSqlExecutor</code>
</InvalidNullableReturnType>
<LessSpecificReturnStatement>
<code><![CDATA[$this->parse()->getSqlExecutor()->getSqlStatements()]]></code>
<code><![CDATA[$this->getSqlExecutor()->getSqlStatements()]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[list<string>|string]]></code>
</MoreSpecificReturnType>
<NullableReturnStatement>
<code><![CDATA[$this->sqlExecutor]]></code>
</NullableReturnStatement>
<PossiblyNullArgument>
<code><![CDATA[$this->getDQL()]]></code>
</PossiblyNullArgument>
Expand Down Expand Up @@ -1866,6 +1872,15 @@
<code><![CDATA[$this->_sqlStatements = &$this->sqlStatements]]></code>
</UnsupportedPropertyReferenceUsage>
</file>
<file src="lib/Doctrine/ORM/Query/Exec/FinalizedSelectExecutor.php">
<PossiblyInvalidArgument>
<code><![CDATA[$this->getSqlStatements()]]></code>
</PossiblyInvalidArgument>
<PropertyNotSetInConstructor>
<code>FinalizedSelectExecutor</code>
<code>FinalizedSelectExecutor</code>
</PropertyNotSetInConstructor>
</file>
<file src="lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php">
<InvalidReturnStatement>
<code>$numDeleted</code>
Expand Down

0 comments on commit 9eabd9e

Please sign in to comment.