From b0b86b1c47858bb6fefb9e1b9d2218aecf140003 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 6 Jun 2025 23:15:51 +0200 Subject: [PATCH] require PropertyInfo 8.0+ in the Doctrine bridge --- src/Symfony/Bridge/Doctrine/composer.json | 5 +-- .../Mapping/Loader/PropertyInfoLoaderTest.php | 35 +++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/composer.json b/src/Symfony/Bridge/Doctrine/composer.json index 18650bf669f3e..8c7018435d4ca 100644 --- a/src/Symfony/Bridge/Doctrine/composer.json +++ b/src/Symfony/Bridge/Doctrine/composer.json @@ -40,7 +40,7 @@ "symfony/lock": "^7.4|^8.0", "symfony/messenger": "^7.4|^8.0", "symfony/property-access": "^7.4|^8.0", - "symfony/property-info": "^7.4|^8.0", + "symfony/property-info": "^8.0", "symfony/security-core": "^7.4|^8.0", "symfony/stopwatch": "^7.4|^8.0", "symfony/translation": "^7.4|^8.0", @@ -53,7 +53,8 @@ "doctrine/collections": "<1.8", "doctrine/dbal": "<3.6", "doctrine/lexer": "<1.1", - "doctrine/orm": "<2.15" + "doctrine/orm": "<2.15", + "symfony/property-info": "<8.0" }, "autoload": { "psr-4": { "Symfony\\Bridge\\Doctrine\\": "" }, diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/PropertyInfoLoaderTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Loader/PropertyInfoLoaderTest.php index 6b4b40b7a2ae7..ae5253a3fee53 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/PropertyInfoLoaderTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/PropertyInfoLoaderTest.php @@ -15,6 +15,7 @@ use Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface; use Symfony\Component\PropertyInfo\PropertyListExtractorInterface; use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface; +use Symfony\Component\PropertyInfo\Type as LegacyType; use Symfony\Component\TypeInfo\Type; use Symfony\Component\Validator\Constraints\All; use Symfony\Component\Validator\Constraints\Iban; @@ -61,6 +62,7 @@ public function testLoadClassMetadata() private int $i = 0; private int $j = 0; private array $types; + private array $legacyTypes; public function getType(string $class, string $property, array $context = []): ?Type { @@ -84,6 +86,29 @@ public function getType(string $class, string $property, array $context = []): ? return $type; } + + public function getTypes(string $class, string $property, array $context = []): ?array + { + $this->legacyTypes ??= [ + [new LegacyType('string', true)], + [new LegacyType('string')], + [new LegacyType('string', true), new LegacyType('int'), new LegacyType('bool')], + [new LegacyType('object', true, Entity::class)], + [new LegacyType('array', true, null, true, null, new LegacyType('object', false, Entity::class))], + [new LegacyType('array', true, null, true)], + [new LegacyType('float', true)], // The existing constraint is float + [new LegacyType('string', true)], + [new LegacyType('string', true)], + [new LegacyType('array', true, null, true, null, new LegacyType('float'))], + [new LegacyType('string')], + [new LegacyType('string')], + ]; + + $legacyType = $this->legacyTypes[$this->j]; + ++$this->j; + + return $legacyType; + } }; $propertyAccessExtractor = $this->createMock(PropertyAccessExtractorInterface::class); @@ -215,6 +240,11 @@ public function getType(string $class, string $property, array $context = []): ? { return Type::string(); } + + public function getTypes(string $class, string $property, array $context = []): ?array + { + return [new LegacyType('string')]; + } }; $propertyAccessExtractor = $this->createMock(PropertyAccessExtractorInterface::class); @@ -249,6 +279,11 @@ public function getType(string $class, string $property, array $context = []): ? { return Type::string(); } + + public function getTypes(string $class, string $property, array $context = []): ?array + { + return [new LegacyType('string')]; + } }; }