1 | <?php |
||
24 | abstract class Reason |
||
25 | { |
||
26 | // These integers are arbitrary. They may appear to follow some system, but they do not. Always use the constants. |
||
27 | const UNKNOWN = 0, |
||
28 | LIB_CLASS_ADDITION = 1, |
||
29 | LIB_CLASS_REMOVAL = 3, |
||
30 | LIB_CLASS_DEPRECATION = 6, |
||
31 | LIB_FUNCTION_ADDITION = 2, |
||
32 | LIB_FUNCTION_REMOVAL = 4, |
||
33 | LIB_FUNCTION_DEPRECATION = 5, |
||
34 | LIB_CONSTANT_ADDITION = 7, |
||
35 | LIB_CONSTANT_DEPRECATION = 8, |
||
36 | LIB_CONSTANT_REMOVAL = 9, |
||
37 | // 5.3 |
||
38 | GOTO_KEYWORD = 70, |
||
39 | JUMP_LABEL = 71, |
||
40 | NAMESPACE_DECLERATION = 72, |
||
41 | NAMESPACE_MAGIC_CONSTANT = 73, |
||
42 | NAMESPACE_IMPORT = 74, |
||
43 | NOWDOC_LITERAL = 75, |
||
44 | CALLSTATIC_MAGIC_METHOD = 76, |
||
45 | INVOKE_MAGIC_METHOD = 77, |
||
46 | CONST_KEYWORD_OUTSIDE_CLASS = 78, |
||
47 | CONST_KEYWORD_DOC_SYNTAX = 79, |
||
48 | SHORT_TERNARY = 80, |
||
49 | CLOSURE_DECLARATION = 81, |
||
50 | DYNAMIC_ACCESS_TO_STATIC = 82, |
||
51 | LATE_STATE_BINDING_USING_STATIC = 83, |
||
52 | NAMESPACE_SEPARATOR = 84, |
||
53 | DIR_MAGIC_CONSTANT = 85, |
||
54 | NEW_ASSIGN_BY_REF_DEP = 86, |
||
55 | // 5.4 |
||
56 | TRAIT_DEFINITION = 10, |
||
57 | TRAIT_USE = 11, |
||
58 | TRAIT_MAGIC_CONST = 12, |
||
59 | ARRAY_FUNCTION_DEREFERENCING = 13, |
||
60 | THIS_IN_CLOSURE = 14, |
||
61 | TYPEHINT_CALLABLE = 15, |
||
62 | INSTANT_CLASS_MEMBER_ACCESS = 16, |
||
63 | BINARY_NUMBER_DECLARATION = 17, |
||
64 | SHORT_ARRAY_DECLARATION = 18, |
||
65 | STATIC_CALL_BY_EXPRESSION = 19, |
||
66 | SHORT_ECHO_TAG = 20, |
||
67 | // 5.5 |
||
68 | GENERATOR_DEFINITION = 30, |
||
69 | TRY_CATCH_FINALLY = 31, |
||
70 | LIST_IN_FOREACH = 32, |
||
71 | EXPR_IN_EMPTY = 33, |
||
72 | ARRAY_OR_STRING_DEREFERENCING = 34, |
||
73 | CLASS_NAME_RESOLUTION = 35, |
||
74 | // 5.6 |
||
75 | VARIADIC_ARGUMENT = 50, |
||
76 | ARGUMENT_UNPACKING = 51, |
||
77 | CONSTANT_SCALAR_EXPRESSION = 52, |
||
78 | POW_OPERATOR = 53, |
||
79 | FUNCTION_IMPORT_USE = 54, |
||
80 | CONSTANT_IMPORT_USE = 55, |
||
81 | // 7.0 |
||
82 | RESERVED_CLASS_NAME = 100, |
||
83 | SOFT_RESERVED_NAME = 101, |
||
84 | PHP4_CONSTRUCTOR = 103, |
||
85 | COALESCE_OPERATOR = 104, |
||
86 | SPACESHIP_OPERATOR = 105, |
||
87 | RETURN_TYPE = 106, |
||
88 | YIELD_FROM = 107, |
||
89 | ANON_CLASS = 108, |
||
90 | NEW_ASSIGN_BY_REF_REM = 109, |
||
91 | STRICT_TYPE_DECLARE = 110; |
||
92 | |||
93 | /** |
||
94 | * @var array|null |
||
95 | */ |
||
96 | private static $reasonToVersion; |
||
97 | /** |
||
98 | * @var array|null |
||
99 | */ |
||
100 | private static $constantsCache; |
||
101 | |||
102 | /** |
||
103 | * Get version information from a reason. |
||
104 | * |
||
105 | * This static method may be used to get version information of a reason constant defined in Reason. |
||
106 | * If no matching version for a constant can be found an InvalidArgumentException will be thrown. |
||
107 | * |
||
108 | * This method may return a falseable string or bool(false). Use !== false to check for a valid returned version. |
||
109 | * If false is returned refer to the corresponding method on the class that returned the constant. |
||
110 | * |
||
111 | * @param int $reason One of the constants defined in RequirementReason |
||
112 | * @return string|false The required version or bool(false) |
||
113 | 118 | */ |
|
114 | public static function getVersionFromReason($reason) |
||
129 | |||
130 | /** |
||
131 | * Get the constant name from constant value |
||
132 | * |
||
133 | * @param int $value |
||
134 | * @return string The name of the constant or 'UNKNOWN' |
||
135 | 110 | */ |
|
136 | public static function getReasonNameFromValue($value) |
||
147 | |||
148 | /** |
||
149 | * Get a list of defined constants and their values. |
||
150 | * |
||
151 | * @return array |
||
152 | 112 | */ |
|
153 | public static function getReasonNames() |
||
168 | |||
169 | /** |
||
170 | * Clears the cached constant lists. |
||
171 | * |
||
172 | * May be useful to save memory or to force regeneration of the list in tests. |
||
173 | 8 | */ |
|
174 | public static function clear() |
||
179 | |||
180 | /** |
||
181 | * Map reasons to versions |
||
182 | * |
||
183 | * This method returns an array having the constants defined by this class as keys and their required |
||
184 | * php versions as values. |
||
185 | * |
||
186 | * @return array |
||
187 | 8 | */ |
|
188 | protected static function getReasonToVersionBaseValues() |
||
249 | |||
250 | /** |
||
251 | * @codeCoverageIgnore |
||
252 | */ |
||
253 | private function __construct() |
||
256 | } |
||
257 |