1 | <?php |
||
24 | class CannotAddArgumentException extends RuntimeException |
||
25 | { |
||
26 | /** |
||
27 | * Code: The argument exists already. |
||
28 | */ |
||
29 | const EXISTS_ALREADY = 1; |
||
30 | |||
31 | /** |
||
32 | * Code: An argument was added after a multi-valued argument. |
||
33 | */ |
||
34 | const MULTI_VALUED_EXISTS = 2; |
||
35 | |||
36 | /** |
||
37 | * Code: A required argument was added after an optional argument. |
||
38 | */ |
||
39 | const REQUIRED_AFTER_OPTIONAL = 3; |
||
40 | |||
41 | /** |
||
42 | * Creates an exception with code {@link EXISTS_ALREADY}. |
||
43 | * |
||
44 | * @param string $name The argument name. |
||
45 | * @param Exception $cause The exception that caused this exception. |
||
|
|||
46 | * |
||
47 | * @return static The created exception. |
||
48 | */ |
||
49 | 2 | public static function existsAlready($name, Exception $cause = null) |
|
56 | |||
57 | /** |
||
58 | * Creates an exception with code {@link ADD_AFTER_MULTI_VALUED}. |
||
59 | * |
||
60 | * @param Exception $cause The exception that caused this exception. |
||
61 | * |
||
62 | * @return static The created exception. |
||
63 | */ |
||
64 | 4 | public static function cannotAddAfterMultiValued(Exception $cause = null) |
|
72 | |||
73 | /** |
||
74 | * Creates an exception with code {@link ADD_REQUIRED_AFTER_OPTIONAL}. |
||
75 | * |
||
76 | * @param Exception $cause The exception that caused this exception. |
||
77 | * |
||
78 | * @return static The created exception. |
||
79 | */ |
||
80 | 2 | public static function cannotAddRequiredAfterOptional(Exception $cause = null) |
|
88 | } |
||
89 |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.