Skip to content

Commit 95c9daf

Browse files
Gennadi Janzengennadigennadigennadi
authored andcommitted
changed return type for getUidObject to FQCN and renamed it to getUidClass
* return null explicitly
1 parent eefc578 commit 95c9daf

File tree

6 files changed

+16
-18
lines changed

6 files changed

+16
-18
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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Bridge\Doctrine\Types;
1313

14-
use Symfony\Component\Uid\AbstractUid;
1514
use Symfony\Component\Uid\Ulid;
1615

1716
final class UlidBinaryType extends AbstractBinaryUidType
@@ -21,8 +20,8 @@ public function getName(): string
2120
return 'ulid_binary';
2221
}
2322

24-
protected function getUidObject(): AbstractUid
23+
protected function getUidClass(): string
2524
{
26-
return new Ulid();
25+
return Ulid::class;
2726
}
2827
}

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

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

1212
namespace Symfony\Bridge\Doctrine\Types;
1313

14-
use Symfony\Component\Uid\AbstractUid;
1514
use Symfony\Component\Uid\Ulid;
1615

1716
final class UlidType extends AbstractUidType
@@ -21,8 +20,8 @@ public function getName(): string
2120
return 'ulid';
2221
}
2322

24-
protected function getUidObject(): AbstractUid
23+
protected function getUidClass(): string
2524
{
26-
return new Ulid();
25+
return Ulid::class;
2726
}
2827
}

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

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

1212
namespace Symfony\Bridge\Doctrine\Types;
1313

14-
use Symfony\Component\Uid\AbstractUid;
1514
use Symfony\Component\Uid\Uuid;
1615

1716
final class UuidBinaryType extends AbstractBinaryUidType
@@ -21,8 +20,8 @@ public function getName(): string
2120
return 'uuid_binary';
2221
}
2322

24-
protected function getUidObject(): AbstractUid
23+
protected function getUidClass(): string
2524
{
26-
return Uuid::v4();
25+
return Uuid::class;
2726
}
2827
}

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

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

1212
namespace Symfony\Bridge\Doctrine\Types;
1313

14-
use Symfony\Component\Uid\AbstractUid;
1514
use Symfony\Component\Uid\Uuid;
1615

1716
final class UuidType extends AbstractUidType
@@ -21,8 +20,8 @@ public function getName(): string
2120
return 'uuid';
2221
}
2322

24-
protected function getUidObject(): AbstractUid
23+
protected function getUidClass(): string
2524
{
26-
return Uuid::v4();
25+
return Uuid::class;
2726
}
2827
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy