Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid type for SQLite3Result::columnName #11008

Open
stof opened this issue Jun 7, 2024 · 2 comments
Open

Invalid type for SQLite3Result::columnName #11008

stof opened this issue Jun 7, 2024 · 2 comments

Comments

@stof
Copy link
Contributor

stof commented Jun 7, 2024

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

Copy link

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

@derrabus
Copy link

This snippet shows how this method can return false: https://3v4l.org/0mQHi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants