Skip to content

Commit ea7e7fb

Browse files
committed
add symfony uuid type descriptor
1 parent bdb6a83 commit ea7e7fb

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@
3535
"phpstan/phpstan-strict-rules": "^2.0",
3636
"phpunit/phpunit": "^9.6.20",
3737
"ramsey/uuid": "^4.2",
38-
"symfony/cache": "^5.4"
38+
"symfony/cache": "^5.4",
39+
"symfony/doctrine-bridge": "^5.4",
40+
"symfony/uid": "^5.4"
3941
},
4042
"config": {
4143
"sort-packages": true,
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace PHPStan\Type\Doctrine\Descriptors\Symfony;
4+
5+
use PHPStan\Type\Doctrine\Descriptors\DoctrineTypeDescriptor;
6+
use PHPStan\Type\ObjectType;
7+
use PHPStan\Type\StringType;
8+
use PHPStan\Type\Type;
9+
use Symfony\Bridge\Doctrine\Types\UuidType;
10+
use Symfony\Component\Uid\Uuid;
11+
12+
class UuidTypeDescriptor implements DoctrineTypeDescriptor
13+
{
14+
public function getType(): string
15+
{
16+
return UuidType::class;
17+
}
18+
19+
public function getWritableToPropertyType(): Type
20+
{
21+
return new ObjectType(Uuid::class);
22+
}
23+
24+
public function getWritableToDatabaseType(): Type
25+
{
26+
return new ObjectType(Uuid::class);
27+
}
28+
29+
public function getDatabaseInternalType(): Type
30+
{
31+
return new StringType();
32+
}
33+
}

0 commit comments

Comments
 (0)