Skip to content

Commit de13f3e

Browse files
feat: set symfony/uid in dev dependencies
1 parent 63040a0 commit de13f3e

File tree

10 files changed

+40
-56
lines changed

10 files changed

+40
-56
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
"symfony/security-bundle": "^3.4 || ^4.4 || ^5.1 || ^6.0",
8282
"symfony/security-core": "^4.4 || ^5.1 || ^6.0",
8383
"symfony/twig-bundle": "^3.4 || ^4.4 || ^5.1 || ^6.0",
84+
"symfony/uid": "^5.1 || ^6.0",
8485
"symfony/validator": "^3.4 || ^4.4 || ^5.1 || ^6.0",
8586
"symfony/web-profiler-bundle": "^4.4 || ^5.1 || ^6.0",
8687
"symfony/yaml": "^3.4 || ^4.4 || ^5.1 || ^6.0",

tests/Fixtures/TestBundle/Doctrine/Generator/Uuid.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@ public function __toString(): string
2727
return $this->id;
2828
}
2929

30-
/**
31-
* @return mixed
32-
*/
33-
#[\ReturnTypeWillChange] // TODO: remove this and add the typehint in API Platform 3
34-
public function jsonSerialize()
30+
public function jsonSerialize(): mixed
3531
{
3632
return $this->id;
3733
}

tests/Fixtures/TestBundle/Entity/SymfonyUuidDummy.php

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,45 +15,41 @@
1515

1616
use ApiPlatform\Metadata\ApiResource;
1717
use Doctrine\ORM\Mapping as ORM;
18-
use Symfony\Bridge\Doctrine\Types\UuidType;
1918
use Symfony\Component\Uid\Uuid;
2019

21-
/* @TODO remove this check in 3.0 */
22-
if (\PHP_VERSION_ID >= 70200 && class_exists(Uuid::class) && class_exists(UuidType::class)) {
23-
/**
24-
* @author Vincent Chalamon <[email protected]>
25-
*/
26-
#[ApiResource]
27-
#[ORM\Entity]
28-
class SymfonyUuidDummy
20+
/**
21+
* @author Vincent Chalamon <[email protected]>
22+
*/
23+
#[ApiResource]
24+
#[ORM\Entity]
25+
class SymfonyUuidDummy
26+
{
27+
#[ORM\Id]
28+
#[ORM\Column(type: 'symfony_uuid', unique: true)]
29+
#[ORM\GeneratedValue(strategy: 'NONE')]
30+
private $id;
31+
#[ORM\Column(nullable: true)]
32+
private $number;
33+
34+
public function __construct(?Uuid $id = null)
35+
{
36+
$this->id = $id ?? Uuid::v4();
37+
}
38+
39+
public function getId(): Uuid
2940
{
30-
#[ORM\Id]
31-
#[ORM\Column(type: 'symfony_uuid', unique: true)]
32-
#[ORM\GeneratedValue(strategy: 'NONE')]
33-
private $id;
34-
#[ORM\Column(nullable: true)]
35-
private $number;
36-
37-
public function __construct(?Uuid $id = null)
38-
{
39-
$this->id = $id ?? Uuid::v4();
40-
}
41-
42-
public function getId(): Uuid
43-
{
44-
return $this->id;
45-
}
46-
47-
public function getNumber(): ?string
48-
{
49-
return $this->number;
50-
}
51-
52-
public function setNumber(?string $number): self
53-
{
54-
$this->number = $number;
55-
56-
return $this;
57-
}
41+
return $this->id;
42+
}
43+
44+
public function getNumber(): ?string
45+
{
46+
return $this->number;
47+
}
48+
49+
public function setNumber(?string $number): self
50+
{
51+
$this->number = $number;
52+
53+
return $this;
5854
}
5955
}

tests/Fixtures/app/AppKernel.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
use Doctrine\Inflector\InflectorFactory;
2323
use FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle;
2424
use Nelmio\ApiDocBundle\NelmioApiDocBundle;
25-
use Symfony\Bridge\Doctrine\Types\UuidType;
2625
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
2726
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
2827
use Symfony\Bundle\MakerBundle\MakerBundle;
@@ -39,7 +38,6 @@
3938
use Symfony\Component\Security\Core\Authorization\Strategy\AccessDecisionStrategyInterface;
4039
use Symfony\Component\Security\Core\User\User as SymfonyCoreUser;
4140
use Symfony\Component\Security\Core\User\UserInterface;
42-
use Symfony\Component\Uid\Uuid;
4341

4442
/**
4543
* AppKernel for tests.
@@ -111,10 +109,6 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load
111109

112110
$loader->load(__DIR__."/config/config_{$this->getEnvironment()}.yml");
113111

114-
if (class_exists(Uuid::class) && class_exists(UuidType::class)) {
115-
$loader->load(__DIR__.'/config/config_symfony_uid.yml');
116-
}
117-
118112
$c->getDefinition(DoctrineContext::class)->setArgument('$passwordHasher', class_exists(NativePasswordHasher::class) ? 'security.user_password_encoder' : 'security.user_password_hasher');
119113

120114
$messengerConfig = [

tests/Fixtures/app/config/config_common.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ doctrine:
55
charset: 'UTF8'
66
types:
77
uuid: Ramsey\Uuid\Doctrine\UuidType
8+
symfony_uuid: Symfony\Bridge\Doctrine\Types\UuidType
89

910
orm:
1011
auto_generate_proxy_classes: '%kernel.debug%'

tests/Fixtures/app/config/config_mysql.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ doctrine:
1515
server_version: '%env(MYSQL_VERSION)%'
1616
types:
1717
uuid: Ramsey\Uuid\Doctrine\UuidType
18+
symfony_uuid: Symfony\Bridge\Doctrine\Types\UuidType

tests/Fixtures/app/config/config_postgres.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ doctrine:
1515
server_version: '%env(POSTGRES_VERSION)%'
1616
types:
1717
uuid: Ramsey\Uuid\Doctrine\UuidType
18+
symfony_uuid: Symfony\Bridge\Doctrine\Types\UuidType

tests/Fixtures/app/config/config_sqlite.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ doctrine:
1212
url: '%env(resolve:DATABASE_URL)%'
1313
types:
1414
uuid: Ramsey\Uuid\Doctrine\UuidType
15+
symfony_uuid: Symfony\Bridge\Doctrine\Types\UuidType

tests/Fixtures/app/config/config_symfony_uid.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/Metadata/Property/Factory/AttributePropertyMetadataFactoryTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ public function testClassFoundAndParentFound()
8686
$this->assertFalse($metadata->isIdentifier());
8787
$this->assertSame('Default', $metadata->getDefault());
8888
$this->assertSame('Example', $metadata->getExample());
89-
// TODO need https://github.com/api-platform/core/pull/4422
90-
// $this->assertSame(['https://example.com'], $metadata->getTypes());
89+
$this->assertSame(['https://example.com'], $metadata->getTypes());
9190
}
9291
}

0 commit comments

Comments
 (0)