8000 changed return type for getUidObject to FQCN and renamed it to getUid… · symfony/symfony@457f451 · GitHub
[go: up one dir, main page]

Skip to content

Commit 457f451

Browse files
author
Gennadi Janzen
committed
changed return type for getUidObject to FQCN and renamed it to getUidClass
* return null explicitly
1 parent eefc578 commit 457f451

File tree

6 files changed

+17
-14
lines changed

6 files changed

+17
-14
lines changed

src/Symfony/Bridge/Doctrine/Types/AbstractBinaryUidType.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
abstract class AbstractBinaryUidType extends GuidType
2020
{
21-
abstract protected function getUidObject(): AbstractUid;
21+
abstract protected function getUidClass(): string;
2222

2323
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string
2424
{
@@ -44,7 +44,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform): ?Abstract
4444
}
4545

4646
try {
47-
$uuid = $this->getUidObject()::fromString($value);
47+
$uuid = $this->getUidClass()::fromString($value);
4848
} catch (\InvalidArgumentException $e) {
4949
throw ConversionException::conversionFailed($value, $this->getName());
5050
}
@@ -67,10 +67,12 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?str
6767

6868
try {
6969
if (\is_string($value) || method_exists($value, '__toString')) {
70-
return $this->getUidObject()::fromString((string) $value)->toBinary();
70+
return $this->getUidClass()::fromString((string) $value)->toBinary();
7171
}
7272
} catch (\InvalidArgumentException $e) {
7373
throw ConversionException::conversionFailed($value, $this->getName());
7474
}
75+
76+
return null;
7577
}
7678
}

src/Symfony/Bridge/Doctrine/Types/AbstractUidType.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
abstract class AbstractUidType extends GuidType
2020
{
21-
abstract protected function getUidObject(): AbstractUid;
21+
abstract protected function getUidClass(): string;
2222

2323
/**
2424
* @throws ConversionException
@@ -34,7 +34,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform): ?Abstract
3434
}
3535

3636
try {
37-
$uuid = $this->getUidObject()::fromString($value);
37+
$uuid = $this->getUidClass()::fromString($value);
3838
} catch (\InvalidArgumentException $e) {
3939
throw ConversionException::conversionFailed($value, $this->getName());
4040
}
@@ -57,7 +57,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?str
5757

5858
if (
5959
(\is_string($value) || method_exists($value, '__toString'))
60-
&& $this->getUidObject()::isValid((string) $value)
60+
&& $this->getUidClass()::isValid((string) $value)
6161
) {
6262
return (string) $value;
6363
}

src/Symfony/Bridge/Doctrine/Types/UlidBinaryType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public function getName(): string
2121
return 'ulid_binary';
2222
}
2323

24-
protected function getUidObject(): AbstractUid
24+
protected function getUidClass(): string
2525
{
26-
return new Ulid();
26+
return Ulid::class;
2727
}
2828
}

src/Symfony/Bridge/Doctrine/Types/UlidType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public function getName(): string
2121
return 'ulid';
2222
}
2323

24-
protected function getUidObject(): AbstractUid
24+
protected function getUidClass(): string
2525
{
26-
return new Ulid();
26+
return Ulid::class;
2727
}
2828
}

src/Symfony/Bridge/Doctrine/Types/UuidBinaryType.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Uid\AbstractUid;
1515
use Symfony\Component\Uid\Uuid;
16+
use Symfony\Component\Uid\UuidV4;
1617

1718
final class UuidBinaryType extends AbstractBinaryUidType
1819
{
@@ -21,8 +22,8 @@ public function getName(): string
2122
return 'uuid_binary';
2223
}
2324

24-
protected function getUidObject(): AbstractUid
25+
protected function getUidClass(): string
2526
{
26-
return Uuid::v4();
27+
return Uuid::class;
2728
}
2829
}

src/Symfony/Bridge/Doctrine/Types/UuidType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public function getName(): string
2121
return 'uuid';
2222
}
2323

24-
protected function getUidObject(): AbstractUid
24+
protected function getUidClass(): string
2525
{
26-
return Uuid::v4();
26+
return Uuid::class;
2727
}
2828
}

0 commit comments

Comments
 (0)
0