Skip to content

PDO::lastInsertId may really return false #5788

@greg0ire

Description

@greg0ire

Bug report

PDO::lastInsertId may return false, as seen in #4243

You should inspect (or have someone do it) php-src to see in which case can PDO::lastInsertId() return FALSE. Then we can assess whether we should add |false to the return type.

Yesterday, @morozov found a case in https://github.com/microsoft/msphpsql/pull/1282/files#diff-d2bd6eeee218880848855ddb059d2198c44ca96422951309b4298c3ec33de388R1517

The conversation about this is at doctrine/dbal#4885 (comment)

Code snippet that reproduces the problem

https://phpstan.org/r/1d6e6c2e-9c38-483d-9e03-e21f4f7ce550 (strict rules are required)

Expected output

No issues.

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

While trying to reproduce the issue on a brand new test repo, it told me I was running it at level=0 with a nice tip. That was nice UX.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions