1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Zenstruck\Foundry\Tests\Fixtures\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
6
|
|
|
use Doctrine\Common\Collections\Collection; |
7
|
|
|
use Doctrine\ORM\Mapping as ORM; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @ORM\Entity |
11
|
|
|
* @ORM\Table(name="foos") |
12
|
|
|
*/ |
13
|
|
|
class Foo |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @ORM\Id |
17
|
|
|
* @ORM\GeneratedValue |
18
|
|
|
* @ORM\Column(type="integer") |
19
|
|
|
*/ |
20
|
|
|
private $id; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @ORM\OneToOne(targetEntity=Category::class, cascade={"persist", "remove"}) |
24
|
|
|
* @ORM\JoinColumn(nullable=false) |
25
|
|
|
*/ |
26
|
|
|
private $oneToOne; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @ORM\OneToMany(targetEntity=Category::class, mappedBy="foo") |
30
|
|
|
*/ |
31
|
|
|
private $oneToMany; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @ORM\ManyToOne(targetEntity=Category::class) |
35
|
|
|
* @ORM\JoinColumn(nullable=false) |
36
|
|
|
*/ |
37
|
|
|
private $manyToOne; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @ORM\ManyToMany(targetEntity=Category::class) |
41
|
|
|
*/ |
42
|
|
|
private $manyToMany; |
43
|
|
|
|
44
|
|
|
public function __construct() |
45
|
|
|
{ |
46
|
|
|
$this->oneToMany = new ArrayCollection(); |
47
|
|
|
$this->manyToMany = new ArrayCollection(); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function getId(): ?int |
51
|
|
|
{ |
52
|
|
|
return $this->id; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function getOneToOne(): ?Category |
56
|
|
|
{ |
57
|
|
|
return $this->oneToOne; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function setOneToOne(Category $oneToOne): self |
61
|
|
|
{ |
62
|
|
|
$this->oneToOne = $oneToOne; |
63
|
|
|
|
64
|
|
|
return $this; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return Collection|Category[] |
69
|
|
|
*/ |
70
|
|
|
public function getOneToMany(): Collection |
71
|
|
|
{ |
72
|
|
|
return $this->oneToMany; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function addOneToMany(Category $oneToMany): self |
76
|
|
|
{ |
77
|
|
|
if (!$this->oneToMany->contains($oneToMany)) { |
78
|
|
|
$this->oneToMany[] = $oneToMany; |
79
|
|
|
$oneToMany->setFoo($this); |
|
|
|
|
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
return $this; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function removeOneToMany(Category $oneToMany): self |
86
|
|
|
{ |
87
|
|
|
if ($this->oneToMany->removeElement($oneToMany)) { |
88
|
|
|
// set the owning side to null (unless already changed) |
89
|
|
|
if ($oneToMany->getFoo() === $this) { |
|
|
|
|
90
|
|
|
$oneToMany->setFoo(null); |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
return $this; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function getManyToOne(): ?Category |
98
|
|
|
{ |
99
|
|
|
return $this->manyToOne; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
public function setManyToOne(?Category $manyToOne): self |
103
|
|
|
{ |
104
|
|
|
$this->manyToOne = $manyToOne; |
105
|
|
|
|
106
|
|
|
return $this; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @return Collection|Category[] |
111
|
|
|
*/ |
112
|
|
|
public function getManyToMany(): Collection |
113
|
|
|
{ |
114
|
|
|
return $this->manyToMany; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
public function addManyToMany(Category $manyToMany): self |
118
|
|
|
{ |
119
|
|
|
if (!$this->manyToMany->contains($manyToMany)) { |
120
|
|
|
$this->manyToMany[] = $manyToMany; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
return $this; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
public function removeManyToMany(Category $manyToMany): self |
127
|
|
|
{ |
128
|
|
|
$this->manyToMany->removeElement($manyToMany); |
129
|
|
|
|
130
|
|
|
return $this; |
131
|
|
|
} |
132
|
|
|
} |
133
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.