Skip to content

Commit 03dc434

Browse files
authored
Add more specific psalm type for QueryFunctionsInterface::count() result (#810)
1 parent e44b52f commit 03dc434

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
- Enh #801: Deprecate `SchemaInterface::isReadQuery()` and add `DbStringHelper::isReadQuery()` method (@Tigrov)
2525
- Enh #801: Remove unnecessary symbol `\\` from `rtrim()` function inside `DbStringHelper::baseName()` method (@Tigrov)
2626
- Bug #801: Fix bug with `Quoter::$tablePrefix` when change `AbstractConnection::$tablePrefix` property (@Tigrov)
27+
- Enh #810: Add more specific psalm type for `QueryFunctionsInterface::count()` result (@vjik)
2728

2829
## 1.2.0 November 12, 2023
2930

src/Query/Query.php

+1
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ public function count(string $sql = '*'): int|string
300300
return 0;
301301
}
302302

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

src/Query/QueryFunctionsInterface.php

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public function average(string $sql): int|float|null|string;
3939
* @return int|string Number of records. The result may be a string depending on the underlying database engine and
4040
* to support integer values higher than a 32bit PHP integer can handle.
4141
*
42+
* @psalm-return non-negative-int|string
43+
*
4244
* Note: Make sure you quote column names in the expression.
4345
*/
4446
public function count(string $sql = '*'): int|string;

0 commit comments

Comments
 (0)