Skip to content

Allow SortDirection enum in ObjectRepository::findBy() - #525

Merged
GromNaN merged 1 commit into
doctrine:5.0.xfrom
GromNaN:sortdirection-findby-5.0.x
Sep 11, 2026
Merged

Allow SortDirection enum in ObjectRepository::findBy()#525
GromNaN merged 1 commit into
doctrine:5.0.xfrom
GromNaN:sortdirection-findby-5.0.x

Conversation

@GromNaN

@GromNaN GromNaN commented Sep 11, 2026

Copy link
Copy Markdown
Member

Closes #523.

ObjectRepository::findBy() $orderBy now accepts the PHP 8.6 SortDirection enum in addition to the 'asc', 'desc', 'ASC' and 'DESC' strings. The native signature is unchanged and strings remain accepted.

This is a breaking change for implementers of ObjectRepository, who cannot declare a more restrictive type for $orderBy, so it targets 5.0 only. The companion change on 4.3.x (#524) was closed for that reason.

symfony/polyfill-php86 is added to require-dev so PHPStan can resolve SortDirection on PHP 8.4-8.5 without a production dependency. The contract is validated by the static-analysis CI.

@GromNaN
GromNaN force-pushed the sortdirection-findby-5.0.x branch from e491a08 to 781d59b Compare September 11, 2026 13:42
@GromNaN GromNaN changed the title Require SortDirection enum in ObjectRepository::findBy() Allow SortDirection enum in ObjectRepository::findBy() Sep 11, 2026
@GromNaN GromNaN added this to the 5.0.0 milestone Sep 11, 2026
@GromNaN
GromNaN force-pushed the sortdirection-findby-5.0.x branch from 781d59b to 0c41836 Compare September 11, 2026 14:12
Widen the PHPDoc contract of findBy() to accept the PHP 8.6 SortDirection
enum in addition to the 'asc', 'desc', 'ASC' and 'DESC' string literals. The
native signature is unchanged and strings remain accepted.

This is a breaking change for implementers of ObjectRepository, who cannot
declare a more restrictive type for $orderBy, so the change is done in 5.0
only.

Add symfony/polyfill-php86 to require-dev so PHPStan can resolve the
SortDirection symbol on PHP 8.4-8.5 without a production dependency.

Refs doctrine#523
@GromNaN
GromNaN force-pushed the sortdirection-findby-5.0.x branch from 0c41836 to 3371eef Compare September 11, 2026 14:12
@GromNaN
GromNaN marked this pull request as ready for review September 11, 2026 14:13
@GromNaN
GromNaN requested review from greg0ire and stof September 11, 2026 14:13
@GromNaN
GromNaN merged commit 5b1f92a into doctrine:5.0.x Sep 11, 2026
8 checks passed
@GromNaN
GromNaN deleted the sortdirection-findby-5.0.x branch September 11, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants