1 | <?php |
||
4 | class Parser |
||
5 | { |
||
6 | /** |
||
7 | * The path to the source file to parse |
||
8 | * |
||
9 | * @var string |
||
10 | */ |
||
11 | private $path; |
||
12 | |||
13 | /** |
||
14 | * @var \ReflectionClass |
||
15 | */ |
||
16 | private $refl; |
||
17 | |||
18 | /** |
||
19 | * Matches a test method beginning with the conventional "test" |
||
20 | * word |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | private static $testName = '/^test/'; |
||
25 | |||
26 | /** |
||
27 | * A pattern for matching test methods that use the @test annotation |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | private static $testAnnotation = '/@test\b/'; |
||
32 | |||
33 | 31 | public function __construct($srcPath) |
|
52 | |||
53 | /** |
||
54 | * Returns the fully constructed class |
||
55 | * with methods or null if the class is abstract |
||
56 | * |
||
57 | * @return null|ParsedClass |
||
58 | */ |
||
59 | 28 | public function getClass() |
|
70 | |||
71 | /** |
||
72 | * Return reflection name with null bytes stripped |
||
73 | * |
||
74 | * @return string |
||
75 | */ |
||
76 | 28 | private function getCleanReflectionName() |
|
80 | |||
81 | /** |
||
82 | * Return all test methods present in the file |
||
83 | * |
||
84 | * @return array |
||
85 | */ |
||
86 | 28 | private function getMethods() |
|
100 | |||
101 | /** |
||
102 | * Return the class name of the class contained |
||
103 | * in the file |
||
104 | * |
||
105 | * @return string |
||
106 | */ |
||
107 | 30 | private function getClassName($filename, $previousDeclaredClasses) |
|
123 | |||
124 | /** |
||
125 | * Search for the name of the unit test |
||
126 | * @param string[] $classes |
||
127 | * @param string $filename |
||
128 | * @return string|null |
||
129 | */ |
||
130 | 30 | private function _searchForUnitTestClass(array $classes, $filename) { |
|
147 | |||
148 | /** |
||
149 | * @param $filename |
||
150 | * @param $className |
||
151 | * @return bool |
||
152 | */ |
||
153 | 28 | private function classNameMatchesFileName($filename, $className) |
|
158 | |||
159 | 18 | private function invertSlashes($className) |
|
163 | } |
||
164 |
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: