From 1c5014933981f8bb135cb44c639e96be0c39edc5 Mon Sep 17 00:00:00 2001 From: Mariusz Soltys Date: Tue, 10 Oct 2023 10:11:28 +0100 Subject: [PATCH] Updated order of mapping attribute parameters --- UPGRADE.md | 5 +++++ lib/Doctrine/ORM/Mapping/Index.php | 2 +- lib/Doctrine/ORM/Mapping/OneToMany.php | 2 +- lib/Doctrine/ORM/Mapping/OneToOne.php | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index b8680f7ed89..0b618631303 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,10 @@ # Upgrade to 3.0 +## Minor BC BREAK: Changed order of arguments passed to `OneToOne`, `ManyToOne` and `Index` mapping PHP attributes + +To keep PHP mapping attributes consistent, order of arguments passed to above attributes has been changed +so `$targetEntity` is a first argument now. This change affects only non-named arguments usage. + ## BC BREAK: `Doctrine\ORM\Persister\Entity\EntityPersister::executeInserts()` return type changed to `void` Implementors should adapt to the new signature, and should call diff --git a/lib/Doctrine/ORM/Mapping/Index.php b/lib/Doctrine/ORM/Mapping/Index.php index f58adfb1340..1de939e506e 100644 --- a/lib/Doctrine/ORM/Mapping/Index.php +++ b/lib/Doctrine/ORM/Mapping/Index.php @@ -16,9 +16,9 @@ final class Index implements MappingAttribute * @param array|null $options */ public function __construct( + public readonly string|null $name = null, public readonly array|null $columns = null, public readonly array|null $fields = null, - public readonly string|null $name = null, public readonly array|null $flags = null, public readonly array|null $options = null, ) { diff --git a/lib/Doctrine/ORM/Mapping/OneToMany.php b/lib/Doctrine/ORM/Mapping/OneToMany.php index 4eac8842ee6..d71c4f93416 100644 --- a/lib/Doctrine/ORM/Mapping/OneToMany.php +++ b/lib/Doctrine/ORM/Mapping/OneToMany.php @@ -15,8 +15,8 @@ final class OneToMany implements MappingAttribute * @psalm-param 'LAZY'|'EAGER'|'EXTRA_LAZY' $fetch */ public function __construct( - public readonly string|null $mappedBy = null, public readonly string|null $targetEntity = null, + public readonly string|null $mappedBy = null, public readonly array|null $cascade = null, public readonly string $fetch = 'LAZY', public readonly bool $orphanRemoval = false, diff --git a/lib/Doctrine/ORM/Mapping/OneToOne.php b/lib/Doctrine/ORM/Mapping/OneToOne.php index e3e64559a6f..1ddf21c8fe6 100644 --- a/lib/Doctrine/ORM/Mapping/OneToOne.php +++ b/lib/Doctrine/ORM/Mapping/OneToOne.php @@ -15,9 +15,9 @@ final class OneToOne implements MappingAttribute * @psalm-param 'LAZY'|'EAGER'|'EXTRA_LAZY' $fetch */ public function __construct( + public readonly string|null $targetEntity = null, public readonly string|null $mappedBy = null, public readonly string|null $inversedBy = null, - public readonly string|null $targetEntity = null, public readonly array|null $cascade = null, public readonly string $fetch = 'LAZY', public readonly bool $orphanRemoval = false,