From e2e11af10dec2398022ed9a0828337fc7110b290 Mon Sep 17 00:00:00 2001 From: Michael Babker Date: Wed, 11 Oct 2023 21:51:12 -0400 Subject: [PATCH] Run the ORM tests using an attribute driver when able --- .../Doctrine/Embeddable/BlogPostSeo.php | 3 +++ .../Embeddable/BlogPostWithEmbedded.php | 6 ++++++ tests/Fixtures/Doctrine/Entity/Author.php | 7 +++++++ .../Doctrine/Entity/AuthorExcludedId.php | 5 +++++ tests/Fixtures/Doctrine/Entity/BlogPost.php | 15 +++++++++++++- tests/Fixtures/Doctrine/Entity/Comment.php | 9 ++++++++- .../Doctrine/IdentityFields/Server.php | 7 +++++++ .../Doctrine/PersistendCollection/App.php | 8 ++++++++ .../PersistendCollection/SmartPhone.php | 6 ++++++ .../Doctrine/SingleTableInheritance/Clazz.php | 7 +++++++ .../SingleTableInheritance/Organization.php | 8 ++++++++ .../SingleTableInheritance/Person.php | 8 ++++++++ .../SingleTableInheritance/School.php | 1 + .../SingleTableInheritance/Student.php | 1 + .../SingleTableInheritance/Teacher.php | 1 + tests/Metadata/Driver/DoctrineDriverTest.php | 16 +++++++++++---- tests/Serializer/Doctrine/IntegrationTest.php | 15 +++++++++++--- .../Doctrine/ObjectConstructorTest.php | 20 ++++++++++++++----- 18 files changed, 129 insertions(+), 14 deletions(-) diff --git a/tests/Fixtures/Doctrine/Embeddable/BlogPostSeo.php b/tests/Fixtures/Doctrine/Embeddable/BlogPostSeo.php index ed24ab396..297c4c927 100644 --- a/tests/Fixtures/Doctrine/Embeddable/BlogPostSeo.php +++ b/tests/Fixtures/Doctrine/Embeddable/BlogPostSeo.php @@ -4,11 +4,13 @@ namespace JMS\Serializer\Tests\Fixtures\Doctrine\Embeddable; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Embeddable() */ +#[ORM\Embeddable] class BlogPostSeo { /** @@ -16,5 +18,6 @@ class BlogPostSeo * * @var string */ + #[ORM\Column(type: Types::STRING, name: 'meta_title')] private $metaTitle; } diff --git a/tests/Fixtures/Doctrine/Embeddable/BlogPostWithEmbedded.php b/tests/Fixtures/Doctrine/Embeddable/BlogPostWithEmbedded.php index 5f6868603..036276584 100644 --- a/tests/Fixtures/Doctrine/Embeddable/BlogPostWithEmbedded.php +++ b/tests/Fixtures/Doctrine/Embeddable/BlogPostWithEmbedded.php @@ -4,11 +4,13 @@ namespace JMS\Serializer\Tests\Fixtures\Doctrine\Embeddable; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity */ +#[ORM\Entity] class BlogPostWithEmbedded { /** @@ -16,10 +18,14 @@ class BlogPostWithEmbedded * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ + #[ORM\Id] + #[ORM\Column(type: Types::INTEGER)] + #[ORM\GeneratedValue(strategy: 'AUTO')] protected $id; /** * @ORM\Embedded(class="BlogPostSeo", columnPrefix="seo_") */ + #[ORM\Embedded(class: BlogPostSeo::class, columnPrefix: 'seo_')] private $seo; } diff --git a/tests/Fixtures/Doctrine/Entity/Author.php b/tests/Fixtures/Doctrine/Entity/Author.php index 5c04d19ee..468cbc013 100644 --- a/tests/Fixtures/Doctrine/Entity/Author.php +++ b/tests/Fixtures/Doctrine/Entity/Author.php @@ -4,11 +4,13 @@ namespace JMS\Serializer\Tests\Fixtures\Doctrine\Entity; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; use JMS\Serializer\Annotation\Groups; use JMS\Serializer\Annotation\SerializedName; /** @ORM\Entity */ +#[ORM\Entity] class Author { /** @@ -17,6 +19,9 @@ class Author * * @Groups({"id_group"}) */ + #[ORM\Id] + #[ORM\Column(type: Types::INTEGER)] + #[Groups(groups: ['id_group'])] protected $id; /** @@ -24,6 +29,8 @@ class Author * * @SerializedName("full_name") */ + #[ORM\Column(type: Types::STRING)] + #[SerializedName(name: 'full_name')] private $name; public function __construct($name, $id = null) diff --git a/tests/Fixtures/Doctrine/Entity/AuthorExcludedId.php b/tests/Fixtures/Doctrine/Entity/AuthorExcludedId.php index 215160554..f3617af7d 100644 --- a/tests/Fixtures/Doctrine/Entity/AuthorExcludedId.php +++ b/tests/Fixtures/Doctrine/Entity/AuthorExcludedId.php @@ -4,11 +4,13 @@ namespace JMS\Serializer\Tests\Fixtures\Doctrine\Entity; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; use JMS\Serializer\Annotation\Exclude; use JMS\Serializer\Annotation\SerializedName; /** @ORM\Entity */ +#[ORM\Entity] class AuthorExcludedId { /** @@ -17,6 +19,8 @@ class AuthorExcludedId * * @Exclude */ + #[ORM\Id] + #[ORM\Column(type: Types::INTEGER)] #[Exclude] protected $id; @@ -25,6 +29,7 @@ class AuthorExcludedId * * @SerializedName("full_name") */ + #[ORM\Column(type: Types::STRING)] #[SerializedName(name: 'full_name')] private $name; diff --git a/tests/Fixtures/Doctrine/Entity/BlogPost.php b/tests/Fixtures/Doctrine/Entity/BlogPost.php index d49b7e903..665c72fd4 100644 --- a/tests/Fixtures/Doctrine/Entity/BlogPost.php +++ b/tests/Fixtures/Doctrine/Entity/BlogPost.php @@ -5,6 +5,7 @@ namespace JMS\Serializer\Tests\Fixtures\Doctrine\Entity; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; use JMS\Serializer\Annotation as Serializer; use JMS\Serializer\Annotation\Groups; @@ -19,6 +20,7 @@ * * @XmlRoot("blog-post") */ +#[ORM\Entity] #[XmlRoot(name: 'blog-post')] class BlogPost { @@ -27,11 +29,15 @@ class BlogPost * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ + #[ORM\Id] + #[ORM\Column(type: Types::INTEGER)] + #[ORM\GeneratedValue(strategy: 'AUTO')] protected $id; /** * @ORM\Column(type="guid") */ + #[ORM\Column(type: Types::GUID)] private $guid; /** @@ -39,12 +45,14 @@ class BlogPost * * @Groups({"comments","post"}) */ + #[ORM\Column(type: Types::STRING)] #[Groups(groups: ['comments', 'post'])] private $title; /** * @ORM\Column(type="some_custom_type") */ + #[ORM\Column(type: 'some_custom_type')] protected $slug; /** @@ -52,6 +60,7 @@ class BlogPost * * @XmlAttribute */ + #[ORM\Column(type: Types::DATETIME_MUTABLE)] #[XmlAttribute] private $createdAt; @@ -66,6 +75,7 @@ class BlogPost * @Groups({"post"}) * @XmlAttribute */ + #[ORM\Column(type: Types::BOOLEAN)] #[Type(name: 'integer')] #[SerializedName(name: 'is_published')] #[Groups(groups: ['post'])] @@ -78,6 +88,7 @@ class BlogPost * @XmlList(inline=true, entry="comment") * @Groups({"comments"}) */ + #[ORM\OneToMany(targetEntity: Comment::class, mappedBy: 'blogPost')] #[XmlList(entry: 'comment', inline: true)] #[Groups(groups: ['comments'])] private $comments; @@ -87,13 +98,15 @@ class BlogPost * * @Groups({"post"}) */ + #[ORM\OneToOne(targetEntity: Author::class)] #[Groups(groups: ['post'])] private $author; /** - * @Serializer\Exclude() * @ORM\Column(type="integer") + * @Serializer\Exclude() */ + #[ORM\Column(type: Types::INTEGER)] #[Serializer\Exclude] private $ref; diff --git a/tests/Fixtures/Doctrine/Entity/Comment.php b/tests/Fixtures/Doctrine/Entity/Comment.php index 402685f70..7b09e0853 100644 --- a/tests/Fixtures/Doctrine/Entity/Comment.php +++ b/tests/Fixtures/Doctrine/Entity/Comment.php @@ -5,28 +5,35 @@ namespace JMS\Serializer\Tests\Fixtures\Doctrine\Entity; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; /** @ORM\Entity */ +#[ORM\Entity] class Comment { /** * @ORM\Id * @ORM\Column(type="integer") */ + #[ORM\Id] + #[ORM\Column(type: Types::INTEGER)] protected $id; /** - * @ORM\Column(type="Author") + * @ORM\OneToOne(targetEntity="Author") */ + #[ORM\OneToOne(targetEntity: Author::class)] private $author; /** @ORM\ManyToOne(targetEntity="BlogPost") */ + #[ORM\ManyToOne(targetEntity: BlogPost::class)] private $blogPost; /** * @ORM\Column(type="string") */ + #[ORM\Column(type: Types::STRING)] private $text; public function __construct(Author $author, $text) diff --git a/tests/Fixtures/Doctrine/IdentityFields/Server.php b/tests/Fixtures/Doctrine/IdentityFields/Server.php index cdd20f73d..329dd85eb 100644 --- a/tests/Fixtures/Doctrine/IdentityFields/Server.php +++ b/tests/Fixtures/Doctrine/IdentityFields/Server.php @@ -4,10 +4,12 @@ namespace JMS\Serializer\Tests\Fixtures\Doctrine\IdentityFields; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; use JMS\Serializer\Annotation as Serializer; /** @ORM\Entity */ +#[ORM\Entity] class Server { /** @@ -18,6 +20,8 @@ class Server * @var string */ #[Serializer\Type(name: 'string')] + #[ORM\Id] + #[ORM\Column(type: Types::STRING, name: 'ip_address')] protected $ipAddress; /** @@ -30,6 +34,8 @@ class Server */ #[Serializer\SerializedName(name: 'server_id_extracted')] #[Serializer\Type(name: 'string')] + #[ORM\Id] + #[ORM\Column(type: Types::STRING, name: 'server_id')] protected $serverId; /** @@ -39,6 +45,7 @@ class Server * @var string */ #[Serializer\Type(name: 'string')] + #[ORM\Column(type: Types::STRING)] private $name; /** diff --git a/tests/Fixtures/Doctrine/PersistendCollection/App.php b/tests/Fixtures/Doctrine/PersistendCollection/App.php index e10cd85b3..dd6a9a86c 100644 --- a/tests/Fixtures/Doctrine/PersistendCollection/App.php +++ b/tests/Fixtures/Doctrine/PersistendCollection/App.php @@ -4,10 +4,12 @@ namespace JMS\Serializer\Tests\Fixtures\Doctrine\PersistendCollection; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; use JMS\Serializer\Annotation as Serializer; /** @ORM\Entity */ +#[ORM\Entity] class App { /** @@ -18,7 +20,10 @@ class App * * @var string */ + #[Serializer\SerializedName(name: 'id')] #[Serializer\Type(name: 'string')] + #[ORM\Id] + #[ORM\Column(type: Types::STRING, name: 'id')] protected $id; /** @@ -28,13 +33,16 @@ class App * @var string */ #[Serializer\Type(name: 'string')] + #[ORM\Column(type: Types::STRING)] private $name; /** * @ORM\ManyToOne(targetEntity="SmartPhone") + * @Serializer\Type("JMS\Serializer\Tests\Fixtures\Doctrine\PersistendCollection\SmartPhone") * * @var SmartPhone */ + #[ORM\ManyToOne(targetEntity: SmartPhone::class)] #[Serializer\Type(name: SmartPhone::class)] private $smartPhone; diff --git a/tests/Fixtures/Doctrine/PersistendCollection/SmartPhone.php b/tests/Fixtures/Doctrine/PersistendCollection/SmartPhone.php index 8622d5874..9e68aab4c 100644 --- a/tests/Fixtures/Doctrine/PersistendCollection/SmartPhone.php +++ b/tests/Fixtures/Doctrine/PersistendCollection/SmartPhone.php @@ -7,10 +7,12 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Criteria; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; use JMS\Serializer\Annotation as Serializer; /** @ORM\Entity */ +#[ORM\Entity] class SmartPhone { /** @@ -23,6 +25,8 @@ class SmartPhone */ #[Serializer\SerializedName(name: 'id')] #[Serializer\Type(name: 'string')] + #[ORM\Id] + #[ORM\Column(type: Types::STRING, name: 'id')] protected $id; /** @@ -32,6 +36,7 @@ class SmartPhone * @var string */ #[Serializer\Type(name: 'string')] + #[ORM\Column(type: Types::STRING)] private $name; /** @@ -43,6 +48,7 @@ class SmartPhone */ #[Serializer\SerializedName(name: 'applications')] #[Serializer\Type(name: 'ArrayCollection')] + #[ORM\OneToMany(targetEntity: App::class, mappedBy: 'smartPhone', cascade: ['persist'], orphanRemoval: true)] private $apps; /** diff --git a/tests/Fixtures/Doctrine/SingleTableInheritance/Clazz.php b/tests/Fixtures/Doctrine/SingleTableInheritance/Clazz.php index 001f9223e..4702053fd 100644 --- a/tests/Fixtures/Doctrine/SingleTableInheritance/Clazz.php +++ b/tests/Fixtures/Doctrine/SingleTableInheritance/Clazz.php @@ -5,11 +5,13 @@ namespace JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity */ +#[ORM\Entity] class Clazz extends AbstractModel { /** @@ -17,12 +19,17 @@ class Clazz extends AbstractModel * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ + #[ORM\Id] + #[ORM\Column(type: Types::INTEGER)] + #[ORM\GeneratedValue(strategy: 'AUTO')] private $id; /** @ORM\ManyToOne(targetEntity = "JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance\Teacher") */ + #[ORM\ManyToOne(targetEntity: Teacher::class)] private $teacher; /** @ORM\ManyToMany(targetEntity = "JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance\Student") */ + #[ORM\ManyToMany(targetEntity: Student::class)] private $students; public function __construct(Teacher $teacher, array $students) diff --git a/tests/Fixtures/Doctrine/SingleTableInheritance/Organization.php b/tests/Fixtures/Doctrine/SingleTableInheritance/Organization.php index 8c2edb809..f04eae6c5 100644 --- a/tests/Fixtures/Doctrine/SingleTableInheritance/Organization.php +++ b/tests/Fixtures/Doctrine/SingleTableInheritance/Organization.php @@ -4,6 +4,7 @@ namespace JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; /** @@ -14,6 +15,10 @@ * "school" = "JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance\School" * }) */ +#[ORM\Entity] +#[ORM\InheritanceType('SINGLE_TABLE')] +#[ORM\DiscriminatorColumn(name: 'type', type: Types::STRING)] +#[ORM\DiscriminatorMap(['school' => School::class])] abstract class Organization { /** @@ -21,5 +26,8 @@ abstract class Organization * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ + #[ORM\Id] + #[ORM\Column(type: Types::INTEGER)] + #[ORM\GeneratedValue(strategy: 'AUTO')] private $id; } diff --git a/tests/Fixtures/Doctrine/SingleTableInheritance/Person.php b/tests/Fixtures/Doctrine/SingleTableInheritance/Person.php index b10e33ee1..ea887bb27 100644 --- a/tests/Fixtures/Doctrine/SingleTableInheritance/Person.php +++ b/tests/Fixtures/Doctrine/SingleTableInheritance/Person.php @@ -4,6 +4,7 @@ namespace JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; /** @@ -15,6 +16,10 @@ * "teacher" = "JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance\Teacher", * }) */ +#[ORM\Entity] +#[ORM\InheritanceType('SINGLE_TABLE')] +#[ORM\DiscriminatorColumn(name: 'type', type: Types::STRING)] +#[ORM\DiscriminatorMap(['student' => Student::class, 'teacher' => Teacher::class])] abstract class Person extends AbstractModel { /** @@ -22,5 +27,8 @@ abstract class Person extends AbstractModel * @ORM\Column(type = "integer") * @ORM\GeneratedValue(strategy = "AUTO") */ + #[ORM\Id] + #[ORM\Column(type: Types::INTEGER)] + #[ORM\GeneratedValue(strategy: 'AUTO')] private $id; } diff --git a/tests/Fixtures/Doctrine/SingleTableInheritance/School.php b/tests/Fixtures/Doctrine/SingleTableInheritance/School.php index a74dad85c..c9d163a0d 100644 --- a/tests/Fixtures/Doctrine/SingleTableInheritance/School.php +++ b/tests/Fixtures/Doctrine/SingleTableInheritance/School.php @@ -9,6 +9,7 @@ /** * @ORM\Entity */ +#[ORM\Entity] class School extends Organization { } diff --git a/tests/Fixtures/Doctrine/SingleTableInheritance/Student.php b/tests/Fixtures/Doctrine/SingleTableInheritance/Student.php index 7e6412760..7ef4eba91 100644 --- a/tests/Fixtures/Doctrine/SingleTableInheritance/Student.php +++ b/tests/Fixtures/Doctrine/SingleTableInheritance/Student.php @@ -9,6 +9,7 @@ /** * @ORM\Entity */ +#[ORM\Entity] class Student extends Person { } diff --git a/tests/Fixtures/Doctrine/SingleTableInheritance/Teacher.php b/tests/Fixtures/Doctrine/SingleTableInheritance/Teacher.php index 4f3bd2597..eae0374c1 100644 --- a/tests/Fixtures/Doctrine/SingleTableInheritance/Teacher.php +++ b/tests/Fixtures/Doctrine/SingleTableInheritance/Teacher.php @@ -9,6 +9,7 @@ /** * @ORM\Entity */ +#[ORM\Entity] class Teacher extends Person { } diff --git a/tests/Metadata/Driver/DoctrineDriverTest.php b/tests/Metadata/Driver/DoctrineDriverTest.php index 88fd2a0f0..6f25c0bc1 100644 --- a/tests/Metadata/Driver/DoctrineDriverTest.php +++ b/tests/Metadata/Driver/DoctrineDriverTest.php @@ -7,7 +7,8 @@ use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManager; -use Doctrine\ORM\Mapping\Driver\AnnotationDriver as DoctrineDriver; +use Doctrine\ORM\Mapping\Driver\AnnotationDriver as DoctrineAnnotationDriver; +use Doctrine\ORM\Mapping\Driver\AttributeDriver as DoctrineAttributeDriver; use Doctrine\ORM\Version as ORMVersion; use Doctrine\Persistence\ManagerRegistry; use JMS\Serializer\Metadata\Driver\AnnotationDriver; @@ -134,9 +135,16 @@ protected function getEntityManager() $config = new Configuration(); $config->setProxyDir(sys_get_temp_dir() . '/JMSDoctrineTestProxies'); $config->setProxyNamespace('JMS\Tests\Proxies'); - $config->setMetadataDriverImpl( - new DoctrineDriver(new AnnotationReader(), __DIR__ . '/../../Fixtures/Doctrine') - ); + + if (PHP_VERSION_ID >= 80000 && class_exists(DoctrineAttributeDriver::class)) { + $config->setMetadataDriverImpl( + new DoctrineAttributeDriver([__DIR__ . '/../../Fixtures/Doctrine'], true) + ); + } else { + $config->setMetadataDriverImpl( + new DoctrineAnnotationDriver(new AnnotationReader(), __DIR__ . '/../../Fixtures/Doctrine') + ); + } $conn = [ 'driver' => 'pdo_sqlite', diff --git a/tests/Serializer/Doctrine/IntegrationTest.php b/tests/Serializer/Doctrine/IntegrationTest.php index c8f5ae5ae..eb9111872 100644 --- a/tests/Serializer/Doctrine/IntegrationTest.php +++ b/tests/Serializer/Doctrine/IntegrationTest.php @@ -11,6 +11,7 @@ use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManager; use Doctrine\ORM\Mapping\Driver\AnnotationDriver; +use Doctrine\ORM\Mapping\Driver\AttributeDriver; use Doctrine\ORM\ORMException; use Doctrine\ORM\Tools\SchemaTool; use Doctrine\Persistence\AbstractManagerRegistry; @@ -135,9 +136,17 @@ private function createConnection() private function createEntityManager(Connection $con) { $cfg = new Configuration(); - $cfg->setMetadataDriverImpl(new AnnotationDriver(new AnnotationReader(), [ - __DIR__ . '/../../Fixtures/Doctrine/SingleTableInheritance', - ])); + + if (PHP_VERSION_ID >= 80000 && class_exists(AttributeDriver::class)) { + $cfg->setMetadataDriverImpl(new AttributeDriver([ + __DIR__ . '/../../Fixtures/Doctrine/SingleTableInheritance', + ])); + } else { + $cfg->setMetadataDriverImpl(new AnnotationDriver(new AnnotationReader(), [ + __DIR__ . '/../../Fixtures/Doctrine/SingleTableInheritance', + ])); + } + $cfg->setAutoGenerateProxyClasses(true); $cfg->setProxyNamespace('JMS\Serializer\DoctrineProxy'); $cfg->setProxyDir(sys_get_temp_dir() . '/serializer-test-proxies'); diff --git a/tests/Serializer/Doctrine/ObjectConstructorTest.php b/tests/Serializer/Doctrine/ObjectConstructorTest.php index f32d526c5..fb376d227 100644 --- a/tests/Serializer/Doctrine/ObjectConstructorTest.php +++ b/tests/Serializer/Doctrine/ObjectConstructorTest.php @@ -13,6 +13,7 @@ use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManager; use Doctrine\ORM\Mapping\Driver\AnnotationDriver; +use Doctrine\ORM\Mapping\Driver\AttributeDriver; use Doctrine\ORM\Mapping\Driver\XmlDriver; use Doctrine\ORM\ORMException; use Doctrine\ORM\PersistentCollection; @@ -534,11 +535,20 @@ private function createEntityManager(Connection $con, ?Configuration $cfg = null { if (!$cfg) { $cfg = new Configuration(); - $cfg->setMetadataDriverImpl(new AnnotationDriver(new AnnotationReader(), [ - __DIR__ . '/../../Fixtures/Doctrine/Entity', - __DIR__ . '/../../Fixtures/Doctrine/IdentityFields', - __DIR__ . '/../../Fixtures/Doctrine/PersistendCollection', - ])); + + if (PHP_VERSION_ID >= 80000 && class_exists(AttributeDriver::class)) { + $cfg->setMetadataDriverImpl(new AttributeDriver([ + __DIR__ . '/../../Fixtures/Doctrine/Entity', + __DIR__ . '/../../Fixtures/Doctrine/IdentityFields', + __DIR__ . '/../../Fixtures/Doctrine/PersistendCollection', + ])); + } else { + $cfg->setMetadataDriverImpl(new AnnotationDriver(new AnnotationReader(), [ + __DIR__ . '/../../Fixtures/Doctrine/Entity', + __DIR__ . '/../../Fixtures/Doctrine/IdentityFields', + __DIR__ . '/../../Fixtures/Doctrine/PersistendCollection', + ])); + } } $cfg->setAutoGenerateProxyClasses(true);