forked from rectorphp/rector-doctrine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor the OrderByKeyToClassConstRector to use the new enum only in…
… Criteria::orderBy method call. Relates to: - doctrine/collections#389; - doctrine/orm#11313 (comment)
- Loading branch information
1 parent
3ba7adb
commit 4c9ac77
Showing
9 changed files
with
140 additions
and
93 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
...rty/OrderByKeyToClassConstRector/Fixture/criteria_to_order_from_constant_criteria.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
use Doctrine\Common\Collections\Criteria; | ||
|
||
$criteria = new Criteria(); | ||
$criteria->orderBy(['asc' => Criteria::ASC, 'desc' => Criteria::DESC]); | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
use Doctrine\Common\Collections\Criteria; | ||
|
||
$criteria = new Criteria(); | ||
$criteria->orderBy(['asc' => \Doctrine\Common\Collections\Order::Ascending, 'desc' => \Doctrine\Common\Collections\Order::Descending]); | ||
|
||
?> |
17 changes: 17 additions & 0 deletions
17
...Property/OrderByKeyToClassConstRector/Fixture/criteria_to_order_from_string_lower.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
use Doctrine\Common\Collections\Criteria; | ||
|
||
$criteria = new Criteria(); | ||
$criteria->orderBy(['asc' => 'asc', 'desc' => 'desc']); | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
use Doctrine\Common\Collections\Criteria; | ||
|
||
$criteria = new Criteria(); | ||
$criteria->orderBy(['asc' => \Doctrine\Common\Collections\Order::Ascending, 'desc' => \Doctrine\Common\Collections\Order::Descending]); | ||
|
||
?> |
17 changes: 17 additions & 0 deletions
17
...Property/OrderByKeyToClassConstRector/Fixture/criteria_to_order_from_string_upper.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
use Doctrine\Common\Collections\Criteria; | ||
|
||
$criteria = new Criteria(); | ||
$criteria->orderBy(['asc' => 'ASC', 'desc' => 'DESC']); | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
use Doctrine\Common\Collections\Criteria; | ||
|
||
$criteria = new Criteria(); | ||
$criteria->orderBy(['asc' => \Doctrine\Common\Collections\Order::Ascending, 'desc' => \Doctrine\Common\Collections\Order::Descending]); | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 3 additions & 8 deletions
11
...ity/Rector/Property/OrderByKeyToClassConstRector/Fixture/skip_already_using_const.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,8 @@ | ||
<?php | ||
|
||
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\OrderByKeyToClassConstRector\Fixture; | ||
|
||
use Doctrine\Common\Collections\Criteria; | ||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
class SkipAlreadyUsingConst | ||
{ | ||
#[ORM\OrderBy(['createdAt' => Criteria::ASC])] | ||
protected \DateTimeInterface $messages; | ||
} | ||
$criteria = new Criteria(); | ||
$criteria->orderBy(['asc' => \Doctrine\Common\Collections\Order::Ascending, 'desc' => \Doctrine\Common\Collections\Order::Descending]); | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
tests/Set/DoctrineCOLLECTION22Set/Fixture/asc_desc_in_attributes_not_replaced.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
class DummyEntity { | ||
|
||
#[ORM\OneToMany(targetEntity: AnotherEntity::class, mappedBy: 'dummy')] | ||
#[ORM\OrderBy(["id" => \Doctrine\Common\Collections\Criteria::ASC])] | ||
public \Doctrine\Common\Collections\Collection $properties; | ||
|
||
#[ORM\OneToMany(targetEntity: YetAnotherEntity::class, mappedBy: 'dummy')] | ||
#[ORM\OrderBy(["id" => \Doctrine\Common\Collections\Criteria::DESC])] | ||
public \Doctrine\Common\Collections\Collection $otherProperties; | ||
} |