These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace gossi\swagger; |
||
3 | |||
4 | abstract class AbstractModel { |
||
5 | |||
6 | 6 | protected function export() { |
|
7 | 6 | $cols = func_get_args(); |
|
8 | |||
9 | // add cols |
||
10 | 6 | if (method_exists($this, 'hasRef') && $this->hasRef()) { |
|
11 | 5 | $cols = array_merge(['$ref'], $cols); |
|
12 | 5 | } |
|
13 | |||
14 | // flatten array |
||
15 | 6 | $fields = []; |
|
16 | array_walk_recursive($cols, function($a) use (&$fields) { $fields[] = $a; }); |
||
17 | |||
18 | 6 | $out = []; |
|
0 ignored issues
–
show
|
|||
19 | 6 | $refl = new \ReflectionClass(get_class($this)); |
|
20 | |||
21 | 6 | foreach ($fields as $field) { |
|
22 | 6 | if ($field == 'tags') { |
|
23 | 6 | $val = $this->exportTags(); |
|
24 | 6 | } else { |
|
25 | 6 | $prop = $refl->getProperty($field == '$ref' ? 'ref' : $field); |
|
26 | 6 | $prop->setAccessible(true); |
|
27 | 6 | $val = $prop->getValue($this); |
|
28 | |||
29 | 6 | if (method_exists($val, 'toArray')) { |
|
30 | 6 | $val = $val->toArray(); |
|
31 | 6 | } |
|
32 | } |
||
33 | |||
34 | 6 | if ($field == 'required' && is_bool($val) || !empty($val)) { |
|
35 | 6 | $out[$field] = $val; |
|
36 | 6 | } |
|
37 | 6 | } |
|
38 | |||
39 | 6 | if (method_exists($this, 'getExtensions')) { |
|
40 | 6 | $out = array_merge($out, $this->getExtensions()->toArray()); |
|
41 | 6 | } |
|
42 | |||
43 | 6 | return $out; |
|
44 | } |
||
45 | } |
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.