1 | <?php |
||
12 | class StubHelper |
||
13 | { |
||
14 | private const PREFIXES = [ |
||
15 | 'static' => '::', |
||
16 | 'property' => '\\$' |
||
17 | ]; |
||
18 | |||
19 | private const NAME_TEMPLATE = '/^%s/'; |
||
20 | |||
21 | /** |
||
22 | * http://php.net/manual/en/language.variables.basics.php |
||
23 | * http://php.net/manual/en/functions.user-defined.php |
||
24 | */ |
||
25 | private const REGEX_NAME = '/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/'; |
||
26 | |||
27 | /** |
||
28 | * @param string $name |
||
29 | * @return bool |
||
30 | * |
||
31 | * @throws InvalidArgumentException |
||
32 | */ |
||
33 | 2 | public static function isStaticName(string $name): bool |
|
41 | |||
42 | /** |
||
43 | * @param string $name |
||
44 | * @return void |
||
45 | * |
||
46 | * @throws InvalidArgumentException |
||
47 | */ |
||
48 | 2 | public static function validateStaticName(string $name): void |
|
52 | |||
53 | /** |
||
54 | * @param string $name |
||
55 | * @return bool |
||
56 | * |
||
57 | * @throws InvalidArgumentException |
||
58 | */ |
||
59 | 91 | public static function isPropertyName(string $name): bool |
|
67 | |||
68 | /** |
||
69 | * @param string $name |
||
70 | * @param string $memberType |
||
71 | * @param string $subject |
||
72 | * @return bool |
||
73 | * @throws InvalidArgumentException |
||
74 | */ |
||
75 | 93 | private static function isName(string $name, string $memberType, string $subject): bool |
|
87 | |||
88 | /** |
||
89 | * @param string $name |
||
90 | * @return void |
||
91 | * |
||
92 | * @throws InvalidArgumentException |
||
93 | */ |
||
94 | 87 | public static function validatePropertyName(string $name): void |
|
98 | |||
99 | /** |
||
100 | * @param string $name |
||
101 | * @return bool |
||
102 | * |
||
103 | * @throws InvalidArgumentException |
||
104 | */ |
||
105 | 4 | public static function isMethodName(string $name): bool |
|
109 | |||
110 | /** |
||
111 | * @param string $name |
||
112 | * @return void |
||
113 | * |
||
114 | * @throws InvalidArgumentException |
||
115 | */ |
||
116 | 87 | public static function validateMethodName(string $name): void |
|
120 | |||
121 | /** |
||
122 | * @param string $name |
||
123 | * @return string |
||
124 | * |
||
125 | * @throws InvalidArgumentException |
||
126 | */ |
||
127 | 94 | public static function stripName(string $name): string |
|
133 | |||
134 | /** |
||
135 | * @param string $name |
||
136 | * @param array|null $prefixes |
||
137 | * @return string |
||
138 | */ |
||
139 | 104 | private static function doStripName(string $name, array $prefixes = null): string |
|
153 | |||
154 | /** |
||
155 | * @param string $name |
||
156 | * @param string|null $type |
||
157 | * @return void |
||
158 | * |
||
159 | * @throws InvalidArgumentException |
||
160 | */ |
||
161 | 104 | private static function validateName(string $name, string $type = null): void |
|
183 | } |
||
184 |