Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Codeception/Module/Doctrine.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
* ```php
* $I->grabEntitiesFromRepository('User', [
* 'status' => 'active',
* Criteria::create()->orderBy(['name' => 'asc']),
* Criteria::create()->orderBy(['name' => SortDirection::Ascending]), // or `['name' => asc]`
* ]);
Comment on lines 146 to 149

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your suggestion would only work with doctrine/collections version 3.1 or higher.

Should this be reflected in the docs?

Suggested change
* $I->grabEntitiesFromRepository('User', [
* 'status' => 'active',
* Criteria::create()->orderBy(['name' => 'asc']),
* Criteria::create()->orderBy(['name' => SortDirection::Ascending]),
* ]);
* // doctrine/collections < 3.0
* $I->grabEntitiesFromRepository('User', [
* 'status' => 'active',
* Criteria::create()->orderBy(['name' => 'asc']),
* ]);
*
* // doctrine/collections 3.0
* $I->grabEntitiesFromRepository('User', [
* 'status' => 'active',
* Criteria::create()->orderBy(['name' => \Doctrine\Common\Collections\Order::Ascending]),
* ]);
*
* // doctrine/collections > 3.0
* $I->grabEntitiesFromRepository('User', [
* 'status' => 'active',
* Criteria::create()->orderBy(['name' => \SortDirection::Ascending]),
* ]);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Order::Ascending was never really promoted, so I'd rather not mention that at all. And \SortDirection::Ascending only works in PHP 8.6 (which isn't released yet), otherwise you'll need Symfony's polyfill.
=> So this is all a little confusing - and from my experience I'd guess that whatever we write now will stay there for the next 10 years... ;-)
But you're right that removing 'asc' completely probably wasn't the best idea. So I added it as "comment" now.
My main goal was to promote PHP's new cool SortDirection enum. I think that people who can't use that yet, will easily figure out that asc is meant for them :-)

* ```
*
Expand Down
Loading