Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
17 | class Template extends View |
||
18 | { |
||
19 | const TYPE = 'template'; |
||
20 | |||
21 | /** |
||
22 | * @var string |
||
23 | * |
||
24 | * @ORM\OneToMany(targetEntity="\Victoire\Bundle\CoreBundle\Entity\View", mappedBy="template") |
||
25 | */ |
||
26 | protected $inheritors; |
||
27 | |||
28 | /** |
||
29 | * @var string |
||
30 | * |
||
31 | * @ORM\Column(name="layout", type="string", length=255) |
||
32 | */ |
||
33 | protected $layout; |
||
34 | |||
35 | /** |
||
36 | * Construct. |
||
37 | **/ |
||
38 | public function __construct() |
||
45 | |||
46 | /** |
||
47 | * to string. |
||
48 | * |
||
49 | * @return string |
||
50 | **/ |
||
51 | public function __toString() |
||
55 | |||
56 | /** |
||
57 | * add page. |
||
58 | * |
||
59 | * @param BasePage $page |
||
60 | * |
||
61 | * @return Template |
||
62 | **/ |
||
63 | public function addPage(BasePage $page) |
||
70 | |||
71 | /** |
||
72 | * set page. |
||
73 | * |
||
74 | * @param array $pages |
||
75 | * |
||
76 | * @return Template |
||
77 | **/ |
||
78 | public function setPages(array $pages) |
||
86 | |||
87 | /** |
||
88 | * remove page. |
||
89 | * |
||
90 | * @param BasePage $page |
||
91 | * |
||
92 | * @return Template |
||
93 | **/ |
||
94 | public function removePage($page) |
||
100 | |||
101 | /** |
||
102 | * Get pages (all Pages having this object as Template). |
||
103 | * |
||
104 | * @return ArrayCollection |
||
105 | */ |
||
106 | public function getPages() |
||
110 | |||
111 | /** |
||
112 | * Set layout. |
||
113 | * |
||
114 | * @param string $layout |
||
115 | * |
||
116 | * @return Template |
||
117 | */ |
||
118 | public function setLayout($layout) |
||
124 | |||
125 | /** |
||
126 | * Get layout. |
||
127 | * |
||
128 | * @return string |
||
129 | */ |
||
130 | public function getLayout() |
||
134 | |||
135 | /** |
||
136 | * Set inheritors. |
||
137 | * |
||
138 | * @param string $inheritors |
||
139 | * |
||
140 | * @return Template |
||
141 | */ |
||
142 | public function setInheritors($inheritors) |
||
148 | |||
149 | /** |
||
150 | * Get inheritors (all Views having this object as Template). |
||
151 | * |
||
152 | * @return [View] |
||
153 | */ |
||
154 | public function getInheritors() |
||
158 | |||
159 | /** |
||
160 | * Get inheritors (all Templates having this object as Template). |
||
161 | * |
||
162 | * @return [Template] |
||
163 | */ |
||
164 | View Code Duplication | public function getTemplateInheritors() |
|
175 | |||
176 | /** |
||
177 | * @Assert\Callback(groups={"victoire"}) |
||
178 | * |
||
179 | * @param ExecutionContextInterface $context |
||
180 | */ |
||
181 | public function validate(ExecutionContextInterface $context) |
||
195 | } |
||
196 |
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..