From 303e346390b74157e34dbd8537330ef164599a61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 9 Jun 2021 22:55:27 +0200 Subject: [PATCH 1/2] Restore backwards-compatibility There used to be no constructor in this class, adding one with mandatory arguments was technically a BC-break. Fixes #8753 --- lib/Doctrine/ORM/Mapping/ManyToMany.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ManyToMany.php b/lib/Doctrine/ORM/Mapping/ManyToMany.php index d9c8bedf650..07269deb4bb 100644 --- a/lib/Doctrine/ORM/Mapping/ManyToMany.php +++ b/lib/Doctrine/ORM/Mapping/ManyToMany.php @@ -31,7 +31,7 @@ #[Attribute(Attribute::TARGET_PROPERTY)] final class ManyToMany implements Annotation { - /** @var string */ + /** @var string|null */ public $targetEntity; /** @var string */ @@ -61,7 +61,7 @@ final class ManyToMany implements Annotation * @param array $cascade */ public function __construct( - string $targetEntity, + ?string $targetEntity = null, ?string $mappedBy = null, ?string $inversedBy = null, ?array $cascade = null, From 10e41ec8bccb8218434024860222c90c52819170 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 9 Jun 2021 23:01:58 +0200 Subject: [PATCH 2/2] Deprecate required of mandatory arguments --- lib/Doctrine/ORM/Mapping/Embedded.php | 9 +++++++++ lib/Doctrine/ORM/Mapping/ManyToMany.php | 9 +++++++++ lib/Doctrine/ORM/Mapping/ManyToOne.php | 9 +++++++++ 3 files changed, 27 insertions(+) diff --git a/lib/Doctrine/ORM/Mapping/Embedded.php b/lib/Doctrine/ORM/Mapping/Embedded.php index cfb0acaa980..8dbdb134bb9 100644 --- a/lib/Doctrine/ORM/Mapping/Embedded.php +++ b/lib/Doctrine/ORM/Mapping/Embedded.php @@ -22,6 +22,7 @@ use Attribute; use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor; +use Doctrine\Deprecations\Deprecation; /** * @Annotation @@ -39,6 +40,14 @@ final class Embedded implements Annotation public function __construct(?string $class = null, $columnPrefix = null) { + if ($class === null) { + Deprecation::trigger( + 'doctrine/orm', + 'https://github.com/doctrine/orm/issues/8753', + 'Passing no class is deprecated.' + ); + } + $this->class = $class; $this->columnPrefix = $columnPrefix; } diff --git a/lib/Doctrine/ORM/Mapping/ManyToMany.php b/lib/Doctrine/ORM/Mapping/ManyToMany.php index 07269deb4bb..99e70816393 100644 --- a/lib/Doctrine/ORM/Mapping/ManyToMany.php +++ b/lib/Doctrine/ORM/Mapping/ManyToMany.php @@ -22,6 +22,7 @@ use Attribute; use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor; +use Doctrine\Deprecations\Deprecation; /** * @Annotation @@ -69,6 +70,14 @@ public function __construct( bool $orphanRemoval = false, ?string $indexBy = null ) { + if ($targetEntity === null) { + Deprecation::trigger( + 'doctrine/orm', + 'https://github.com/doctrine/orm/issues/8753', + 'Passing no target entity is deprecated.' + ); + } + $this->targetEntity = $targetEntity; $this->mappedBy = $mappedBy; $this->inversedBy = $inversedBy; diff --git a/lib/Doctrine/ORM/Mapping/ManyToOne.php b/lib/Doctrine/ORM/Mapping/ManyToOne.php index e7bc2df0f51..42b5662f0d7 100644 --- a/lib/Doctrine/ORM/Mapping/ManyToOne.php +++ b/lib/Doctrine/ORM/Mapping/ManyToOne.php @@ -22,6 +22,7 @@ use Attribute; use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor; +use Doctrine\Deprecations\Deprecation; /** * @Annotation @@ -57,6 +58,14 @@ public function __construct( string $fetch = 'LAZY', ?string $inversedBy = null ) { + if ($targetEntity === null) { + Deprecation::trigger( + 'doctrine/orm', + 'https://github.com/doctrine/orm/issues/8753', + 'Passing no target entity is deprecated.' + ); + } + $this->targetEntity = $targetEntity; $this->cascade = $cascade; $this->fetch = $fetch;