Thanks to visit codestin.com
Credit goes to github.com

Skip to content

PDO::fetchAll(PDO::FETCH_COLUMN) returns a list #11889

@pereorga

Description

@pereorga

Bug report

PHPStan complains this function returns an array (not necessarily a list):

/**
 * @return list<string>
 */
function get_cv_files(): array
{
    $pdo = new PDO("");
    $stmt = $pdo->prepare('SELECT `file` FROM `commonvoice`');
    $stmt->execute();

    return $stmt->fetchAll(PDO::FETCH_COLUMN);
}

Code snippet that reproduces the problem

https://phpstan.org/r/860e662d-152e-4631-813f-dea50f9dbb6e

Expected output

fetchAll(PDO::FETCH_COLUMN) will always return a list.

Did PHPStan help you today? Did it make you happy in any way?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions