Skip to content

Imperfect QueryBuilderType detection returned by other method call #499

Closed
@janedbal

Description

@janedbal

See current behaviour:

class Foo {

    public function notWorking()
    {
        $queryBuilder = $this->createQueryBuilder();
        $queryBuilder->andWhere('1 = 1');

        $queryBuilder->getQuery()->getResult(); // mixed[]
    }

    public function working()
    {
        $queryBuilder = $this->createQueryBuilder()
              ->andWhere('1 = 1');

        $queryBuilder->getQuery()->getResult(); // list<Entity>
    }
}

This is because QueryBuilderMethodDynamicReturnTypeExtension detects only calls over QueryBuilder (second case) and optionally dives into the initial "other method" call to detect what happened there.

This could be fixed if I added some DynamicMethodReturnTypeExtension that is hooked to object and decided based on its return type (QueryBuilder) if OtherMethodQueryBuilderParser can be used to infer the enhanced QueryBuilderType. But no such thing is possible (hooking DynamicMethodReturnTypeExtension to any class).

Would you accept such PRs to accomplish this?

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