These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\MenuBundle\Entity; |
||
4 | |||
5 | use Doctrine\Common\Collections\ArrayCollection; |
||
6 | use Doctrine\ORM\Mapping as ORM; |
||
7 | use Kunstmaan\AdminBundle\Entity\AbstractEntity; |
||
8 | use Symfony\Component\Validator\Constraints as Assert; |
||
9 | |||
10 | /** |
||
11 | * Class BaseMenu |
||
12 | * |
||
13 | * @ORM\MappedSuperclass() |
||
14 | */ |
||
15 | class BaseMenu extends AbstractEntity |
||
16 | { |
||
17 | /** |
||
18 | * @var string |
||
19 | * |
||
20 | * @ORM\Column(name="name", type="string", length=25, nullable=true) |
||
21 | * @Assert\NotBlank() |
||
22 | */ |
||
23 | protected $name; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | * |
||
28 | * @ORM\Column(name="locale", type="string", length=5, nullable=true) |
||
29 | * @Assert\NotBlank() |
||
30 | */ |
||
31 | protected $locale; |
||
32 | |||
33 | /** |
||
34 | * @var ArrayCollection |
||
35 | * |
||
36 | * @ORM\OneToMany(targetEntity="Kunstmaan\MenuBundle\Entity\MenuItem", mappedBy="menu", cascade={"persist", "remove"}, orphanRemoval=true) |
||
37 | */ |
||
38 | protected $items; |
||
39 | |||
40 | /** |
||
41 | * Constructor |
||
42 | */ |
||
43 | public function __construct() |
||
44 | { |
||
45 | $this->items = new ArrayCollection(); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * @return string |
||
50 | */ |
||
51 | public function getName() |
||
52 | { |
||
53 | return $this->name; |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * @param string $name |
||
58 | * |
||
59 | * @return Menu |
||
60 | */ |
||
61 | public function setName($name) |
||
62 | { |
||
63 | $this->name = $name; |
||
64 | |||
65 | return $this; |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * @return string |
||
70 | */ |
||
71 | public function getLocale() |
||
72 | { |
||
73 | return $this->locale; |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * @param string $locale |
||
78 | * |
||
79 | * @return Menu |
||
80 | */ |
||
81 | public function setLocale($locale) |
||
82 | { |
||
83 | $this->locale = $locale; |
||
84 | |||
85 | return $this; |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * @return ArrayCollection |
||
90 | */ |
||
91 | public function getItems() |
||
92 | { |
||
93 | return $this->items; |
||
94 | } |
||
95 | |||
96 | /** |
||
97 | * @param ArrayCollection $items |
||
98 | * |
||
99 | * @return Menu |
||
100 | */ |
||
101 | public function setItems($items) |
||
102 | { |
||
103 | $this->items = $items; |
||
104 | |||
105 | return $this; |
||
106 | } |
||
107 | |||
108 | /** |
||
109 | * @param MenuItem $item |
||
110 | */ |
||
111 | public function addItem(MenuItem $item) |
||
112 | { |
||
113 | $item->setMenu($this); |
||
0 ignored issues
–
show
|
|||
114 | |||
115 | $this->items->add($item); |
||
116 | } |
||
117 | |||
118 | /** |
||
119 | * @param MenuItem $item |
||
120 | */ |
||
121 | public function removeItem(MenuItem $item) |
||
122 | { |
||
123 | $this->items->removeElement($item); |
||
124 | } |
||
125 | } |
||
126 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.