1 | <?php |
||
7 | class Parser |
||
8 | { |
||
9 | /** |
||
10 | * The path to the source file to parse. |
||
11 | * |
||
12 | * @var string |
||
13 | */ |
||
14 | private $path; |
||
15 | |||
16 | /** |
||
17 | * @var \ReflectionClass |
||
18 | */ |
||
19 | private $refl; |
||
20 | |||
21 | /** |
||
22 | * Matches a test method beginning with the conventional "test" |
||
23 | * word. |
||
24 | * |
||
25 | * @var string |
||
26 | */ |
||
27 | private static $testName = '/^test/'; |
||
28 | |||
29 | /** |
||
30 | * A pattern for matching test methods that use the @test annotation. |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | private static $testAnnotation = '/@test\b/'; |
||
35 | |||
36 | 31 | public function __construct(string $srcPath) |
|
55 | |||
56 | /** |
||
57 | * Returns the fully constructed class |
||
58 | * with methods or null if the class is abstract. |
||
59 | * |
||
60 | * @return null|ParsedClass |
||
61 | */ |
||
62 | 28 | public function getClass() |
|
73 | |||
74 | /** |
||
75 | * Return reflection name with null bytes stripped. |
||
76 | * |
||
77 | * @return string |
||
78 | */ |
||
79 | 28 | private function getCleanReflectionName(): string |
|
83 | |||
84 | /** |
||
85 | * Return all test methods present in the file. |
||
86 | * |
||
87 | * @return array |
||
88 | */ |
||
89 | 28 | private function getMethods(): array |
|
105 | |||
106 | /** |
||
107 | * Return the class name of the class contained |
||
108 | * in the file. |
||
109 | * |
||
110 | * @param mixed $filename |
||
111 | * @param mixed $previousDeclaredClasses |
||
112 | * |
||
113 | * @return string |
||
114 | */ |
||
115 | 30 | private function getClassName(string $filename, array $previousDeclaredClasses) |
|
131 | |||
132 | /** |
||
133 | * Search for the name of the unit test. |
||
134 | * |
||
135 | * @param string[] $classes |
||
136 | * @param string $filename |
||
137 | * |
||
138 | * @return string|null |
||
139 | */ |
||
140 | 30 | private function _searchForUnitTestClass(array $classes, string $filename) |
|
159 | |||
160 | /** |
||
161 | * @param $filename |
||
162 | * @param $className |
||
163 | * |
||
164 | * @return bool |
||
165 | */ |
||
166 | 28 | private function classNameMatchesFileName(string $filename, string $className): bool |
|
171 | |||
172 | 18 | private function invertSlashes(string $className): string |
|
176 | } |
||
177 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: