-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support native enum hydration when using
NEW
operator
Using the `NEW` operator with the query builder now properly converts scalar values to native enums inside data transfer objects.
- Loading branch information
Showing
5 changed files
with
142 additions
and
13 deletions.
There are no files selected for viewing
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
21 changes: 21 additions & 0 deletions
21
tests/Doctrine/Tests/Models/DataTransferObjects/DtoWithArrayOfEnums.php
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,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Tests\Models\DataTransferObjects; | ||
|
||
use Doctrine\Tests\Models\Enums\Unit; | ||
|
||
final class DtoWithArrayOfEnums | ||
{ | ||
/** @var Unit[] */ | ||
public $supportedUnits; | ||
|
||
/** | ||
* @param Unit[] $supportedUnits | ||
*/ | ||
public function __construct(array $supportedUnits) | ||
{ | ||
$this->supportedUnits = $supportedUnits; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
tests/Doctrine/Tests/Models/DataTransferObjects/DtoWithEnum.php
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,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Tests\Models\DataTransferObjects; | ||
|
||
use Doctrine\Tests\Models\Enums\Suit; | ||
|
||
final class DtoWithEnum | ||
{ | ||
/** @var Suit|null */ | ||
public $suit; | ||
|
||
public function __construct(?Suit $suit) | ||
{ | ||
$this->suit = $suit; | ||
} | ||
} |
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