Open
Description
How to properly solve those?
I know it will allways be ?int, but since fetchSingle is marked as returning mixed I can't solve this. I wouldn't want to just skip those checks....
public function getIdByKey(string $key): ?int
{
return $this->db->select('id')->from($this->table)->where('%n = %s', 'key', $key)->fetchSingle();
}
ofcours, here is integer in some other query will be something else...
only thing I think off as correct would maybe be:
public function getIdByKey(string $key): ?int
{
/** @var int|null $id */
$id = $this->db->select('id')->from($this->table)->where('%n = %s', 'key', $key)->fetchSingle();
}
Metadata
Metadata
Assignees
Labels
No labels