Skip to content

Commit 7a7e22f

Browse files
Simplify
1 parent fe96e38 commit 7a7e22f

File tree

3 files changed

+21
-63
lines changed

3 files changed

+21
-63
lines changed

src/Type/Doctrine/Descriptors/Ramsey/UuidTypeDescriptor.php

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,30 @@
22

33
namespace PHPStan\Type\Doctrine\Descriptors\Ramsey;
44

5-
use PHPStan\Rules\Doctrine\ORM\FakeTestingRamseyUuidType;
6-
use PHPStan\ShouldNotHappenException;
75
use PHPStan\Type\Doctrine\Descriptors\DoctrineTypeDescriptor;
86
use PHPStan\Type\ObjectType;
97
use PHPStan\Type\StringType;
108
use PHPStan\Type\Type;
119
use PHPStan\Type\TypeCombinator;
1210
use Ramsey\Uuid\UuidInterface;
13-
use function in_array;
14-
use function sprintf;
1511

1612
class UuidTypeDescriptor implements DoctrineTypeDescriptor
1713
{
18-
19-
private const SUPPORTED_UUID_TYPES = [
20-
'Ramsey\Uuid\Doctrine\UuidType',
21-
'Ramsey\Uuid\Doctrine\UuidBinaryType',
22-
'Ramsey\Uuid\Doctrine\UuidBinaryOrderedTimeType',
23-
FakeTestingRamseyUuidType::class,
24-
];
25-
14+
/**
15+
* @var class-string<\Doctrine\DBAL\Types\Type>
16+
*/
2617
private string $uuidTypeName;
2718

28-
public function __construct(
29-
string $uuidTypeName
30-
)
19+
/**
20+
* @param class-string<\Doctrine\DBAL\Types\Type> $uuidTypeName
21+
*/
22+
public function __construct(string $uuidTypeName)
3123
{
32-
if (!in_array($uuidTypeName, self::SUPPORTED_UUID_TYPES, true)) {
33-
throw new ShouldNotHappenException(sprintf(
34-
'Unexpected UUID column type "%s" provided',
35-
$uuidTypeName,
36-
));
37-
}
38-
3924
$this->uuidTypeName = $uuidTypeName;
4025
}
4126

4227
public function getType(): string
4328
{
44-
/** @var class-string<\Doctrine\DBAL\Types\Type> */
4529
return $this->uuidTypeName;
4630
}
4731

src/Type/Doctrine/Descriptors/Symfony/UlidTypeDescriptor.php

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,31 @@
22

33
namespace PHPStan\Type\Doctrine\Descriptors\Symfony;
44

5-
use PHPStan\Rules\Doctrine\ORM\FakeTestingSymfonyUlidType;
6-
use PHPStan\ShouldNotHappenException;
75
use PHPStan\Type\Doctrine\Descriptors\DoctrineTypeDescriptor;
86
use PHPStan\Type\ObjectType;
97
use PHPStan\Type\StringType;
108
use PHPStan\Type\Type;
119
use PHPStan\Type\TypeCombinator;
1210
use Symfony\Component\Uid\Ulid;
13-
use function in_array;
14-
use function sprintf;
1511

1612
class UlidTypeDescriptor implements DoctrineTypeDescriptor
1713
{
1814

19-
private const SUPPORTED_UUID_TYPES = [
20-
'Symfony\Bridge\Doctrine\Types\UlidType',
21-
FakeTestingSymfonyUlidType::class,
22-
];
23-
15+
/**
16+
* @var class-string<\Doctrine\DBAL\Types\Type>
17+
*/
2418
private string $uuidTypeName;
2519

26-
public function __construct(
27-
string $uuidTypeName
28-
)
20+
/**
21+
* @param class-string<\Doctrine\DBAL\Types\Type> $uuidTypeName
22+
*/
23+
public function __construct(string $uuidTypeName)
2924
{
30-
if (!in_array($uuidTypeName, self::SUPPORTED_UUID_TYPES, true)) {
31-
throw new ShouldNotHappenException(sprintf(
32-
'Unexpected UUID column type "%s" provided',
33-
$uuidTypeName,
34-
));
35-
}
36-
3725
$this->uuidTypeName = $uuidTypeName;
3826
}
3927

4028
public function getType(): string
4129
{
42-
/** @var class-string<\Doctrine\DBAL\Types\Type> */
4330
return $this->uuidTypeName;
4431
}
4532

src/Type/Doctrine/Descriptors/Symfony/UuidTypeDescriptor.php

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,31 @@
22

33
namespace PHPStan\Type\Doctrine\Descriptors\Symfony;
44

5-
use PHPStan\Rules\Doctrine\ORM\FakeTestingSymfonyUuidType;
6-
use PHPStan\ShouldNotHappenException;
75
use PHPStan\Type\Doctrine\Descriptors\DoctrineTypeDescriptor;
86
use PHPStan\Type\ObjectType;
97
use PHPStan\Type\StringType;
108
use PHPStan\Type\Type;
119
use PHPStan\Type\TypeCombinator;
1210
use Symfony\Component\Uid\Uuid;
13-
use function in_array;
14-
use function sprintf;
1511

1612
class UuidTypeDescriptor implements DoctrineTypeDescriptor
1713
{
1814

19-
private const SUPPORTED_UUID_TYPES = [
20-
'Symfony\Bridge\Doctrine\Types\UuidType',
21-
FakeTestingSymfonyUuidType::class,
22-
];
23-
15+
/**
16+
* @var class-string<\Doctrine\DBAL\Types\Type>
17+
*/
2418
private string $uuidTypeName;
2519

26-
public function __construct(
27-
string $uuidTypeName
28-
)
20+
/**
21+
* @param class-string<\Doctrine\DBAL\Types\Type> $uuidTypeName
22+
*/
23+
public function __construct(string $uuidTypeName)
2924
{
30-
if (!in_array($uuidTypeName, self::SUPPORTED_UUID_TYPES, true)) {
31-
throw new ShouldNotHappenException(sprintf(
32-
'Unexpected UUID column type "%s" provided',
33-
$uuidTypeName,
34-
));
35-
}
36-
3725
$this->uuidTypeName = $uuidTypeName;
3826
}
3927

4028
public function getType(): string
4129
{
42-
/** @var class-string<\Doctrine\DBAL\Types\Type> */
4330
return $this->uuidTypeName;
4431
}
4532

0 commit comments

Comments
 (0)