1 | <?php |
||
9 | class Reader extends MetaProvider |
||
10 | { |
||
11 | /** |
||
12 | * @var \SimpleXMLElement |
||
13 | */ |
||
14 | protected $xml; |
||
15 | |||
16 | /** |
||
17 | * @var bool |
||
18 | */ |
||
19 | protected $isSingle = false; |
||
20 | |||
21 | /** |
||
22 | * @var array |
||
23 | */ |
||
24 | protected $suites = []; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $logFile; |
||
30 | |||
31 | /** |
||
32 | * @var array |
||
33 | */ |
||
34 | protected static $defaultSuite = [ |
||
35 | 'name' => '', |
||
36 | 'file' => '', |
||
37 | 'tests' => 0, |
||
38 | 'assertions' => 0, |
||
39 | 'failures' => 0, |
||
40 | 'errors' => 0, |
||
41 | 'skipped' => 0, |
||
42 | 'time' => 0, |
||
43 | ]; |
||
44 | |||
45 | 55 | public function __construct(string $logFile) |
|
59 | |||
60 | /** |
||
61 | * Returns whether or not this reader contains only |
||
62 | * a single suite. |
||
63 | * |
||
64 | * @return bool |
||
65 | */ |
||
66 | 2 | public function isSingleSuite(): bool |
|
70 | |||
71 | /** |
||
72 | * Return the Reader's collection |
||
73 | * of test suites. |
||
74 | * |
||
75 | * @return array |
||
76 | */ |
||
77 | 16 | public function getSuites(): array |
|
81 | |||
82 | /** |
||
83 | * Return an array that contains |
||
84 | * each suite's instant feedback. Since |
||
85 | * logs do not contain skipped or incomplete |
||
86 | * tests this array will contain any number of the following |
||
87 | * characters: .,F,E |
||
88 | * TODO: Update this, skipped was added in phpunit. |
||
89 | * |
||
90 | * @return array |
||
91 | */ |
||
92 | 12 | public function getFeedback(): array |
|
112 | |||
113 | /** |
||
114 | * Remove the JUnit xml file. |
||
115 | */ |
||
116 | 3 | public function removeLog() |
|
120 | |||
121 | /** |
||
122 | * Initialize the suite collection |
||
123 | * from the JUnit xml document. |
||
124 | */ |
||
125 | 55 | protected function init() |
|
133 | |||
134 | /** |
||
135 | * Uses an array of testcase nodes to build a suite. |
||
136 | * |
||
137 | * @param array $nodeArray an array of SimpleXMLElement nodes representing testcase elements |
||
138 | */ |
||
139 | 55 | protected function initSuiteFromCases(array $nodeArray) |
|
149 | |||
150 | /** |
||
151 | * Creates and adds a TestSuite based on the given |
||
152 | * suite properties and collection of test cases. |
||
153 | * |
||
154 | * @param $properties |
||
155 | * @param $testCases |
||
156 | */ |
||
157 | 44 | protected function addSuite($properties, array $testCases) |
|
163 | |||
164 | /** |
||
165 | * Fold an array of testcase nodes into a suite array. |
||
166 | * |
||
167 | * @param array $nodeArray an array of testcase nodes |
||
168 | * @param array $testCases an array reference. Individual testcases will be placed here. |
||
169 | * |
||
170 | * @return mixed |
||
171 | */ |
||
172 | 55 | protected function caseNodesToSuiteProperties(array $nodeArray, array &$testCases = []) |
|
190 | |||
191 | /** |
||
192 | * Return a collection of testcase nodes |
||
193 | * from the xml document. |
||
194 | * |
||
195 | * @return array |
||
196 | */ |
||
197 | 55 | protected function getCaseNodes(): array |
|
211 | |||
212 | /** |
||
213 | * Determine if this reader is a single suite |
||
214 | * and initialize the suite collection with the first |
||
215 | * suite. |
||
216 | */ |
||
217 | 55 | protected function initSuite() |
|
229 | } |
||
230 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.