1 | <?php |
||
24 | class CannotAddCommandException extends RuntimeException |
||
25 | { |
||
26 | /** |
||
27 | * Code: A command with the same name exists. |
||
28 | */ |
||
29 | const NAME_EXISTS = 1; |
||
30 | |||
31 | /** |
||
32 | * Code: An option with the same name exists. |
||
33 | */ |
||
34 | const OPTION_EXISTS = 2; |
||
35 | |||
36 | /** |
||
37 | * Code: The command name is empty. |
||
38 | */ |
||
39 | const NAME_EMPTY = 3; |
||
40 | |||
41 | /** |
||
42 | * Creates an exception for the code {@link NAME_EXISTS}. |
||
43 | * |
||
44 | * @param string $name The command name. |
||
45 | * @param Exception $cause The exception that caused this exception. |
||
|
|||
46 | * |
||
47 | * @return static The created exception. |
||
48 | */ |
||
49 | 6 | public static function nameExists($name, Exception $cause = null) |
|
50 | { |
||
51 | 6 | return new static(sprintf( |
|
52 | 6 | 'A command named "%s" exists already.', |
|
53 | $name |
||
54 | 6 | ), self::NAME_EXISTS, $cause); |
|
55 | } |
||
56 | |||
57 | /** |
||
58 | * Creates an exception for the code {@link OPTION_EXISTS}. |
||
59 | * |
||
60 | * @param string $name The command name. |
||
61 | * @param Exception $cause The exception that caused this exception. |
||
62 | * |
||
63 | * @return static The created exception. |
||
64 | */ |
||
65 | 2 | public static function optionExists($name, Exception $cause = null) |
|
66 | { |
||
67 | 2 | return new static(sprintf( |
|
68 | 2 | 'An option named "%s%s" exists already.', |
|
69 | 2 | strlen($name) > 1 ? '--' : '-', |
|
70 | $name |
||
71 | 2 | ), self::OPTION_EXISTS, $cause); |
|
72 | } |
||
73 | |||
74 | /** |
||
75 | * Creates an exception for the code {@link NAME_EMPTY}. |
||
76 | * |
||
77 | * @param Exception $cause The exception that caused this exception. |
||
78 | * |
||
79 | * @return static The created exception. |
||
80 | */ |
||
81 | 2 | public static function nameEmpty(Exception $cause = null) |
|
85 | } |
||
86 |
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.