Skip to content

Commit

Permalink
Add integer cast in setMaxResults methods of Query and QueryBuilder (d…
Browse files Browse the repository at this point in the history
  • Loading branch information
mitelg authored Oct 4, 2021
1 parent 02b6f9c commit b1c31e1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/Doctrine/ORM/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,10 @@ public function getFirstResult(): ?int
*/
public function setMaxResults($maxResults): self
{
if ($maxResults !== null) {
$maxResults = (int) $maxResults;
}

$this->maxResults = $maxResults;
$this->_state = self::STATE_DIRTY;

Expand Down
4 changes: 4 additions & 0 deletions lib/Doctrine/ORM/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,10 @@ public function getFirstResult()
*/
public function setMaxResults($maxResults)
{
if ($maxResults !== null) {
$maxResults = (int) $maxResults;
}

$this->_maxResults = $maxResults;

return $this;
Expand Down
7 changes: 7 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@
<file name="lib/Doctrine/ORM/Mapping/Driver/AttributeReader.php"/>
</errorLevel>
</NullArgument>
<RedundantCastGivenDocblockType>
<errorLevel type="suppress">
<!-- Can be removed once the "getMaxResults" methods of those classes have native parameter types -->
<file name="lib/Doctrine/ORM/Query.php"/>
<file name="lib/Doctrine/ORM/QueryBuilder.php"/>
</errorLevel>
</RedundantCastGivenDocblockType>
<TypeDoesNotContainType>
<errorLevel type="suppress">
<file name="lib/Doctrine/ORM/Internal/SQLResultCasing.php"/>
Expand Down

0 comments on commit b1c31e1

Please sign in to comment.