Skip to content

Commit b3e8f1a

Browse files
committed
Added comment support for Doctrine's custom typess
1 parent 7c55dc4 commit b3e8f1a

4 files changed

Lines changed: 25 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ This changelog references the relevant changes done between versions.
55
To get the diff for a specific change, go to https://github.com/LIN3S/SharedKernel/commit/XXX where XXX is the change hash
66
To get the diff between two versions, go to https://github.com/LIN3S/SharedKernel/compare/v0.7.0...v0.8.0
77

8+
* 0.9.2
9+
* Added comment support for Doctrine's custom types.
810
* 0.9.1
911
* Fixed typo in the Doctrine's mappings in the standalone way.
1012
* 0.9.0

src/LIN3S/SharedKernel/Infrastructure/Persistence/Doctrine/DBAL/Domain/Model/Iban/Types/IbanType.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
class IbanType extends TextType
2424
{
25-
public function convertToDatabaseValue($value, AbstractPlatform $platform)
25+
public function convertToDatabaseValue($value, AbstractPlatform $platform) : ?string
2626
{
2727
if ($value instanceof Iban) {
2828
return $value->iban();
@@ -31,7 +31,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform)
3131
return $value;
3232
}
3333

34-
public function convertToPHPValue($value, AbstractPlatform $platform)
34+
public function convertToPHPValue($value, AbstractPlatform $platform) : ?Iban
3535
{
3636
if (null === $value) {
3737
return;
@@ -40,6 +40,11 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
4040
return Iban::from($value);
4141
}
4242

43+
public function requiresSQLCommentHint(AbstractPlatform $platform) : bool
44+
{
45+
return true;
46+
}
47+
4348
public function getName()
4449
{
4550
return 'iban';

src/LIN3S/SharedKernel/Infrastructure/Persistence/Doctrine/DBAL/Domain/Model/Phone/Types/PhoneType.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
class PhoneType extends TextType
2424
{
25-
public function convertToDatabaseValue($value, AbstractPlatform $platform)
25+
public function convertToDatabaseValue($value, AbstractPlatform $platform) : ?string
2626
{
2727
if ($value instanceof Phone) {
2828
return $value->phone();
@@ -31,7 +31,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform)
3131
return $value;
3232
}
3333

34-
public function convertToPHPValue($value, AbstractPlatform $platform)
34+
public function convertToPHPValue($value, AbstractPlatform $platform) : ?Phone
3535
{
3636
if (null === $value) {
3737
return;
@@ -40,7 +40,12 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
4040
return Phone::fromInternatinal($value);
4141
}
4242

43-
public function getName()
43+
public function requiresSQLCommentHint(AbstractPlatform $platform) : bool
44+
{
45+
return true;
46+
}
47+
48+
public function getName() : string
4449
{
4550
return 'phone';
4651
}

src/LIN3S/SharedKernel/Infrastructure/Persistence/Doctrine/DBAL/Domain/Model/TaxIdNumber/Types/TaxIdNumberType.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
class TaxIdNumberType extends TextType
2424
{
25-
public function convertToDatabaseValue($value, AbstractPlatform $platform)
25+
public function convertToDatabaseValue($value, AbstractPlatform $platform) : ?string
2626
{
2727
if ($value instanceof TaxIdNumber) {
2828
return $value->number();
@@ -31,7 +31,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform)
3131
return $value;
3232
}
3333

34-
public function convertToPHPValue($value, AbstractPlatform $platform)
34+
public function convertToPHPValue($value, AbstractPlatform $platform) : ?TaxIdNumber
3535
{
3636
if (null === $value) {
3737
return;
@@ -40,7 +40,12 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
4040
return TaxIdNumber::fromSpain($value);
4141
}
4242

43-
public function getName()
43+
public function requiresSQLCommentHint(AbstractPlatform $platform) : bool
44+
{
45+
return true;
46+
}
47+
48+
public function getName() : string
4449
{
4550
return 'tax_id_number';
4651
}

0 commit comments

Comments
 (0)