Skip to content

Commit 40f145e

Browse files
committed
Better psalm type hints
1 parent f9d81b7 commit 40f145e

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

psalm.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
</projectFiles>
1414

1515
<issueHandlers>
16-
<MissingConstructor errorLevel="info" />
16+
<MissingConstructor>
17+
<errorLevel type="suppress">
18+
<file name="src/DBPassToLowerLayerTrait.php" />
19+
</errorLevel>
20+
</MissingConstructor>
1721
</issueHandlers>
1822
</psalm>

src/Builder/SelectEntries.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ public function getOneEntry(): ?array
156156
'where' => $this->where,
157157
'order' => $this->orderBy,
158158
'group' => $this->groupBy,
159-
'limit' => 1,
160159
'offset' => $this->startAt,
161160
'lock' => $this->blocking,
162161
]);

src/DBInterface.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public function inTransaction(): bool;
3131
*
3232
* @param string|array $query SQL query as a string, with ? as variable placeholders if necessary
3333
* or an array for a structured SQL query where $vars is not used
34+
* @psalm-param string|array{fields?:array,field?:string,tables?:array,table?:string,where?:array,group?:array,order?:array,limit?:int,offset?:int,lock?:bool} $query
3435
* @param array $vars Query variables, replaces ? with these variables in order
3536
* @return DBSelectQueryInterface Query result to use with fetch, fetchAll, clear
3637
*
@@ -62,6 +63,7 @@ public function clear(DBSelectQueryInterface $selectQuery): void;
6263
*
6364
* @param string|array $query SQL query as a string, with ? as variable placeholders if necessary
6465
* or an array for a structured SQL query where $vars is not used
66+
* @psalm-param string|array{fields?:array,field?:string,tables?:array,table?:string,where?:array,group?:array,order?:array,lock?:bool} $query
6567
* @param array $vars Query variables, replaces ? with these variables in order
6668
* @return array|null Table row as an associative array, or null if no entry was found
6769
*
@@ -74,6 +76,7 @@ public function fetchOne($query, array $vars = []): ?array;
7476
*
7577
* @param string|array $query SQL query as a string, with ? as variable placeholders if necessary
7678
* or an array for a structured SQL query where $vars is not used
79+
* @psalm-param string|array{fields?:array,field?:string,tables?:array,table?:string,where?:array,group?:array,order?:array,limit?:int,offset?:int,lock?:bool,flattenFields?:bool} $query
7780
* @param array $vars Query variables, replaces ? with these variables in order
7881
* @return array List of table rows, each entry as an associate array for one row
7982
*
@@ -85,7 +88,7 @@ public function fetchAll($query, array $vars = []): array;
8588
* Insert a row into a table with the given names and values
8689
*
8790
* @param string $tableName Name of the table
88-
* @param array $row Name and value pairs to insert into the table
91+
* @param array<string, mixed> $row Name and value pairs to insert into the table
8992
* @param string $autoIncrementIndex Index of an automatically generated value that should be returned
9093
* @return string|null If $autoIncrementIndex is empty, return null, otherwise return the auto increment value
9194
*
@@ -104,7 +107,7 @@ public function insert(string $tableName, array $row = [], string $autoIncrement
104107
* Others/ANSI: MERGE (see https://en.wikipedia.org/wiki/Merge_(SQL))
105108
*
106109
* @param string $tableName Name of the table
107-
* @param array $row Row to insert, keys are column names, values are the data
110+
* @param array<string, mixed> $row Row to insert, keys are column names, values are the data
108111
* @param string[] $indexColumns Index columns which encompass the unique index
109112
* @param array|null $rowUpdates Fields to update if entry already exists, default is all non-index field entries
110113
*
@@ -116,6 +119,7 @@ public function insertOrUpdate(string $tableName, array $row = [], array $indexC
116119
* Execute an update query and return number of affected rows
117120
*
118121
* @param array $query Structured query parts
122+
* @psalm-param array{changes?:array,tables?:array,table?:string,where?:array,order?:array,limit?:int} $query
119123
* @return int Number of affected rows
120124
*
121125
* @throws DBException Common minimal exception thrown if anything goes wrong

tests/Builder/SelectEntriesTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ public function testOneEntry()
177177
'field1',
178178
'field6' => 'somefield',
179179
],
180-
'limit' => 1,
181180
'offset' => 13,
182181
'lock' => true,
183182
])

0 commit comments

Comments
 (0)