-
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.
- Loading branch information
Showing
3 changed files
with
34 additions
and
50 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
32 changes: 32 additions & 0 deletions
32
tests/Doctrine/Tests/ORM/Mapping/TypedFieldMapper/CustomIntAsStringTypedFieldMapper.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,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Tests\ORM\Mapping\TypedFieldMapper; | ||
|
||
use Doctrine\DBAL\Types\Types; | ||
use Doctrine\ORM\Mapping\TypedFieldMapper; | ||
use ReflectionNamedType; | ||
use ReflectionProperty; | ||
|
||
final class CustomIntAsStringTypedFieldMapper implements TypedFieldMapper | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function validateAndComplete(array $mapping, ReflectionProperty $field): array | ||
{ | ||
$type = $field->getType(); | ||
|
||
if ( | ||
! isset($mapping['type']) | ||
&& ($type instanceof ReflectionNamedType) | ||
) { | ||
if ($type->getName() === 'int') { | ||
$mapping['type'] = Types::STRING; | ||
} | ||
} | ||
|
||
return $mapping; | ||
} | ||
} |
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