diff --git a/composer.json b/composer.json index 57ca4481..a4a38cce 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,6 @@ }, "require-dev": { "ext-sqlite3": "*", - "doctrine/annotations": "^1.12 || ^2", "doctrine/coding-standard": "^12", "doctrine/dbal": "^3.5 || ^4", "doctrine/mongodb-odm": "^1.3.0 || ^2.0.0", diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 20b0dc06..778c0f18 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -7,11 +7,5 @@ parameters: excludePaths: - tests/Mock/ForwardCompatibleEntityManager.php - ignoreErrors: - # ORM 2 backwards compatibility - - - message: '#^Call to an undefined static method Doctrine\\ORM\\ORMSetup\:\:createAnnotationMetadataConfiguration\(\)\.$#' - path: tests/Common/DataFixtures/BaseTestCase.php - includes: - phpstan-baseline.neon diff --git a/tests/Common/DataFixtures/BaseTestCase.php b/tests/Common/DataFixtures/BaseTestCase.php index d9a8869a..86c7b881 100644 --- a/tests/Common/DataFixtures/BaseTestCase.php +++ b/tests/Common/DataFixtures/BaseTestCase.php @@ -11,8 +11,6 @@ use function method_exists; -use const PHP_VERSION_ID; - /** * Base test class */ @@ -26,12 +24,8 @@ abstract class BaseTestCase extends TestCase protected function getMockSqliteEntityManager(string $fixtureSet = 'TestEntity'): EntityManager { $dbParams = ['driver' => 'sqlite3', 'memory' => true]; - if (PHP_VERSION_ID >= 80100) { - $config = ORMSetup::createAttributeMetadataConfiguration([__DIR__ . '/' . $fixtureSet], true); - $config->setLazyGhostObjectEnabled(true); - } else { - $config = ORMSetup::createAnnotationMetadataConfiguration([__DIR__ . '/' . $fixtureSet], true); - } + $config = ORMSetup::createAttributeMetadataConfiguration([__DIR__ . '/' . $fixtureSet], true); + $config->setLazyGhostObjectEnabled(true); $connection = DriverManager::getConnection($dbParams, $config); $platform = $connection->getDatabasePlatform(); diff --git a/tests/Common/DataFixtures/Purger/MongoDBPurgerTest.php b/tests/Common/DataFixtures/Purger/MongoDBPurgerTest.php index 63f2ca94..780d116d 100644 --- a/tests/Common/DataFixtures/Purger/MongoDBPurgerTest.php +++ b/tests/Common/DataFixtures/Purger/MongoDBPurgerTest.php @@ -7,7 +7,7 @@ use Doctrine\Common\DataFixtures\Purger\MongoDBPurger; use Doctrine\ODM\MongoDB\Configuration; use Doctrine\ODM\MongoDB\DocumentManager; -use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver; +use Doctrine\ODM\MongoDB\Mapping\Driver\AttributeDriver; use Doctrine\Tests\Common\DataFixtures\BaseTestCase; use Doctrine\Tests\Common\DataFixtures\TestDocument\Role; use MongoCollection; @@ -24,18 +24,18 @@ class MongoDBPurgerTest extends BaseTestCase private function getDocumentManager(): DocumentManager { - if (! class_exists('Doctrine\ODM\MongoDB\DocumentManager')) { + if (! class_exists(DocumentManager::class)) { $this->markTestSkipped('Missing doctrine/mongodb-odm'); } - $root = dirname(dirname(dirname(dirname(dirname(__DIR__))))); + $root = dirname(__DIR__, 5); $config = new Configuration(); $config->setProxyDir($root . '/generate/proxies'); $config->setProxyNamespace('Proxies'); $config->setHydratorDir($root . '/generate/hydrators'); $config->setHydratorNamespace('Hydrators'); - $config->setMetadataDriverImpl(AnnotationDriver::create(dirname(__DIR__) . '/TestDocument')); + $config->setMetadataDriverImpl(AttributeDriver::create(dirname(__DIR__) . '/TestDocument')); $dm = DocumentManager::create(null, $config); @@ -71,8 +71,7 @@ public function testPurgeKeepsIndices(): void $this->assertIndexCount(2, $collection); } - /** @param Collection|MongoCollection $collection */ - private function assertIndexCount(int $expectedCount, object $collection): void + private function assertIndexCount(int $expectedCount, Collection|MongoCollection $collection): void { if ($collection instanceof Collection) { $indexes = $collection->listIndexes(); diff --git a/tests/Common/DataFixtures/TestDocument/Role.php b/tests/Common/DataFixtures/TestDocument/Role.php index 00dce7c3..a6281ee0 100644 --- a/tests/Common/DataFixtures/TestDocument/Role.php +++ b/tests/Common/DataFixtures/TestDocument/Role.php @@ -6,16 +6,14 @@ use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; -/** @ODM\Document */ +#[ODM\Document] class Role { - /** @ODM\Id */ + #[ODM\Id] private string|null $id = null; - /** - * @ODM\Field(type="string") - * @ODM\Index - */ + #[ODM\Field(type: 'string')] + #[ODM\Index] private string|null $name = null; public function getId(): string|null diff --git a/tests/Common/DataFixtures/TestEntity/Group.php b/tests/Common/DataFixtures/TestEntity/Group.php index 4bd6ab73..aa5ef658 100644 --- a/tests/Common/DataFixtures/TestEntity/Group.php +++ b/tests/Common/DataFixtures/TestEntity/Group.php @@ -6,22 +6,13 @@ use Doctrine\ORM\Mapping as ORM; -/** @ORM\Entity() */ #[ORM\Entity] class Group { - /** - * @ORM\Column(type="integer") - * @ORM\Id - */ #[ORM\Column] #[ORM\Id] private int|null $id = null; - /** - * @ORM\Column(length=32) - * @ORM\Id - */ #[ORM\Column(length: 32)] #[ORM\Id] private string|null $code = null; diff --git a/tests/Common/DataFixtures/TestEntity/GroupWithSchema.php b/tests/Common/DataFixtures/TestEntity/GroupWithSchema.php index dfaba79b..e24bdee8 100644 --- a/tests/Common/DataFixtures/TestEntity/GroupWithSchema.php +++ b/tests/Common/DataFixtures/TestEntity/GroupWithSchema.php @@ -6,26 +6,14 @@ use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity() - * @ORM\Table(name="group",schema="test_schema") - */ #[ORM\Entity] #[ORM\Table(name: 'group', schema: 'test_schema')] class GroupWithSchema { - /** - * @ORM\Column(type="integer") - * @ORM\Id - */ #[ORM\Column] #[ORM\Id] private int|null $id = null; - /** - * @ORM\Column(length=32) - * @ORM\Id - */ #[ORM\Column(length: 32)] #[ORM\Id] private string|null $code = null; diff --git a/tests/Common/DataFixtures/TestEntity/Link.php b/tests/Common/DataFixtures/TestEntity/Link.php index addf4c79..56a113e5 100644 --- a/tests/Common/DataFixtures/TestEntity/Link.php +++ b/tests/Common/DataFixtures/TestEntity/Link.php @@ -7,19 +7,13 @@ use Doctrine\ORM\Mapping as ORM; use Doctrine\Tests\Common\DataFixtures\TestValueObjects\Uuid; -/** @ORM\Entity */ #[ORM\Entity] class Link { - /** - * @ORM\Id - * @ORM\Column(type="uuid") - */ #[ORM\Id] #[ORM\Column(type: 'uuid')] private Uuid $id; - /** @ORM\Column(length=150) */ #[ORM\Column(length: 150)] private string|null $url = null; diff --git a/tests/Common/DataFixtures/TestEntity/Quoted.php b/tests/Common/DataFixtures/TestEntity/Quoted.php index a3ddca9b..c40e4d4e 100644 --- a/tests/Common/DataFixtures/TestEntity/Quoted.php +++ b/tests/Common/DataFixtures/TestEntity/Quoted.php @@ -7,35 +7,18 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity - * @ORM\Table("`SELECT`") - */ #[ORM\Entity] #[ORM\Table(name: '`SELECT`')] class Quoted { - /** - * @ORM\Column(type="integer") - * @ORM\Id - * @ORM\GeneratedValue(strategy="IDENTITY") - */ #[ORM\Column] #[ORM\Id] #[ORM\GeneratedValue(strategy: 'IDENTITY')] private int|null $id = null; - /** @ORM\Column(length=50, name="select") */ #[ORM\Column(length: 50, name: '`SELECT`')] private string|null $select = null; - /** - * @ORM\ManyToMany(targetEntity=Quoted::class) - * @ORM\JoinTable(name="`INSERT`", - * joinColumns={@ORM\JoinColumn(name="`SELECT`", referencedColumnName="id")}, - * inverseJoinColumns={@ORM\JoinColumn(name="`UPDATE`", referencedColumnName="id")} - * ) - */ #[ORM\ManyToMany(targetEntity: self::class)] #[ORM\JoinTable(name: '`INSERT`')] #[ORM\JoinColumn(name: '`SELECT`', referencedColumnName: 'id')] diff --git a/tests/Common/DataFixtures/TestEntity/Role.php b/tests/Common/DataFixtures/TestEntity/Role.php index fc8b3a13..884fc037 100644 --- a/tests/Common/DataFixtures/TestEntity/Role.php +++ b/tests/Common/DataFixtures/TestEntity/Role.php @@ -6,21 +6,14 @@ use Doctrine\ORM\Mapping as ORM; -/** @ORM\Entity */ #[ORM\Entity] class Role { - /** - * @ORM\Column(type="integer") - * @ORM\Id - * @ORM\GeneratedValue(strategy="IDENTITY") - */ #[ORM\Column] #[ORM\Id] #[ORM\GeneratedValue(strategy: 'IDENTITY')] private int|null $id = null; - /** @ORM\Column(length=50) */ #[ORM\Column(length: 50)] private string|null $name = null; diff --git a/tests/Common/DataFixtures/TestEntity/User.php b/tests/Common/DataFixtures/TestEntity/User.php index 0ccf6ecf..721084f1 100644 --- a/tests/Common/DataFixtures/TestEntity/User.php +++ b/tests/Common/DataFixtures/TestEntity/User.php @@ -10,58 +10,34 @@ use function md5; -/** @ORM\Entity */ #[ORM\Entity] class User { - /** - * @ORM\Column(type="integer") - * @ORM\Id - */ #[ORM\Column] #[ORM\Id] private int|null $id = null; - /** - * @ORM\Column(length=32) - * @ORM\Id - */ #[ORM\Column(length: 32)] #[ORM\Id] private string|null $code = null; - /** @ORM\Column(length=32) */ #[ORM\Column(length: 32)] private string|null $password = null; - /** @ORM\Column(length=255) */ #[ORM\Column(length: 255)] private string|null $email = null; - /** @ORM\ManyToOne(targetEntity=Role::class, cascade={"persist"}) */ #[ORM\ManyToOne(cascade: ['persist'])] private Role|null $role = null; - /** - * @ORM\ManyToMany(targetEntity=User::class, inversedBy="authors") - * @ORM\JoinTable(name="author_reader", schema="readers", - * joinColumns={@ORM\JoinColumn(name="author_id", referencedColumnName="id")}, - * inverseJoinColumns={@ORM\JoinColumn(name="reader_id", referencedColumnName="id")} - * ) - * - * @var Collection - */ + /** @var Collection */ #[ORM\ManyToMany(targetEntity: self::class, inversedBy: 'authors')] #[ORM\JoinTable(name: 'author_reader', schema: 'readers')] #[ORM\JoinColumn(name: 'author_id', referencedColumnName: 'id')] #[ORM\InverseJoinColumn(name: 'reader_id', referencedColumnName: 'id')] private Collection $readers; - /** - * @ORM\ManyToMany(targetEntity=User::class, mappedBy="readers") - * - * @var Collection - */ + /** @var Collection */ #[ORM\ManyToMany(targetEntity: self::class, mappedBy: 'readers')] private Collection $authors; diff --git a/tests/Common/DataFixtures/TestEntity/UserWithSchema.php b/tests/Common/DataFixtures/TestEntity/UserWithSchema.php index a6e3c137..09626612 100644 --- a/tests/Common/DataFixtures/TestEntity/UserWithSchema.php +++ b/tests/Common/DataFixtures/TestEntity/UserWithSchema.php @@ -10,62 +10,35 @@ use function md5; -/** - * @ORM\Entity - * @ORM\Table(name="user",schema="test_schema") - */ #[ORM\Entity] #[ORM\Table(name: 'user', schema: 'test_schema')] class UserWithSchema { - /** - * @ORM\Column(type="integer") - * @ORM\Id - */ #[ORM\Column] #[ORM\Id] private int|null $id = null; - /** - * @ORM\Column(length=32) - * @ORM\Id - */ #[ORM\Column(length: 32)] #[ORM\Id] private string|null $code = null; - /** @ORM\Column(length=32) */ #[ORM\Column(length: 32)] private string|null $password = null; - /** @ORM\Column(length=255) */ #[ORM\Column(length: 255)] private string|null $email = null; - /** @ORM\ManyToOne(targetEntity=Role::class, cascade={"persist"}) */ #[ORM\ManyToOne(cascade: ['persist'])] private Role|null $role = null; - /** - * @ORM\ManyToMany(targetEntity=UserWithSchema::class, inversedBy="authors") - * @ORM\JoinTable(name="author_reader", schema="readers", - * joinColumns={@ORM\JoinColumn(name="author_id", referencedColumnName="id")}, - * inverseJoinColumns={@ORM\JoinColumn(name="reader_id", referencedColumnName="id")} - * ) - * - * @var Collection - */ + /** @var Collection */ #[ORM\ManyToMany(targetEntity: self::class, inversedBy: 'authors')] #[ORM\JoinTable(name: 'author_reader', schema: 'readers')] #[ORM\JoinColumn(name: 'author_id', referencedColumnName: 'id')] #[ORM\InverseJoinColumn(name: 'reader_id', referencedColumnName: 'id')] private Collection $readers; - /** - * @ORM\ManyToMany(targetEntity=UserWithSchema::class, mappedBy="readers") - * - * @var Collection - */ + /** @var Collection */ #[ORM\ManyToMany(targetEntity: self::class, mappedBy: 'readers')] private Collection $authors; diff --git a/tests/Common/DataFixtures/TestPurgeEntity/ExcludedEntity.php b/tests/Common/DataFixtures/TestPurgeEntity/ExcludedEntity.php index 58103ad2..3f0eae7f 100644 --- a/tests/Common/DataFixtures/TestPurgeEntity/ExcludedEntity.php +++ b/tests/Common/DataFixtures/TestPurgeEntity/ExcludedEntity.php @@ -6,14 +6,9 @@ use Doctrine\ORM\Mapping as ORM; -/** @ORM\Entity */ #[ORM\Entity] class ExcludedEntity { - /** - * @ORM\Column(type="integer") - * @ORM\Id - */ #[ORM\Column] #[ORM\Id] private int|null $id = null; diff --git a/tests/Common/DataFixtures/TestPurgeEntity/IncludedEntity.php b/tests/Common/DataFixtures/TestPurgeEntity/IncludedEntity.php index b2acc30c..a32681ef 100644 --- a/tests/Common/DataFixtures/TestPurgeEntity/IncludedEntity.php +++ b/tests/Common/DataFixtures/TestPurgeEntity/IncludedEntity.php @@ -6,14 +6,9 @@ use Doctrine\ORM\Mapping as ORM; -/** @ORM\Entity */ #[ORM\Entity] class IncludedEntity { - /** - * @ORM\Column(type="integer") - * @ORM\Id - */ #[ORM\Column] #[ORM\Id] private int|null $id = null;