From 5c89bb8c6bb8b559a4a9debe6ba13cdaffe07345 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Tue, 17 Mar 2015 21:29:30 +0000 Subject: [PATCH] #1336 DDC-3622 - removing implicit cast from `string` to `CustomIdObject` in entity API (confusing) --- .../Models/CustomType/CustomIdObjectTypeChild.php | 8 ++------ .../Models/CustomType/CustomIdObjectTypeParent.php | 8 ++------ .../Tests/ORM/Functional/CustomIdObjectTypeTest.php | 11 ++++++----- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeChild.php b/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeChild.php index 0f0113d57..028a55c25 100644 --- a/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeChild.php +++ b/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeChild.php @@ -42,15 +42,11 @@ class CustomIdObjectTypeChild public $parent; /** - * @param CustomIdObject|string $id + * @param CustomIdObject $id * @param CustomIdObjectTypeParent $parent */ - public function __construct($id, CustomIdObjectTypeParent $parent) + public function __construct(CustomIdObject $id, CustomIdObjectTypeParent $parent) { - if (! $id instanceof CustomIdObject) { - $id = new CustomIdObject($id); - } - $this->id = $id; $this->parent = $parent; } diff --git a/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php b/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php index 02bebc475..3045c647b 100644 --- a/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php +++ b/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php @@ -43,14 +43,10 @@ class CustomIdObjectTypeParent public $children; /** - * @param CustomIdObject|string $id + * @param CustomIdObject $id */ - public function __construct($id) + public function __construct(CustomIdObject $id) { - if (! $id instanceof CustomIdObject) { - $id = new CustomIdObject($id); - } - $this->id = $id; $this->children = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/ORM/Functional/CustomIdObjectTypeTest.php b/tests/Doctrine/Tests/ORM/Functional/CustomIdObjectTypeTest.php index 9617644a9..2e7abf76c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/CustomIdObjectTypeTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/CustomIdObjectTypeTest.php @@ -19,6 +19,7 @@ namespace Doctrine\Tests\ORM\Functional; +use Doctrine\Tests\DbalTypes\CustomIdObject; use Doctrine\Tests\DbalTypes\CustomIdObjectType; use Doctrine\Tests\Models\CustomType\CustomIdObjectTypeChild; use Doctrine\Tests\Models\CustomType\CustomIdObjectTypeParent; @@ -42,7 +43,7 @@ class CustomIdObjectTypeTest extends OrmFunctionalTestCase public function testFindByCustomIdObject() { - $parent = new CustomIdObjectTypeParent('foo'); + $parent = new CustomIdObjectTypeParent(new CustomIdObject('foo')); $this->_em->persist($parent); $this->_em->flush(); @@ -58,9 +59,9 @@ class CustomIdObjectTypeTest extends OrmFunctionalTestCase */ public function testFetchJoinCustomIdObject() { - $parent = new CustomIdObjectTypeParent('foo'); + $parent = new CustomIdObjectTypeParent(new CustomIdObject('foo')); - $parent->children->add(new CustomIdObjectTypeChild('bar', $parent)); + $parent->children->add(new CustomIdObjectTypeChild(new CustomIdObject('bar'), $parent)); $this->_em->persist($parent); $this->_em->flush(); @@ -84,9 +85,9 @@ class CustomIdObjectTypeTest extends OrmFunctionalTestCase */ public function testFetchJoinWhereCustomIdObject() { - $parent = new CustomIdObjectTypeParent('foo'); + $parent = new CustomIdObjectTypeParent(new CustomIdObject('foo')); - $parent->children->add(new CustomIdObjectTypeChild('bar', $parent)); + $parent->children->add(new CustomIdObjectTypeChild(new CustomIdObject('bar'), $parent)); $this->_em->persist($parent); $this->_em->flush();