Skip to content

Commit

Permalink
add symfony uuid type descriptor
Browse files Browse the repository at this point in the history
  • Loading branch information
alcohol committed Jan 21, 2025
1 parent bdb6a83 commit ea7e7fb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
"phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^9.6.20",
"ramsey/uuid": "^4.2",
"symfony/cache": "^5.4"
"symfony/cache": "^5.4",
"symfony/doctrine-bridge": "^5.4",
"symfony/uid": "^5.4"
},
"config": {
"sort-packages": true,
Expand Down
33 changes: 33 additions & 0 deletions src/Type/Doctrine/Descriptors/Symfony/UuidTypeDescriptor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php declare(strict_types=1);

namespace PHPStan\Type\Doctrine\Descriptors\Symfony;

use PHPStan\Type\Doctrine\Descriptors\DoctrineTypeDescriptor;
use PHPStan\Type\ObjectType;
use PHPStan\Type\StringType;
use PHPStan\Type\Type;
use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Component\Uid\Uuid;

class UuidTypeDescriptor implements DoctrineTypeDescriptor
{
public function getType(): string
{
return UuidType::class;
}

public function getWritableToPropertyType(): Type
{
return new ObjectType(Uuid::class);
}

public function getWritableToDatabaseType(): Type
{
return new ObjectType(Uuid::class);
}

public function getDatabaseInternalType(): Type
{
return new StringType();
}
}

0 comments on commit ea7e7fb

Please sign in to comment.