fetchSingle returning mixed, how to approach?
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 20/100
Research direction
Start by locating the fetchSingle entry point and the extension code that describes its return type. Compare the declared mixed result with the documented scalar and null behavior, then define the expected typing for different queries and add regression coverage showing that valid calls no longer require the reported workaround.
Written by the indexing model from the issue text.
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();
}
- Dominant language
- PHP
- Stars
- 16
- Forks
- 11
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from phpstan/phpstan-dibi
-
Dependency Dashboard Open
Difficulty 4/5 3-5 days Newbie friendliness 20/100
phpstan/phpstan-dibi#22 ·
All issues in phpstan/phpstan-dibi
Similar issues
-
priority: p3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
googleapis/librarian#7636 ·
-
0. Needs triage bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nextcloud/fulltextsearch#1011 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
phpstan/phpstan-doctrine#794 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Automattic/static-site-importer#1767 ·