1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Doctrine\Tests\ORM\Functional\Ticket; |
6
|
|
|
|
7
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
8
|
|
|
use Doctrine\ORM\Annotation as ORM; |
9
|
|
|
use Doctrine\Tests\OrmFunctionalTestCase; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* @group DDC-2780 |
13
|
|
|
*/ |
14
|
|
|
class DDC2780Test extends OrmFunctionalTestCase |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* {@inheritDoc} |
18
|
|
|
*/ |
19
|
|
|
protected function setUp() : void |
20
|
|
|
{ |
21
|
|
|
parent::setUp(); |
22
|
|
|
|
23
|
|
|
$this->schemaTool->createSchema( |
24
|
|
|
[ |
25
|
|
|
$this->em->getClassMetadata(DDC2780User::class), |
26
|
|
|
$this->em->getClassMetadata(DDC2780Project::class), |
27
|
|
|
] |
28
|
|
|
); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Verifies that IS [NOT] NULL can be used on join aliases |
33
|
|
|
*/ |
34
|
|
|
public function testIssue() : void |
35
|
|
|
{ |
36
|
|
|
$user = new DDC2780User(); |
37
|
|
|
$project = new DDC2780Project(); |
38
|
|
|
|
39
|
|
|
$user->project = $project; |
40
|
|
|
|
41
|
|
|
$this->em->persist($project); |
42
|
|
|
$this->em->persist($user); |
43
|
|
|
$this->em->flush(); |
44
|
|
|
$this->em->clear(); |
45
|
|
|
|
46
|
|
|
$result = $this->em->createQueryBuilder() |
47
|
|
|
->select('user') |
48
|
|
|
->from(DDC2780User::class, 'user') |
49
|
|
|
->leftJoin('user.project', 'project') |
50
|
|
|
->where('project IS NOT NULL') |
51
|
|
|
->getQuery() |
52
|
|
|
->getOneOrNullResult(); |
53
|
|
|
|
54
|
|
|
self::assertInstanceOf(DDC2780User::class, $result); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @ORM\Entity |
60
|
|
|
*/ |
61
|
|
|
class DDC2780User |
62
|
|
|
{ |
63
|
|
|
/** |
64
|
|
|
* @ORM\Id @ORM\GeneratedValue |
65
|
|
|
* @ORM\Column(type="integer") |
66
|
|
|
*/ |
67
|
|
|
public $id; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @ORM\ManyToOne(targetEntity=DDC2780Project::class) |
71
|
|
|
* |
72
|
|
|
* @var DDC2780Project |
73
|
|
|
*/ |
74
|
|
|
public $project; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** @ORM\Entity */ |
78
|
|
|
class DDC2780Project |
79
|
|
|
{ |
80
|
|
|
/** |
81
|
|
|
* @ORM\Id @ORM\GeneratedValue |
82
|
|
|
* @ORM\Column(type="integer") |
83
|
|
|
*/ |
84
|
|
|
public $id; |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @ORM\OneToMany(targetEntity=DDC2780User::class, mappedBy="project") |
88
|
|
|
* |
89
|
|
|
* @var DDC2780User[] |
90
|
|
|
*/ |
91
|
|
|
public $users; |
92
|
|
|
|
93
|
|
|
/** Constructor */ |
94
|
|
|
public function __construct() |
95
|
|
|
{ |
96
|
|
|
$this->users = new ArrayCollection(); |
|
|
|
|
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..