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 | 97 |
| Code Lines | 41 |
| 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 |
||
| 200 | public function parentExceptionMappingDataProvider() |
||
| 201 | { |
||
| 202 | return [ |
||
| 203 | 'without $mapExceptionsToParent and only the exact class, maps to exact class' => [ |
||
| 204 | [ |
||
| 205 | ChildOfInvalidArgumentException::class => UserError::class, |
||
| 206 | ], |
||
| 207 | false, |
||
| 208 | [ |
||
| 209 | 'errors' => [ |
||
| 210 | [ |
||
| 211 | 'message' => 'Error with invalid argument exception', |
||
| 212 | ], |
||
| 213 | ], |
||
| 214 | ], |
||
| 215 | ], |
||
| 216 | 'without $mapExceptionsToParent and only the parent class, does not map to parent' => [ |
||
| 217 | [ |
||
| 218 | \InvalidArgumentException::class => UserWarning::class, |
||
| 219 | ], |
||
| 220 | false, |
||
| 221 | ChildOfInvalidArgumentException::class, |
||
| 222 | ], |
||
| 223 | 'with $mapExceptionsToParent and only the exact class' => [ |
||
| 224 | [ |
||
| 225 | ChildOfInvalidArgumentException::class => UserError::class, |
||
| 226 | ], |
||
| 227 | true, |
||
| 228 | [ |
||
| 229 | 'errors' => [ |
||
| 230 | [ |
||
| 231 | 'message' => 'Error with invalid argument exception', |
||
| 232 | ], |
||
| 233 | ], |
||
| 234 | ], |
||
| 235 | ], |
||
| 236 | 'with $mapExceptionsToParent and only the parent class' => [ |
||
| 237 | [ |
||
| 238 | \InvalidArgumentException::class => UserWarning::class, |
||
| 239 | ], |
||
| 240 | true, |
||
| 241 | [ |
||
| 242 | 'extensions' => [ |
||
| 243 | 'warnings' => [ |
||
| 244 | [ |
||
| 245 | 'message' => 'Error with invalid argument exception', |
||
| 246 | ], |
||
| 247 | ], |
||
| 248 | ], |
||
| 249 | ], |
||
| 250 | ], |
||
| 251 | 'with $mapExceptionsToParent and the exact class first matches exact class' => [ |
||
| 252 | [ |
||
| 253 | ChildOfInvalidArgumentException::class => UserError::class, |
||
| 254 | \InvalidArgumentException::class => UserWarning::class, |
||
| 255 | ], |
||
| 256 | true, |
||
| 257 | [ |
||
| 258 | 'errors' => [ |
||
| 259 | [ |
||
| 260 | 'message' => 'Error with invalid argument exception', |
||
| 261 | ], |
||
| 262 | ], |
||
| 263 | ], |
||
| 264 | ], |
||
| 265 | 'with $mapExceptionsToParent and the exact class first but parent maps to error' => [ |
||
| 266 | [ |
||
| 267 | ChildOfInvalidArgumentException::class => UserWarning::class, |
||
| 268 | \InvalidArgumentException::class => UserError::class, |
||
| 269 | ], |
||
| 270 | true, |
||
| 271 | [ |
||
| 272 | 'extensions' => [ |
||
| 273 | 'warnings' => [ |
||
| 274 | [ |
||
| 275 | 'message' => 'Error with invalid argument exception', |
||
| 276 | ], |
||
| 277 | ], |
||
| 278 | ], |
||
| 279 | ], |
||
| 280 | ], |
||
| 281 | 'with $mapExceptionsToParent and the parent class first still matches exact class' => [ |
||
| 282 | [ |
||
| 283 | \InvalidArgumentException::class => UserWarning::class, |
||
| 284 | ChildOfInvalidArgumentException::class => UserError::class, |
||
| 285 | ], |
||
| 286 | true, |
||
| 287 | [ |
||
| 288 | 'errors' => [ |
||
| 289 | [ |
||
| 290 | 'message' => 'Error with invalid argument exception', |
||
| 291 | ], |
||
| 292 | ], |
||
| 293 | ], |
||
| 294 | ], |
||
| 295 | ]; |
||
| 296 | } |
||
| 297 | } |
||
| 298 |
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: