Skip to content

ObjectRepository::findBy orderBy should accept SortDirection #523

Closed

Description

@dmitryuk

Feature Request

What

\Doctrine\Persistence\ObjectRepository::findBy
php doc for $orderBy argument should accept array<\SortDirection> enum

Why

Since php 8.6 (and symfony/polyfill-php86) provide \SortDirection enum

How

Fix phpdoc for \Doctrine\Persistence\ObjectRepository::findBy

Relates doctrine/orm#11313

Activity

  1. greg0ire commented on Sep 10, 2026

    @greg0ire
    Member

    On v4, it should accept it, and on v5, it must accept it, and no longer needs to accept strings. Requiring that every implementation suddenly accept it would be a breaking change. Not sure what to do on 4.x. @derrabus @SenseException @stof @GromNaN thoughts? Maybe an @method annotation would help on 4.x? Also, requiring a polyfill just for a phpdoc comment feels weird.

  2. GromNaN commented on Sep 11, 2026

    @GromNaN
    Member

    Thanks @dmitryuk for reporting this issue. The new enum will be added in 5.0.0 by #525.

  3. dmitryuk commented on Sep 11, 2026

    @dmitryuk
    Author

    What about v4?

  4. GromNaN commented on Sep 11, 2026

    @GromNaN
    Member

    See #524 (comment)

    Widening parameter type is a BC break for implementers (as implementers are not allowed to use a more restrictive type based on the Liskov Substitution Principle).

  5. GromNaN commented on Sep 13, 2026

    @GromNaN
    Member

    Two PRs were opened to allow SortDirection values wherever sort directions are accepted:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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