From 3aed6912a3ff20475e520a5e0cab4d3e12aa427a Mon Sep 17 00:00:00 2001 From: Louis-Arnaud <20201470+lacatoire@users.noreply.github.com> Date: Fri, 21 Feb 2025 10:10:22 +0100 Subject: [PATCH 1/2] Update ORMInvalidArgumentException.php update message to use attribute instead of annotation --- src/ORMInvalidArgumentException.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ORMInvalidArgumentException.php b/src/ORMInvalidArgumentException.php index 2181d207c28..868f4496ef6 100644 --- a/src/ORMInvalidArgumentException.php +++ b/src/ORMInvalidArgumentException.php @@ -309,7 +309,7 @@ private static function newEntityFoundThroughRelationshipMessage(array $associat . ' configured to cascade persist operations for entity: ' . self::objToStr($entity) . '.' . ' To solve this issue: Either explicitly call EntityManager#persist()' . ' on this unknown entity or configure cascade persist' - . ' this association in the mapping for example @ManyToOne(..,cascade={"persist"}).' + . ' this association in the mapping for example #[ORM\ManyToOne(..., cascade: ['persist'])].' . (method_exists($entity, '__toString') ? '' : ' If you cannot find out which entity causes the problem implement \'' From 2d2a34407c102c76f854916fad1d0b8e0aabb2ba Mon Sep 17 00:00:00 2001 From: Louis-Arnaud <20201470+lacatoire@users.noreply.github.com> Date: Fri, 21 Feb 2025 21:29:39 +0100 Subject: [PATCH 2/2] Use attributes in exception message --- src/ORMInvalidArgumentException.php | 2 +- tests/Tests/ORM/ORMInvalidArgumentExceptionTest.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ORMInvalidArgumentException.php b/src/ORMInvalidArgumentException.php index 868f4496ef6..b2db07ff43b 100644 --- a/src/ORMInvalidArgumentException.php +++ b/src/ORMInvalidArgumentException.php @@ -309,7 +309,7 @@ private static function newEntityFoundThroughRelationshipMessage(array $associat . ' configured to cascade persist operations for entity: ' . self::objToStr($entity) . '.' . ' To solve this issue: Either explicitly call EntityManager#persist()' . ' on this unknown entity or configure cascade persist' - . ' this association in the mapping for example #[ORM\ManyToOne(..., cascade: ['persist'])].' + . ' this association in the mapping for example #[ORM\ManyToOne(..., cascade: [\'persist\'])].' . (method_exists($entity, '__toString') ? '' : ' If you cannot find out which entity causes the problem implement \'' diff --git a/tests/Tests/ORM/ORMInvalidArgumentExceptionTest.php b/tests/Tests/ORM/ORMInvalidArgumentExceptionTest.php index e878bc067b6..6af40bd0d74 100644 --- a/tests/Tests/ORM/ORMInvalidArgumentExceptionTest.php +++ b/tests/Tests/ORM/ORMInvalidArgumentExceptionTest.php @@ -85,7 +85,7 @@ public function __toString(): string . 'persist operations for entity: stdClass@' . spl_object_id($entity1) . '. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity ' . 'or configure cascade persist this association in the mapping for example ' - . '@ManyToOne(..,cascade={"persist"}). If you cannot find out which entity causes the problem ' + . '#[ORM\ManyToOne(..., cascade: [\'persist\'])]. If you cannot find out which entity causes the problem ' . 'implement \'baz1#__toString()\' to get a clue.', ], 'two entities found' => [ @@ -104,13 +104,13 @@ public function __toString(): string . 'cascade persist operations for entity: stdClass@' . spl_object_id($entity1) . '. ' . 'To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity ' . 'or configure cascade persist this association in the mapping for example ' - . '@ManyToOne(..,cascade={"persist"}). If you cannot find out which entity causes the problem ' + . '#[ORM\ManyToOne(..., cascade: [\'persist\'])]. If you cannot find out which entity causes the problem ' . 'implement \'baz1#__toString()\' to get a clue.' . "\n" . ' * A new entity was found through the relationship \'foo2#bar2\' that was not configured to ' . 'cascade persist operations for entity: stdClass@' . spl_object_id($entity2) . '. To solve ' . 'this issue: Either explicitly call EntityManager#persist() on this unknown entity or ' . 'configure cascade persist this association in the mapping for example ' - . '@ManyToOne(..,cascade={"persist"}). If you cannot find out which entity causes the problem ' + . '#[ORM\ManyToOne(..., cascade: [\'persist\'])]. If you cannot find out which entity causes the problem ' . 'implement \'baz2#__toString()\' to get a clue.', ], 'two entities found, one is stringable' => [ @@ -124,7 +124,7 @@ public function __toString(): string . 'persist operations for entity: ThisIsAStringRepresentationOfEntity3' . '. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity ' . 'or configure cascade persist this association in the mapping for example ' - . '@ManyToOne(..,cascade={"persist"}).', + . '#[ORM\ManyToOne(..., cascade: [\'persist\'])].', ], ]; }