Skip to content

Commit

Permalink
Add more specific psalm type for QueryFunctionsInterface::count() r…
Browse files Browse the repository at this point in the history
…esult (#810)
  • Loading branch information
vjik authored Feb 14, 2024
1 parent e44b52f commit 03dc434
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- Enh #801: Deprecate `SchemaInterface::isReadQuery()` and add `DbStringHelper::isReadQuery()` method (@Tigrov)
- Enh #801: Remove unnecessary symbol `\\` from `rtrim()` function inside `DbStringHelper::baseName()` method (@Tigrov)
- Bug #801: Fix bug with `Quoter::$tablePrefix` when change `AbstractConnection::$tablePrefix` property (@Tigrov)
- Enh #810: Add more specific psalm type for `QueryFunctionsInterface::count()` result (@vjik)

## 1.2.0 November 12, 2023

Expand Down
1 change: 1 addition & 0 deletions src/Query/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ public function count(string $sql = '*'): int|string
return 0;
}

/** @psalm-var non-negative-int|string */
return $count <= PHP_INT_MAX ? (int) $count : $count;
}

Expand Down
2 changes: 2 additions & 0 deletions src/Query/QueryFunctionsInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public function average(string $sql): int|float|null|string;
* @return int|string Number of records. The result may be a string depending on the underlying database engine and
* to support integer values higher than a 32bit PHP integer can handle.
*
* @psalm-return non-negative-int|string
*
* Note: Make sure you quote column names in the expression.
*/
public function count(string $sql = '*'): int|string;
Expand Down

0 comments on commit 03dc434

Please sign in to comment.