@@ -13,6 +13,7 @@ abstract class Entities
1313 private string $ idColumn ;
1414 /** @var array<string, Prop> */
1515 private array $ fullPropMap ;
16+ /** @var array<string, mixed> */
1617 private array $ map ;
1718
1819 public function __construct (PeachySql $ db )
@@ -34,7 +35,7 @@ public function __construct(PeachySql $db)
3435 }
3536
3637 $ idParts = explode ('. ' , $ propMap [$ this ->idField ]->col );
37- $ this ->idColumn = array_pop ($ idParts );
38+ $ this ->idColumn = $ idParts [ array_key_last ($ idParts )] ;
3839 $ this ->fullPropMap = $ propMap ;
3940 $ this ->map = $ this ->getMap ();
4041 }
@@ -152,6 +153,9 @@ public function deleteByIds(array $ids): int
152153 return $ this ->db ->deleteFrom ($ this ->getTableName (), [$ this ->idColumn => $ ids ]);
153154 }
154155
156+ /**
157+ * @param mixed[] $data
158+ */
155159 public function updateById (int |string $ id , array $ data ): int
156160 {
157161 $ row = Helpers::allPropertiesToColumns ($ this ->map , $ this ->processValues ($ data , [$ id ]));
@@ -163,6 +167,7 @@ public function updateById(int|string $id, array $data): int
163167 /**
164168 * Update one or more rows via a JSON Merge Patch (https://tools.ietf.org/html/rfc7396)
165169 * @param list<string|int> $ids
170+ * @param mixed[] $mergePatch
166171 */
167172 public function patchByIds (array $ ids , array $ mergePatch ): int
168173 {
@@ -212,11 +217,13 @@ public function addEntities(array $entities): array
212217 foreach ($ existingIds as $ offset => $ id ) {
213218 array_splice ($ ids , $ offset , 0 , [$ id ]);
214219 }
220+ /** @phpstan-ignore return.type */
215221 return $ ids ;
216222 }
217223
218224 /**
219225 * @param string[] $fields
226+ * @return mixed[]
220227 */
221228 public function getEntityById (int |string $ id , array $ fields = []): array
222229 {
@@ -230,7 +237,9 @@ public function getEntityById(int|string $id, array $fields = []): array
230237 }
231238
232239 /**
240+ * @param list<int|string> $ids
233241 * @param string[] $fields
242+ * @param mixed[] $sort
234243 * @return list<array>
235244 */
236245 public function getEntitiesByIds (array $ ids , array $ fields = [], array $ sort = []): array
@@ -243,7 +252,9 @@ public function getEntitiesByIds(array $ids, array $fields = [], array $sort = [
243252 }
244253
245254 /**
255+ * @param mixed[] $filter
246256 * @param string[] $fields
257+ * @param mixed[] $sort
247258 * @return list<array>
248259 */
249260 public function getEntities (array $ filter = [], array $ fields = [], array $ sort = [], int $ offset = 0 , int $ limit = 0 ): array
@@ -258,8 +269,8 @@ public function getEntities(array $filter = [], array $fields = [], array $sort
258269 $ fieldProps = Helpers::getFieldPropMap ($ fields , $ this ->fullPropMap );
259270 $ queryOptions = new QueryOptions ($ processedFilter , $ filter , $ sort , $ fieldProps );
260271
261- /** @psalm-suppress MixedArgumentTypeCoercion */
262272 $ select = $ this ->db ->select ($ this ->getBaseSelect ($ queryOptions ))
273+ /** @phpstan-ignore argument.type */
263274 ->where (self ::propertiesToColumns ($ selectMap , $ processedFilter ))
264275 ->orderBy (self ::propertiesToColumns ($ selectMap , $ sort , complexValues: false ));
265276
@@ -281,8 +292,8 @@ public function countEntities(array $filter = []): int
281292 $ prop = new Prop ('count ' , 'COUNT(*) ' , false , true , 'count ' );
282293 $ queryOptions = new QueryOptions ($ processedFilter , $ filter , [], [$ prop ]);
283294
284- /** @psalm-suppress MixedArgumentTypeCoercion */
285295 $ select = $ this ->db ->select ($ this ->getBaseSelect ($ queryOptions ))
296+ /** @phpstan-ignore argument.type */
286297 ->where (self ::propertiesToColumns ($ selectMap , $ processedFilter ));
287298
288299 /** @var array{count: int} $row */
@@ -293,6 +304,8 @@ public function countEntities(array $filter = []): int
293304
294305 /**
295306 * Converts nested properties to an array of columns and values using a map.
307+ * @param array<string, mixed> $map
308+ * @param mixed[] $properties
296309 * @return array<string, mixed>
297310 */
298311 public static function propertiesToColumns (
0 commit comments