DDC-3484: [GH-1244] Change $this return type to static in AbstractQuery #4292

Closed
opened 2026-01-22 14:38:59 +01:00 by admin · 3 comments
Owner

Originally created by @doctrinebot on GitHub (Jan 11, 2015).

Originally assigned to: @Ocramius on GitHub.

Jira issue originally created by user @doctrinebot:

This issue is created automatically through a Github pull request on behalf of BenMorel:

Url: https://github.com/doctrine/doctrine2/pull/1244

Message:

This allows IDEs and static code analysis tools to properly understand the return type when chaining methods, for example when using the QueryBuilder:

    $query = $this->em->createQueryBuilder()
        ->select('u')
        ->from(User::class, 'u')
        ->where('u.email = :email')
        ->getQuery()
        ->setParameter('email', $email)
        ->setMaxResults(10);

In this example, my IDE (PHPStorm) reports:

Method 'setMaxResults' not found in class \Doctrine\ORM\AbstractQuery

With a static return type, the IDE now understands the chaining and knows that $query is a Query, not just an AbstractQuery.

Originally created by @doctrinebot on GitHub (Jan 11, 2015). Originally assigned to: @Ocramius on GitHub. Jira issue originally created by user @doctrinebot: This issue is created automatically through a Github pull request on behalf of BenMorel: Url: https://github.com/doctrine/doctrine2/pull/1244 Message: This allows IDEs and static code analysis tools to properly understand the return type when chaining methods, for example when using the QueryBuilder: ``` $query = $this->em->createQueryBuilder() ->select('u') ->from(User::class, 'u') ->where('u.email = :email') ->getQuery() ->setParameter('email', $email) ->setMaxResults(10); ``` In this example, my IDE (PHPStorm) reports: > Method 'setMaxResults' not found in class \Doctrine\ORM\AbstractQuery With a `static` return type, the IDE now understands the chaining and knows that `$query` is a `Query`, not just an `AbstractQuery`.
admin closed this issue 2026-01-22 14:39:00 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jan 11, 2015):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-1244] was assigned:
https://github.com/doctrine/doctrine2/pull/1244

@doctrinebot commented on GitHub (Jan 11, 2015): Comment created by @doctrinebot: A related Github Pull-Request [GH-1244] was assigned: https://github.com/doctrine/doctrine2/pull/1244
Author
Owner

@doctrinebot commented on GitHub (Jan 11, 2015):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-1244] was merged:
https://github.com/doctrine/doctrine2/pull/1244

@doctrinebot commented on GitHub (Jan 11, 2015): Comment created by @doctrinebot: A related Github Pull-Request [GH-1244] was merged: https://github.com/doctrine/doctrine2/pull/1244
Author
Owner

@doctrinebot commented on GitHub (Jan 11, 2015):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Jan 11, 2015): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4292