This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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\collections; |
||
3 | |||
4 | use gossi\swagger\Parameter; |
||
5 | use gossi\swagger\parts\RefPart; |
||
6 | use phootwork\collection\ArrayList; |
||
7 | use phootwork\collection\CollectionUtils; |
||
8 | use phootwork\lang\Arrayable; |
||
9 | use gossi\swagger\AbstractModel; |
||
10 | |||
11 | class Parameters extends AbstractModel implements Arrayable, \Iterator { |
||
12 | |||
13 | use RefPart; |
||
14 | |||
15 | /** @var ArrayList */ |
||
16 | private $parameters; |
||
17 | |||
18 | 13 | public function __construct($contents = []) { |
|
19 | 13 | $this->parse($contents === null ? [] : $contents); |
|
20 | 13 | } |
|
21 | |||
22 | 13 | private function parse($contents) { |
|
23 | 13 | $data = CollectionUtils::toMap($contents); |
|
24 | |||
25 | 13 | $this->parameters = new ArrayList(); |
|
26 | 13 | $this->parseRef($data); |
|
27 | |||
28 | 13 | if (!$this->hasRef()) { |
|
29 | 13 | foreach ($data as $param) { |
|
30 | 4 | $this->parameters->add(new Parameter($param)); |
|
31 | 13 | } |
|
32 | 13 | } |
|
33 | 13 | } |
|
34 | |||
35 | 9 | public function toArray() { |
|
36 | 9 | if ($this->hasRef()) { |
|
37 | 1 | return ['$ref' => $this->getRef()]; |
|
38 | } |
||
39 | |||
40 | 9 | return CollectionUtils::toArrayRecursive($this->parameters); |
|
41 | } |
||
42 | |||
43 | 1 | public function size() { |
|
44 | 1 | return $this->parameters->size(); |
|
45 | } |
||
46 | |||
47 | /** |
||
48 | * Searches whether a parameter with the given name exists |
||
49 | * |
||
50 | * @param string $name |
||
51 | * @return bool |
||
52 | */ |
||
53 | 1 | public function searchByName($name) { |
|
54 | return $this->parameters->search($name, function (Parameter $param, $name) { |
||
55 | 1 | return $param->getName() == $name; |
|
56 | 1 | }); |
|
57 | } |
||
58 | |||
59 | /** |
||
60 | * Returns parameter with the given name if it exists |
||
61 | * |
||
62 | * @param string $name |
||
63 | * @return Parameter|void |
||
64 | */ |
||
65 | 1 | public function findByName($name) { |
|
66 | 1 | foreach ($this->parameters as $param) { |
|
67 | 1 | if ($param->getName() == $name) { |
|
68 | 1 | return $param; |
|
69 | } |
||
70 | 1 | } |
|
71 | 1 | } |
|
72 | |||
73 | /** |
||
74 | * Searches for the parameter with the given name. Creates a parameter with the given name |
||
75 | * if none exists |
||
76 | * |
||
77 | * @param string $name |
||
78 | * @return Parameter |
||
79 | */ |
||
80 | public function getByName($name) { |
||
81 | $param = $this->findByName($name); |
||
82 | if (empty($param)) { |
||
83 | $param = new Parameter(); |
||
84 | $param->setName($name); |
||
85 | $this->parameters->add($param); |
||
86 | } |
||
87 | |||
88 | return $param; |
||
89 | } |
||
90 | |||
91 | /** |
||
92 | * Searches whether a parameter with the given unique combination exists |
||
93 | * |
||
94 | * @param string $name |
||
95 | * @param string $id |
||
0 ignored issues
–
show
|
|||
96 | * @return bool |
||
97 | */ |
||
98 | public function search($name, $in) { |
||
99 | 1 | return $this->parameters->search(function (Parameter $param) use ($name, $in) { |
|
100 | 1 | return $param->getIn() == $in && $param->getName() == $name; |
|
101 | 1 | }); |
|
102 | } |
||
103 | |||
104 | 1 | public function find($name, $in) { |
|
105 | 1 | foreach ($this->parameters as $param) { |
|
106 | 1 | if ($param->getIn() == $in && $param->getName() == $name) { |
|
107 | 1 | return $param; |
|
108 | } |
||
109 | 1 | } |
|
110 | 1 | } |
|
111 | |||
112 | 1 | public function get($name, $in) { |
|
113 | 1 | $param = $this->find($name, $in); |
|
114 | 1 | if (empty($param)) { |
|
115 | 1 | $param = new Parameter(); |
|
116 | 1 | $param->setName($name); |
|
117 | 1 | $param->setIn($in); |
|
118 | 1 | $this->parameters->add($param); |
|
119 | 1 | } |
|
120 | |||
121 | 1 | return $param; |
|
122 | } |
||
123 | |||
124 | /** |
||
125 | * Adds a parameter |
||
126 | * |
||
127 | * @param Parameter $param |
||
128 | */ |
||
129 | 1 | public function add(Parameter $param) { |
|
130 | 1 | $this->parameters->add($param); |
|
131 | 1 | } |
|
132 | |||
133 | /** |
||
134 | * Removes a parameter |
||
135 | * |
||
136 | * @param Parameter $param |
||
137 | */ |
||
138 | 1 | public function remove(Parameter $param) { |
|
139 | 1 | $this->parameters->remove($param); |
|
140 | 1 | } |
|
141 | |||
142 | /** |
||
143 | * Returns whether a given parameter exists |
||
144 | * |
||
145 | * @param Parameter $param |
||
146 | * @return bool |
||
147 | */ |
||
148 | 1 | public function contains(Parameter $param) { |
|
149 | 1 | return $this->parameters->contains($param); |
|
150 | } |
||
151 | |||
152 | public function current() { |
||
153 | return $this->parameters->current(); |
||
154 | } |
||
155 | |||
156 | public function key() { |
||
157 | return $this->parameters->key(); |
||
158 | } |
||
159 | |||
160 | public function next() { |
||
161 | return $this->parameters->next(); |
||
162 | } |
||
163 | |||
164 | public function rewind() { |
||
165 | return $this->parameters->rewind(); |
||
166 | } |
||
167 | |||
168 | public function valid() { |
||
169 | return $this->parameters->valid(); |
||
170 | } |
||
171 | } |
||
172 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.