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