psalm
psalm copied to clipboard
Invalid type for SQLite3Result::columnName
https://psalm.dev/r/634c35d072
Psalm complains when comparing the return value to false. But the method can return false: https://www.php.net/manual/en/sqlite3result.columnname.php
I found these snippets:
https://psalm.dev/r/634c35d072
<?php
function getColumnName(SQLite3Result $result, int $index): string {
$name = $result->columnName($index);
if ($name === false) {
throw new \OutOfBoundsException("Invalid index $index.");
}
return $name;
}
Psalm output (using commit 16b24bd):
ERROR: TypeDoesNotContainType - 6:9 - string does not contain false
This snippet shows how this method can return false: https://3v4l.org/0mQHi