Skip to content

Unable to detect real driver for proper query type inference in phpstan-doctrine #6440

Closed
@janedbal

Description

@janedbal

Support Question

Hi, I'm trying to improve query type inference support in phpstan-doctrine, see PR. Any type of DQL expression is dependent on used driver (and PHP version and config). I tried to make this work out of the box (by autodetection) and so far I used this for conditional logic:

$em->getConnection()->getDriver() instanceof Doctrine\DBAL\Driver\PgSQL\Driver // not working with middlewares

But now I realized that when middlewares are used, this will never match. And I found no reliable way in public api of doctrine/dbal to detect actually used driver. Did I miss some approach or do you think it would be handy even for other usecases to somehow expose really used driver?

I dont care about the instance itself, I could work even with some enum like those used in connection params or just its class-string.

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