diff --git a/composer.json b/composer.json index 27ed19e132f..8d955dbc0b9 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,6 @@ "behat/mink": "^1.9", "doctrine/cache": "^1.11 || ^2.1", "doctrine/common": "^3.2.2", - "doctrine/data-fixtures": "^1.2.2", "doctrine/dbal": "^3.4.0", "doctrine/doctrine-bundle": "^1.12 || ^2.0", "doctrine/mongodb-odm": "^2.2", diff --git a/tests/Fixtures/DummyCompoundValidatedEntity.php b/tests/Fixtures/DummyCompoundValidatedEntity.php index 6d999f96ac9..f8d9024d80b 100644 --- a/tests/Fixtures/DummyCompoundValidatedEntity.php +++ b/tests/Fixtures/DummyCompoundValidatedEntity.php @@ -19,8 +19,7 @@ class DummyCompoundValidatedEntity { /** * @var string - * - * @DummyCompoundRequirements */ + #[DummyCompoundRequirements] public $dummy; } diff --git a/tests/Fixtures/DummyCountValidatedEntity.php b/tests/Fixtures/DummyCountValidatedEntity.php index 761ef013d77..47d0b84df2b 100644 --- a/tests/Fixtures/DummyCountValidatedEntity.php +++ b/tests/Fixtures/DummyCountValidatedEntity.php @@ -19,22 +19,19 @@ class DummyCountValidatedEntity { /** * @var array - * - * @Assert\Count(min=1) */ + #[Assert\Count(min: 1)] public $dummyMin; /** * @var array - * - * @Assert\Count(max=10) */ + #[Assert\Count(max: 10)] public $dummyMax; /** * @var array - * - * @Assert\Count(min=1, max=10) */ + #[Assert\Count(min: 1, max: 10)] public $dummyMinMax; } diff --git a/tests/Fixtures/DummyIgnoreProperty.php b/tests/Fixtures/DummyIgnoreProperty.php index b5d6b81b0ea..b2097e3dac5 100644 --- a/tests/Fixtures/DummyIgnoreProperty.php +++ b/tests/Fixtures/DummyIgnoreProperty.php @@ -20,15 +20,10 @@ class DummyIgnoreProperty { public $visibleWithoutGroup; - /** - * @Groups({"dummy"}) - */ + #[Groups('dummy')] public $visibleWithGroup; - /** - * @Groups({"dummy"}) - * - * @Ignore - */ + #[Groups('dummy')] + #[Ignore] public $ignored; } diff --git a/tests/Fixtures/DummyIriWithValidationEntity.php b/tests/Fixtures/DummyIriWithValidationEntity.php index a5e892760ae..eb2173b5426 100644 --- a/tests/Fixtures/DummyIriWithValidationEntity.php +++ b/tests/Fixtures/DummyIriWithValidationEntity.php @@ -22,73 +22,45 @@ */ class DummyIriWithValidationEntity { - /** - * @Assert\Url - */ + #[Assert\Url] public $dummyUrl; - /** - * @Assert\Email - */ + #[Assert\Email] public $dummyEmail; - /** - * @Assert\Uuid - */ + #[Assert\Uuid] public $dummyUuid; - /** - * @Assert\CardScheme(schemes="MASTERCARD") - */ + #[Assert\CardScheme(schemes: 'MASTERCARD')] public $dummyCardScheme; - /** - * @Assert\Bic - */ + #[Assert\Bic] public $dummyBic; - /** - * @Assert\Iban - */ + #[Assert\Iban] public $dummyIban; - /** - * @Assert\Date - */ + #[Assert\Date] public $dummyDate; - /** - * @Assert\DateTime - */ + #[Assert\DateTime] public $dummyDateTime; - /** - * @Assert\Time - */ + #[Assert\Time] public $dummyTime; - /** - * @Assert\Image - */ + #[Assert\Image] public $dummyImage; - /** - * @Assert\File - */ + #[Assert\File] public $dummyFile; - /** - * @Assert\Currency - */ + #[Assert\Currency] public $dummyCurrency; - /** - * @Assert\Isbn - */ + #[Assert\Isbn] public $dummyIsbn; - /** - * @Assert\Issn - */ + #[Assert\Issn] public $dummyIssn; } diff --git a/tests/Fixtures/DummyNumericValidatedEntity.php b/tests/Fixtures/DummyNumericValidatedEntity.php index ce9b2424801..b98e7c157f0 100644 --- a/tests/Fixtures/DummyNumericValidatedEntity.php +++ b/tests/Fixtures/DummyNumericValidatedEntity.php @@ -19,57 +19,49 @@ class DummyNumericValidatedEntity { /** * @var int - * - * @Assert\GreaterThan(value=10) */ + #[Assert\GreaterThan(value: 10)] public $greaterThanMe; /** * @var float - * - * @Assert\GreaterThanOrEqual(value=10.99) */ + #[Assert\GreaterThanOrEqual(value: '10.99')] public $greaterThanOrEqualToMe; /** * @var int - * - * @Assert\LessThan(value=99) */ + #[Assert\LessThan(value: 99)] public $lessThanMe; /** * @var float - * - * @Assert\LessThanOrEqual(value=99.33) */ + #[Assert\LessThanOrEqual(value: '99.33')] public $lessThanOrEqualToMe; /** * @var int - * - * @Assert\Positive */ + #[Assert\Positive] public $positive; /** * @var int - * - * @Assert\PositiveOrZero */ + #[Assert\PositiveOrZero] public $positiveOrZero; /** * @var int - * - * @Assert\Negative */ + #[Assert\Negative] public $negative; /** * @var int - * - * @Assert\NegativeOrZero */ + #[Assert\NegativeOrZero] public $negativeOrZero; } diff --git a/tests/Fixtures/DummyRangeValidatedEntity.php b/tests/Fixtures/DummyRangeValidatedEntity.php index 282ba629aa1..ea18b5e6758 100644 --- a/tests/Fixtures/DummyRangeValidatedEntity.php +++ b/tests/Fixtures/DummyRangeValidatedEntity.php @@ -19,43 +19,37 @@ class DummyRangeValidatedEntity { /** * @var int - * - * @Assert\Range(min=1) */ + #[Assert\Range(min: 1)] public $dummyIntMin; /** * @var int - * - * @Assert\Range(max=10) */ + #[Assert\Range(max: 10)] public $dummyIntMax; /** * @var int - * - * @Assert\Range(min=1, max=10) */ + #[Assert\Range(min: 1, max: 10)] public $dummyIntMinMax; /** * @var float - * - * @Assert\Range(min=1.5) */ + #[Assert\Range(min: '1.5')] public $dummyFloatMin; /** * @var float - * - * @Assert\Range(max=10.5) */ + #[Assert\Range(max: '10.5')] public $dummyFloatMax; /** * @var float - * - * @Assert\Range(min=1.5, max=10.5) */ + #[Assert\Range(min: '1.5', max: '10.5')] public $dummyFloatMinMax; } diff --git a/tests/Fixtures/DummyUniqueValidatedEntity.php b/tests/Fixtures/DummyUniqueValidatedEntity.php index d4535e31851..a96ba6d01de 100644 --- a/tests/Fixtures/DummyUniqueValidatedEntity.php +++ b/tests/Fixtures/DummyUniqueValidatedEntity.php @@ -19,8 +19,7 @@ class DummyUniqueValidatedEntity { /** * @var string[] - * - * @Assert\Unique */ + #[Assert\Unique] public $dummyItems; } diff --git a/tests/Fixtures/DummyValidatedChoiceEntity.php b/tests/Fixtures/DummyValidatedChoiceEntity.php index f8b62184365..4229a760166 100644 --- a/tests/Fixtures/DummyValidatedChoiceEntity.php +++ b/tests/Fixtures/DummyValidatedChoiceEntity.php @@ -19,51 +19,44 @@ class DummyValidatedChoiceEntity { /** * @var string - * - * @Assert\Choice(choices={"a", "b"}) */ + #[Assert\Choice(choices: ['a', 'b'])] public $dummySingleChoice; /** * @var string - * - * @Assert\Choice(callback={DummyValidatedChoiceEntity::class, "getChoices"}) */ + #[Assert\Choice(callback: [self::class, 'getChoices'])] public $dummySingleChoiceCallback; /** * @var string[] - * - * @Assert\Choice(choices={"a", "b"}, multiple=true) */ + #[Assert\Choice(choices: ['a', 'b'], multiple: true)] public $dummyMultiChoice; /** * @var string[] - * - * @Assert\Choice(callback={DummyValidatedChoiceEntity::class, "getChoices"}, multiple=true) */ + #[Assert\Choice(callback: [self::class, 'getChoices'], multiple: true)] public $dummyMultiChoiceCallback; /** * @var string[] - * - * @Assert\Choice(choices={"a", "b", "c", "d"}, multiple=true, min=2) */ + #[Assert\Choice(choices: ['a', 'b', 'c', 'd'], multiple: true, min: 2)] public $dummyMultiChoiceMin; /** * @var string[] - * - * @Assert\Choice(choices={"a", "b", "c", "d"}, multiple=true, max=4) */ + #[Assert\Choice(choices: ['a', 'b', 'c', 'd'], multiple: true, max: 4)] public $dummyMultiChoiceMax; /** * @var string[] - * - * @Assert\Choice(choices={"a", "b", "c", "d"}, multiple=true, min=2, max=4) */ + #[Assert\Choice(choices: ['a', 'b', 'c', 'd'], multiple: true, min: 2, max: 4)] public $dummyMultiChoiceMinMax; public static function getChoices(): array diff --git a/tests/Fixtures/DummyValidatedHostnameEntity.php b/tests/Fixtures/DummyValidatedHostnameEntity.php index df248da2030..febac7e5426 100644 --- a/tests/Fixtures/DummyValidatedHostnameEntity.php +++ b/tests/Fixtures/DummyValidatedHostnameEntity.php @@ -19,8 +19,7 @@ class DummyValidatedHostnameEntity { /** * @var string - * - * @Assert\Hostname */ + #[Assert\Hostname] public $dummyHostname; } diff --git a/tests/Fixtures/DummyValidatedUlidEntity.php b/tests/Fixtures/DummyValidatedUlidEntity.php index 00e4efff759..5f19f6d628e 100644 --- a/tests/Fixtures/DummyValidatedUlidEntity.php +++ b/tests/Fixtures/DummyValidatedUlidEntity.php @@ -19,8 +19,7 @@ class DummyValidatedUlidEntity { /** * @var string - * - * @Assert\Ulid */ + #[Assert\Ulid] public $dummyUlid; } diff --git a/tests/Fixtures/NotAResource.php b/tests/Fixtures/NotAResource.php index 4c053c99352..4ecfa06319d 100644 --- a/tests/Fixtures/NotAResource.php +++ b/tests/Fixtures/NotAResource.php @@ -23,13 +23,9 @@ class NotAResource { public function __construct( - /** - * @Groups("contain_non_resource") - */ + #[Groups('contain_non_resource')] private $foo, - /** - * @Groups("contain_non_resource") - */ + #[Groups('contain_non_resource')] private $bar ) { } diff --git a/tests/Fixtures/TestBundle/Controller/Common/CustomController.php b/tests/Fixtures/TestBundle/Controller/Common/CustomController.php index 9aca6fdeac2..5847036d2f5 100644 --- a/tests/Fixtures/TestBundle/Controller/Common/CustomController.php +++ b/tests/Fixtures/TestBundle/Controller/Common/CustomController.php @@ -26,9 +26,8 @@ class CustomController extends AbstractController { /** * Custom route for a non API Platform route. - * - * @Route(methods={"GET"}, name="custom_external_route", path="/common/custom/object") */ + #[Route(methods: ['GET'], name: 'custom_external_route', path: '/common/custom/object')] public function __invoke(): CustomObject { return new CustomObject(1, 'Lorem ipsum dolor sit amet'); diff --git a/tests/Fixtures/TestBundle/Entity/NonCloneableDummy.php b/tests/Fixtures/TestBundle/Entity/NonCloneableDummy.php index 4d02182d57b..6c2ed38959d 100644 --- a/tests/Fixtures/TestBundle/Entity/NonCloneableDummy.php +++ b/tests/Fixtures/TestBundle/Entity/NonCloneableDummy.php @@ -13,8 +13,8 @@ namespace ApiPlatform\Tests\Fixtures\TestBundle\Entity; -use ApiPlatform\Core\Annotation\ApiProperty; -use ApiPlatform\Core\Annotation\ApiResource; +use ApiPlatform\Metadata\ApiProperty; +use ApiPlatform\Metadata\ApiResource; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; @@ -22,33 +22,25 @@ * Dummy class that cannot be cloned. * * @author Colin O'Dell - * - * @ApiResource - * - * @ORM\Entity */ +#[ORM\Entity] +#[ApiResource] class NonCloneableDummy { /** * @var int|null The id - * - * @ORM\Column(type="integer", nullable=true) - * - * @ORM\Id - * - * @ORM\GeneratedValue(strategy="AUTO") */ + #[ORM\Column(type: 'integer', nullable: true)] + #[ORM\Id] + #[ORM\GeneratedValue(strategy: 'AUTO')] private $id; /** * @var string The dummy name - * - * @ORM\Column - * - * @Assert\NotBlank - * - * @ApiProperty(iri="http://schema.org/name") */ + #[ApiProperty(iris: ['http://schema.org/name'])] + #[ORM\Column] + #[Assert\NotBlank] private $name; public function getId() diff --git a/tests/Fixtures/TestBundle/Validator/Constraint/DummyCompoundRequirements.php b/tests/Fixtures/TestBundle/Validator/Constraint/DummyCompoundRequirements.php index 075e5de50db..25881bac3e8 100644 --- a/tests/Fixtures/TestBundle/Validator/Constraint/DummyCompoundRequirements.php +++ b/tests/Fixtures/TestBundle/Validator/Constraint/DummyCompoundRequirements.php @@ -17,9 +17,7 @@ use Symfony\Component\Validator\Constraints\Length; use Symfony\Component\Validator\Constraints\Regex; -/** - * @Annotation - */ +#[\Attribute] final class DummyCompoundRequirements extends Compound { public function getConstraints(array $options): array diff --git a/tests/Fixtures/app/AppKernel.php b/tests/Fixtures/app/AppKernel.php index fbcdf342a03..912edda9104 100644 --- a/tests/Fixtures/app/AppKernel.php +++ b/tests/Fixtures/app/AppKernel.php @@ -17,6 +17,7 @@ use ApiPlatform\Tests\Fixtures\TestBundle\Entity\User; use ApiPlatform\Tests\Fixtures\TestBundle\TestBundle; use Doctrine\Bundle\DoctrineBundle\DoctrineBundle; +use Doctrine\Bundle\MongoDBBundle\Command\TailCursorDoctrineODMCommand; use Doctrine\Bundle\MongoDBBundle\DoctrineMongoDBBundle; use Doctrine\Common\Inflector\Inflector; use Doctrine\Inflector\InflectorFactory; @@ -29,6 +30,7 @@ use Symfony\Bundle\TwigBundle\TwigBundle; use Symfony\Bundle\WebProfilerBundle\WebProfilerBundle; use Symfony\Component\Config\Loader\LoaderInterface; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\ErrorHandler\ErrorRenderer\ErrorRendererInterface; use Symfony\Component\HttpFoundation\Session\SessionFactory; @@ -122,6 +124,7 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load 'messenger' => $messengerConfig, 'router' => ['utf8' => true], 'http_method_override' => false, + 'annotations' => false, ]); $alg = class_exists(NativePasswordHasher::class, false) || class_exists('Symfony\Component\Security\Core\Encoder\NativePasswordEncoder') ? 'auto' : 'bcrypt'; @@ -232,4 +235,15 @@ class_exists(NativePasswordHasher::class) ? 'password_hashers' : 'encoders' => [ ], ]); } + + protected function build(ContainerBuilder $container): void + { + $container->addCompilerPass(new class() implements CompilerPassInterface { + public function process(ContainerBuilder $container): void + { + // Deprecated command triggering a Symfony depreciation + $container->removeDefinition(TailCursorDoctrineODMCommand::class); + } + }); + } } diff --git a/tests/Fixtures/app/config/config_common.yml b/tests/Fixtures/app/config/config_common.yml index 8afda96df71..2eab0ec1323 100644 --- a/tests/Fixtures/app/config/config_common.yml +++ b/tests/Fixtures/app/config/config_common.yml @@ -263,10 +263,6 @@ services: alias: property_accessor public: true - test.annotation_reader: - alias: annotation_reader - public: true - app.dummy_validation.group_generator: class: ApiPlatform\Tests\Fixtures\TestBundle\Validator\DummyValidationGroupsGenerator tags: diff --git a/tests/Fixtures/app/config/config_mongodb.yml b/tests/Fixtures/app/config/config_mongodb.yml index 8708efc79c1..2e29e433aa2 100644 --- a/tests/Fixtures/app/config/config_mongodb.yml +++ b/tests/Fixtures/app/config/config_mongodb.yml @@ -159,4 +159,3 @@ services: $decorated: '@ApiPlatform\Doctrine\Common\State\PersistProcessor' tags: - name: 'api_platform.state_processor' -