We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 1 |
Paths | 1 |
Total Lines | 102 |
Code Lines | 44 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
210 | public function parentExceptionMappingDataProvider() |
||
211 | { |
||
212 | return [ |
||
213 | 'without $mapExceptionsToParent and only the exact class, maps to exact class' => [ |
||
214 | [ |
||
215 | ChildOfInvalidArgumentException::class => UserError::class, |
||
216 | ], |
||
217 | false, |
||
218 | [ |
||
219 | 'errors' => [ |
||
220 | [ |
||
221 | 'message' => 'Error with invalid argument exception', |
||
222 | ], |
||
223 | ], |
||
224 | ], |
||
225 | ], |
||
226 | 'without $mapExceptionsToParent and only the parent class, does not map to parent' => [ |
||
227 | [ |
||
228 | \InvalidArgumentException::class => UserWarning::class, |
||
229 | ], |
||
230 | false, |
||
231 | ChildOfInvalidArgumentException::class, |
||
232 | ], |
||
233 | 'with $mapExceptionsToParent and no classes' => [ |
||
234 | [], |
||
235 | true, |
||
236 | ChildOfInvalidArgumentException::class, |
||
237 | ], |
||
238 | 'with $mapExceptionsToParent and only the exact class' => [ |
||
239 | [ |
||
240 | ChildOfInvalidArgumentException::class => UserError::class, |
||
241 | ], |
||
242 | true, |
||
243 | [ |
||
244 | 'errors' => [ |
||
245 | [ |
||
246 | 'message' => 'Error with invalid argument exception', |
||
247 | ], |
||
248 | ], |
||
249 | ], |
||
250 | ], |
||
251 | 'with $mapExceptionsToParent and only the parent class' => [ |
||
252 | [ |
||
253 | \InvalidArgumentException::class => UserWarning::class, |
||
254 | ], |
||
255 | true, |
||
256 | [ |
||
257 | 'extensions' => [ |
||
258 | 'warnings' => [ |
||
259 | [ |
||
260 | 'message' => 'Error with invalid argument exception', |
||
261 | ], |
||
262 | ], |
||
263 | ], |
||
264 | ], |
||
265 | ], |
||
266 | 'with $mapExceptionsToParent and the exact class first matches exact class' => [ |
||
267 | [ |
||
268 | ChildOfInvalidArgumentException::class => UserError::class, |
||
269 | \InvalidArgumentException::class => UserWarning::class, |
||
270 | ], |
||
271 | true, |
||
272 | [ |
||
273 | 'errors' => [ |
||
274 | [ |
||
275 | 'message' => 'Error with invalid argument exception', |
||
276 | ], |
||
277 | ], |
||
278 | ], |
||
279 | ], |
||
280 | 'with $mapExceptionsToParent and the exact class first but parent maps to error' => [ |
||
281 | [ |
||
282 | ChildOfInvalidArgumentException::class => UserWarning::class, |
||
283 | \InvalidArgumentException::class => UserError::class, |
||
284 | ], |
||
285 | true, |
||
286 | [ |
||
287 | 'extensions' => [ |
||
288 | 'warnings' => [ |
||
289 | [ |
||
290 | 'message' => 'Error with invalid argument exception', |
||
291 | ], |
||
292 | ], |
||
293 | ], |
||
294 | ], |
||
295 | ], |
||
296 | 'with $mapExceptionsToParent and the parent class first still matches exact class' => [ |
||
297 | [ |
||
298 | \InvalidArgumentException::class => UserWarning::class, |
||
299 | ChildOfInvalidArgumentException::class => UserError::class, |
||
300 | ], |
||
301 | true, |
||
302 | [ |
||
303 | 'errors' => [ |
||
304 | [ |
||
305 | 'message' => 'Error with invalid argument exception', |
||
306 | ], |
||
307 | ], |
||
308 | ], |
||
309 | ], |
||
310 | ]; |
||
311 | } |
||
312 | } |
||
313 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: