1 | <?php |
||
13 | class Tree implements Buildable, Extension |
||
14 | { |
||
15 | const MACRO_METHOD = 'tree'; |
||
16 | |||
17 | /** |
||
18 | * List of tree strategies available |
||
19 | * |
||
20 | * @var array |
||
21 | */ |
||
22 | private $strategies = [ |
||
23 | 'nested', |
||
24 | 'closure', |
||
25 | 'materializedPath', |
||
26 | ]; |
||
27 | |||
28 | /** |
||
29 | * @var ExtensibleClassMetadata |
||
30 | */ |
||
31 | protected $classMetadata; |
||
32 | |||
33 | /** |
||
34 | * @var string |
||
35 | */ |
||
36 | protected $strategy; |
||
37 | |||
38 | /** |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $left; |
||
42 | |||
43 | /** |
||
44 | * @var string |
||
45 | */ |
||
46 | protected $right; |
||
47 | |||
48 | /** |
||
49 | * @var string |
||
50 | */ |
||
51 | protected $level; |
||
52 | |||
53 | /** |
||
54 | * @var string |
||
55 | */ |
||
56 | protected $root; |
||
57 | |||
58 | /** |
||
59 | * @var bool |
||
60 | */ |
||
61 | protected $activateLocking = false; |
||
62 | |||
63 | /** |
||
64 | * @var int |
||
65 | */ |
||
66 | protected $lockingTimeout = 3; |
||
67 | |||
68 | /** |
||
69 | * @var string |
||
70 | */ |
||
71 | protected $closure; |
||
72 | |||
73 | /** |
||
74 | * @var bool |
||
75 | */ |
||
76 | private $autoComplete = false; |
||
77 | |||
78 | /** |
||
79 | * @param ExtensibleClassMetadata $classMetadata |
||
80 | * @param string $strategy |
||
81 | * @param bool $autoComplete |
||
82 | */ |
||
83 | 9 | public function __construct(ExtensibleClassMetadata $classMetadata, $strategy = 'nested', $autoComplete = false) |
|
89 | |||
90 | /** |
||
91 | * Enable extension |
||
92 | */ |
||
93 | 82 | public static function enable() |
|
119 | |||
120 | /** |
||
121 | * @param string $field |
||
122 | * @param string $type |
||
123 | * @param null $name |
||
124 | * @return $this |
||
125 | */ |
||
126 | 3 | public function root($field = 'root', $type = 'integer', $name = null) |
|
134 | |||
135 | /** |
||
136 | * @param string $field |
||
137 | * @param string $type |
||
138 | * @param null $name |
||
139 | * @return $this |
||
140 | */ |
||
141 | 3 | public function left($field = 'left', $type = 'integer', $name = null) |
|
149 | |||
150 | /** |
||
151 | * @param string $field |
||
152 | * @param string $type |
||
153 | * @param null $name |
||
154 | * @return $this |
||
155 | */ |
||
156 | 3 | public function right($field = 'right', $type = 'integer', $name = null) |
|
164 | |||
165 | /** |
||
166 | * @param string $field |
||
167 | * @param string $type |
||
168 | * @param null $name |
||
169 | * @return $this |
||
170 | */ |
||
171 | 3 | public function level($field = 'level', $type = 'integer', $name = null) |
|
179 | |||
180 | /** |
||
181 | * Execute the build process |
||
182 | */ |
||
183 | 6 | public function build() |
|
218 | |||
219 | /** |
||
220 | * Return the name of the actual extension. |
||
221 | * |
||
222 | * @return string |
||
223 | */ |
||
224 | 5 | public function getExtensionName() |
|
228 | |||
229 | /** |
||
230 | * @param bool $activateLocking |
||
231 | * @return Tree |
||
232 | */ |
||
233 | 1 | public function activateLocking($activateLocking = true) |
|
239 | |||
240 | /** |
||
241 | * @param string $strategy |
||
242 | * @return Tree |
||
243 | */ |
||
244 | 2 | public function strategy($strategy) |
|
250 | |||
251 | /** |
||
252 | * @param int $lockingTimeout |
||
253 | * @return Tree |
||
254 | */ |
||
255 | 2 | public function lockingTimeout($lockingTimeout) |
|
265 | |||
266 | /** |
||
267 | * @param string $closure |
||
268 | * @return Tree |
||
269 | */ |
||
270 | 1 | public function closure($closure) |
|
276 | |||
277 | /** |
||
278 | * @param $field |
||
279 | * @param $type |
||
280 | * @param $name |
||
281 | * @param bool $nullable |
||
282 | */ |
||
283 | 3 | private function mapField($field, $type, $name, $nullable = false) |
|
292 | } |
||
293 |
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.