Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,10 @@ public function getRepository(string $klass): Repository
* @psalm-return ?TEntity
*
* @param string $klass Entity class name
* @param int $id ID of the entity
* @param ?int $id ID of the entity
* @return ?Entity
*/
public function findOne(string $klass, int $id): ?Entity
public function findOne(string $klass, ?int $id): ?Entity
{
return $this->getRepository($klass)->findOne($id);
}
Expand Down
8 changes: 6 additions & 2 deletions src/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,15 @@ public function __construct(Database $db, string $klass)
/**
* Find a single entity by its ID
*
* @param int $id ID of the entity
* @param ?int $id ID of the entity
* @psalm-return ?TEntity
*/
public function findOne(int $id): ?Entity
public function findOne(?int $id): ?Entity
{
if ($id === null) {
return null;
}

return $this->findOneBy([
'id' => $id,
]);
Expand Down
Loading