fix(db): Add a hint that we return PHP_INT_MAX

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2024-07-02 12:26:56 +02:00
parent 66aac18bad
commit 98b6c7c48a
No known key found for this signature in database
GPG key ID: 74434EFE0D2E2205
4 changed files with 8 additions and 9 deletions

View file

@ -317,7 +317,7 @@ class Connection extends PrimaryReadReplicaConnection {
* @param array $params The query parameters.
* @param array $types The parameter types.
*
* @return int The number of affected rows.
* @return int The number of affected rows, if the result is bigger than PHP_INT_MAX, PHP_INT_MAX is returned
*
* @throws \Doctrine\DBAL\Exception
*/

View file

@ -187,7 +187,7 @@ class QueryBuilder implements IQueryBuilder {
/**
* Executes this query using the bound parameters and their types.
*
* Uses {@see Connection::executeQuery} for select statements and {@see Connection::executeUpdate}
* Uses {@see Connection::executeQuery} for select statements and {@see Connection::executeStatement}
* for insert, update and delete statements.
*
* @return IResult|int
@ -272,12 +272,10 @@ class QueryBuilder implements IQueryBuilder {
if ($this->getType() !== self::SELECT) {
$result = $this->queryBuilder->executeStatement();
} else {
$result = $this->queryBuilder->executeQuery();
}
if (is_int($result)) {
return $result;
return (int) $result;
}
$result = $this->queryBuilder->executeQuery();
return new ResultAdapter($result);
}

View file

@ -56,6 +56,6 @@ class ResultAdapter implements IResult {
}
public function rowCount(): int {
return $this->inner->rowCount();
return (int) $this->inner->rowCount();
}
}

View file

@ -69,9 +69,10 @@ interface IResult {
public function fetchOne();
/**
* @return int
* @return int If the result is bigger than PHP_INT_MAX, PHP_INT_MAX is returned
*
* @since 21.0.0
* @since 30.0.0 If the result is bigger than PHP_INT_MAX, PHP_INT_MAX is returned
*/
public function rowCount(): int;
}