1
0
mirror of synced 2024-12-05 03:06:05 +03:00

#1336 DDC-3622 - removing implicit cast from string to CustomIdObject in entity API (confusing)

This commit is contained in:
Marco Pivetta 2015-03-17 21:29:30 +00:00
parent 712b6a7a64
commit 5c89bb8c6b
3 changed files with 10 additions and 17 deletions

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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();