6
6
7
7
use Doctrine \DBAL \Platforms \AbstractPlatform ;
8
8
use Doctrine \DBAL \Types \StringType ;
9
+ use Doctrine \DBAL \Types \Type ;
10
+ use Doctrine \DBAL \Types \Types ;
9
11
use Webmozart \Assert \Assert ;
10
12
use Yokai \DoctrineValueObject \StringValueObject ;
11
13
12
- final class StringValueObjectType extends StringType
14
+ final class StringValueObjectType extends Type
13
15
{
14
16
use ValueObjectType;
15
17
18
+ public function getSQLDeclaration (array $ column , AbstractPlatform $ platform ): string
19
+ {
20
+ /** @var StringType $typeInherit */
21
+ $ typeInherit = $ this ->getType (Types::STRING );
22
+ return $ typeInherit ->getSQLDeclaration ($ column , $ platform );
23
+ }
24
+
16
25
/**
17
26
* @inheritdoc
18
27
*/
@@ -24,7 +33,7 @@ public static function getSupportedValueObjectType(): string
24
33
/**
25
34
* @inheritdoc
26
35
*/
27
- public function convertToDatabaseValue ($ value , AbstractPlatform $ platform ): ? string
36
+ public function convertToDatabaseValue ($ value , AbstractPlatform $ platform ): mixed
28
37
{
29
38
if ($ value === null ) {
30
39
return null ;
@@ -33,15 +42,20 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?str
33
42
Assert::isInstanceOf ($ value , $ this ->class );
34
43
/** @var StringValueObject $value */
35
44
36
- return parent ::convertToDatabaseValue ($ value ->toValue (), $ platform );
45
+ /** @var StringType $typeInherit */
46
+ $ typeInherit = $ this ->getType (Types::STRING );
47
+ return $ typeInherit ->convertToDatabaseValue ($ value ->toValue (), $ platform );
37
48
}
38
49
39
50
/**
40
51
* @inheritdoc
41
52
*/
42
53
public function convertToPHPValue ($ value , AbstractPlatform $ platform ): ?StringValueObject
43
54
{
44
- $ value = parent ::convertToPHPValue ($ value , $ platform );
55
+ /** @var StringType $typeInherit */
56
+ $ typeInherit = $ this ->getType (Types::STRING );
57
+ $ value = $ typeInherit ->convertToPHPValue ($ value , $ platform );
58
+
45
59
if ($ value === null ) {
46
60
return null ;
47
61
}
0 commit comments