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 | 108 |
Code Lines | 50 |
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 |
||
244 | public function parentExceptionMappingDataProvider() |
||
245 | { |
||
246 | return [ |
||
247 | 'without $mapExceptionsToParent and only the exact class, maps to exact class' => [ |
||
248 | [ |
||
249 | ChildOfInvalidArgumentException::class => UserError::class, |
||
250 | ], |
||
251 | false, |
||
252 | [ |
||
253 | 'errors' => [ |
||
254 | [ |
||
255 | 'message' => 'Error with invalid argument exception', |
||
256 | 'category' => 'user', |
||
257 | ], |
||
258 | ], |
||
259 | ], |
||
260 | ], |
||
261 | 'without $mapExceptionsToParent and only the parent class, does not map to parent' => [ |
||
262 | [ |
||
263 | \InvalidArgumentException::class => UserWarning::class, |
||
264 | ], |
||
265 | false, |
||
266 | ChildOfInvalidArgumentException::class, |
||
267 | ], |
||
268 | 'with $mapExceptionsToParent and no classes' => [ |
||
269 | [], |
||
270 | true, |
||
271 | ChildOfInvalidArgumentException::class, |
||
272 | ], |
||
273 | 'with $mapExceptionsToParent and only the exact class' => [ |
||
274 | [ |
||
275 | ChildOfInvalidArgumentException::class => UserError::class, |
||
276 | ], |
||
277 | true, |
||
278 | [ |
||
279 | 'errors' => [ |
||
280 | [ |
||
281 | 'message' => 'Error with invalid argument exception', |
||
282 | 'category' => 'user', |
||
283 | ], |
||
284 | ], |
||
285 | ], |
||
286 | ], |
||
287 | 'with $mapExceptionsToParent and only the parent class' => [ |
||
288 | [ |
||
289 | \InvalidArgumentException::class => UserWarning::class, |
||
290 | ], |
||
291 | true, |
||
292 | [ |
||
293 | 'extensions' => [ |
||
294 | 'warnings' => [ |
||
295 | [ |
||
296 | 'message' => 'Error with invalid argument exception', |
||
297 | 'category' => 'user', |
||
298 | ], |
||
299 | ], |
||
300 | ], |
||
301 | ], |
||
302 | ], |
||
303 | 'with $mapExceptionsToParent and the exact class first matches exact class' => [ |
||
304 | [ |
||
305 | ChildOfInvalidArgumentException::class => UserError::class, |
||
306 | \InvalidArgumentException::class => UserWarning::class, |
||
307 | ], |
||
308 | true, |
||
309 | [ |
||
310 | 'errors' => [ |
||
311 | [ |
||
312 | 'message' => 'Error with invalid argument exception', |
||
313 | 'category' => 'user', |
||
314 | ], |
||
315 | ], |
||
316 | ], |
||
317 | ], |
||
318 | 'with $mapExceptionsToParent and the exact class first but parent maps to error' => [ |
||
319 | [ |
||
320 | ChildOfInvalidArgumentException::class => UserWarning::class, |
||
321 | \InvalidArgumentException::class => UserError::class, |
||
322 | ], |
||
323 | true, |
||
324 | [ |
||
325 | 'extensions' => [ |
||
326 | 'warnings' => [ |
||
327 | [ |
||
328 | 'message' => 'Error with invalid argument exception', |
||
329 | 'category' => 'user', |
||
330 | ], |
||
331 | ], |
||
332 | ], |
||
333 | ], |
||
334 | ], |
||
335 | 'with $mapExceptionsToParent and the parent class first still matches exact class' => [ |
||
336 | [ |
||
337 | \InvalidArgumentException::class => UserWarning::class, |
||
338 | ChildOfInvalidArgumentException::class => UserError::class, |
||
339 | ], |
||
340 | true, |
||
341 | [ |
||
342 | 'errors' => [ |
||
343 | [ |
||
344 | 'message' => 'Error with invalid argument exception', |
||
345 | 'category' => 'user', |
||
346 | ], |
||
347 | ], |
||
348 | ], |
||
349 | ], |
||
350 | ]; |
||
351 | } |
||
352 | } |
||
353 |
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: