1 | <?php |
||
10 | class FakePDOStatement extends PDOStatement { |
||
11 | use EventHandlerTrait; |
||
12 | |||
13 | /** @var array */ |
||
14 | private $attributes = null; |
||
15 | /** @var MethodNameGenerator */ |
||
16 | private $methodNameGenerator = null; |
||
17 | |||
18 | /** |
||
19 | * @param EventHandler $eventHandler |
||
20 | */ |
||
21 | public function __construct(EventHandler $eventHandler = null) { |
||
25 | |||
26 | /** |
||
27 | * @param array|null $bound_input_params |
||
28 | * @return bool |
||
29 | */ |
||
30 | public function execute($bound_input_params = NULL) { |
||
36 | |||
37 | /** |
||
38 | * @param int|null $fetch_style |
||
39 | * @param int $cursor_orientation |
||
40 | * @param int $cursor_offset |
||
41 | * @return mixed |
||
42 | */ |
||
43 | public function fetch($fetch_style = null, $cursor_orientation = PDO::FETCH_ORI_NEXT, $cursor_offset = 0) { |
||
49 | |||
50 | /** |
||
51 | * @param mixed $parameter |
||
52 | * @param mixed $variable |
||
53 | * @param int $data_type |
||
54 | * @param int|null $length |
||
55 | * @param int|null $driver_options |
||
56 | * @return bool|mixed |
||
57 | */ |
||
58 | public function bindParam($parameter, &$variable, $data_type = PDO::PARAM_STR, $length = null, $driver_options = null) { |
||
64 | |||
65 | /** |
||
66 | * @param mixed $column |
||
67 | * @param mixed $param |
||
68 | * @param int $type |
||
69 | * @param int $maxlen |
||
70 | * @param mixed $driverdata |
||
71 | * @return bool|void |
||
72 | */ |
||
73 | public function bindColumn($column, &$param, $type = null, $maxlen = null, $driverdata = null) { |
||
79 | |||
80 | /** |
||
81 | * @param mixed $parameter |
||
82 | * @param mixed $value |
||
83 | * @param int $data_type |
||
84 | * @return bool|mixed |
||
85 | */ |
||
86 | public function bindValue($parameter, $value, $data_type = PDO::PARAM_STR) { |
||
92 | |||
93 | /** |
||
94 | * @return int |
||
95 | */ |
||
96 | public function rowCount() { |
||
102 | |||
103 | /** |
||
104 | * @param int $column_number |
||
105 | * @return string |
||
106 | */ |
||
107 | public function fetchColumn($column_number = 0) { |
||
113 | |||
114 | /** |
||
115 | * @param mixed|null $how |
||
|
|||
116 | * @param mixed|null $class_name |
||
117 | * @param array|null $ctor_args |
||
118 | * @return array |
||
119 | */ |
||
120 | public function fetchAll(int $mode = PDO::FETCH_BOTH, mixed ...$args) { |
||
121 | $methodName = $this->methodNameGenerator->getQualifiedMethodName(__FUNCTION__); |
||
122 | return $this->invokeEventHandler($methodName, array(), function () { |
||
123 | return []; |
||
124 | }); |
||
125 | } |
||
126 | |||
127 | /** |
||
128 | * @param string $class_name |
||
129 | * @param array $ctor_args |
||
130 | * @return mixed |
||
131 | */ |
||
132 | public function fetchObject($class_name = NULL, $ctor_args = NULL) { |
||
138 | |||
139 | /** |
||
140 | * @return string |
||
141 | */ |
||
142 | public function errorCode() { |
||
148 | |||
149 | /** |
||
150 | * @return array |
||
151 | */ |
||
152 | public function errorInfo() { |
||
158 | |||
159 | /** |
||
160 | * @param int $attribute |
||
161 | * @return mixed |
||
162 | */ |
||
163 | public function getAttribute($attribute) { |
||
164 | $methodName = $this->methodNameGenerator->getQualifiedMethodName(__FUNCTION__); |
||
165 | return $this->invokeEventHandler($methodName, array($attribute), function ($attribute) { |
||
166 | $attribute = json_encode($attribute); |
||
167 | if(array_key_exists($attribute, $this->attributes)) { |
||
168 | return $this->attributes[$attribute]; |
||
169 | } |
||
170 | return null; |
||
171 | }); |
||
172 | } |
||
173 | |||
174 | /** |
||
175 | * @param int $attribute |
||
176 | * @param mixed $value |
||
177 | * @return bool |
||
178 | */ |
||
179 | public function setAttribute($attribute, $value) { |
||
187 | |||
188 | /** |
||
189 | * |
||
190 | */ |
||
191 | public function columnCount() { |
||
197 | |||
198 | /** |
||
199 | * @param int $column |
||
200 | * @return array |
||
201 | */ |
||
202 | public function getColumnMeta($column) { |
||
208 | |||
209 | /** |
||
210 | * @param int $mode |
||
211 | * @param array|null $params |
||
212 | * @return bool |
||
213 | */ |
||
214 | public function setFetchMode(int $mode, ...$args) { |
||
220 | |||
221 | /** |
||
222 | * @return bool |
||
223 | */ |
||
224 | public function nextRowset() { |
||
230 | |||
231 | /** |
||
232 | * @return bool |
||
233 | */ |
||
234 | public function closeCursor() { |
||
240 | |||
241 | /** |
||
242 | * @return bool |
||
243 | */ |
||
244 | public function debugDumpParams() { |
||
250 | } |
||
251 |
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.