Completed
Push — master ( 52755b...6c4366 )
by smiley
02:13
created
vendor/phpunit/phpunit/src/Util/TestDox/ResultPrinter.php 1 patch
Indentation   +385 added lines, -385 removed lines patch added patch discarded remove patch
@@ -24,389 +24,389 @@
 block discarded – undo
24 24
  */
25 25
 abstract class ResultPrinter extends Printer implements TestListener
26 26
 {
27
-    /**
28
-     * @var NamePrettifier
29
-     */
30
-    protected $prettifier;
31
-
32
-    /**
33
-     * @var string
34
-     */
35
-    protected $testClass = '';
36
-
37
-    /**
38
-     * @var int
39
-     */
40
-    protected $testStatus;
41
-
42
-    /**
43
-     * @var array
44
-     */
45
-    protected $tests = [];
46
-
47
-    /**
48
-     * @var int
49
-     */
50
-    protected $successful = 0;
51
-
52
-    /**
53
-     * @var int
54
-     */
55
-    protected $warned = 0;
56
-
57
-    /**
58
-     * @var int
59
-     */
60
-    protected $failed = 0;
61
-
62
-    /**
63
-     * @var int
64
-     */
65
-    protected $risky = 0;
66
-
67
-    /**
68
-     * @var int
69
-     */
70
-    protected $skipped = 0;
71
-
72
-    /**
73
-     * @var int
74
-     */
75
-    protected $incomplete = 0;
76
-
77
-    /**
78
-     * @var string|null
79
-     */
80
-    protected $currentTestClassPrettified;
81
-
82
-    /**
83
-     * @var string|null
84
-     */
85
-    protected $currentTestMethodPrettified;
86
-
87
-    /**
88
-     * @var array
89
-     */
90
-    private $groups;
91
-
92
-    /**
93
-     * @var array
94
-     */
95
-    private $excludeGroups;
96
-
97
-    /**
98
-     * @param resource $out
99
-     * @param array    $groups
100
-     * @param array    $excludeGroups
101
-     */
102
-    public function __construct($out = null, array $groups = [], array $excludeGroups = [])
103
-    {
104
-        parent::__construct($out);
105
-
106
-        $this->groups        = $groups;
107
-        $this->excludeGroups = $excludeGroups;
108
-
109
-        $this->prettifier = new NamePrettifier;
110
-        $this->startRun();
111
-    }
112
-
113
-    /**
114
-     * Flush buffer and close output.
115
-     */
116
-    public function flush()
117
-    {
118
-        $this->doEndClass();
119
-        $this->endRun();
120
-
121
-        parent::flush();
122
-    }
123
-
124
-    /**
125
-     * An error occurred.
126
-     *
127
-     * @param Test       $test
128
-     * @param \Exception $e
129
-     * @param float      $time
130
-     */
131
-    public function addError(Test $test, \Exception $e, $time)
132
-    {
133
-        if (!$this->isOfInterest($test)) {
134
-            return;
135
-        }
136
-
137
-        $this->testStatus = BaseTestRunner::STATUS_ERROR;
138
-        $this->failed++;
139
-    }
140
-
141
-    /**
142
-     * A warning occurred.
143
-     *
144
-     * @param Test    $test
145
-     * @param Warning $e
146
-     * @param float   $time
147
-     */
148
-    public function addWarning(Test $test, Warning $e, $time)
149
-    {
150
-        if (!$this->isOfInterest($test)) {
151
-            return;
152
-        }
153
-
154
-        $this->testStatus = BaseTestRunner::STATUS_WARNING;
155
-        $this->warned++;
156
-    }
157
-
158
-    /**
159
-     * A failure occurred.
160
-     *
161
-     * @param Test                 $test
162
-     * @param AssertionFailedError $e
163
-     * @param float                $time
164
-     */
165
-    public function addFailure(Test $test, AssertionFailedError $e, $time)
166
-    {
167
-        if (!$this->isOfInterest($test)) {
168
-            return;
169
-        }
170
-
171
-        $this->testStatus = BaseTestRunner::STATUS_FAILURE;
172
-        $this->failed++;
173
-    }
174
-
175
-    /**
176
-     * Incomplete test.
177
-     *
178
-     * @param Test       $test
179
-     * @param \Exception $e
180
-     * @param float      $time
181
-     */
182
-    public function addIncompleteTest(Test $test, \Exception $e, $time)
183
-    {
184
-        if (!$this->isOfInterest($test)) {
185
-            return;
186
-        }
187
-
188
-        $this->testStatus = BaseTestRunner::STATUS_INCOMPLETE;
189
-        $this->incomplete++;
190
-    }
191
-
192
-    /**
193
-     * Risky test.
194
-     *
195
-     * @param Test       $test
196
-     * @param \Exception $e
197
-     * @param float      $time
198
-     */
199
-    public function addRiskyTest(Test $test, \Exception $e, $time)
200
-    {
201
-        if (!$this->isOfInterest($test)) {
202
-            return;
203
-        }
204
-
205
-        $this->testStatus = BaseTestRunner::STATUS_RISKY;
206
-        $this->risky++;
207
-    }
208
-
209
-    /**
210
-     * Skipped test.
211
-     *
212
-     * @param Test       $test
213
-     * @param \Exception $e
214
-     * @param float      $time
215
-     */
216
-    public function addSkippedTest(Test $test, \Exception $e, $time)
217
-    {
218
-        if (!$this->isOfInterest($test)) {
219
-            return;
220
-        }
221
-
222
-        $this->testStatus = BaseTestRunner::STATUS_SKIPPED;
223
-        $this->skipped++;
224
-    }
225
-
226
-    /**
227
-     * A testsuite started.
228
-     *
229
-     * @param TestSuite $suite
230
-     */
231
-    public function startTestSuite(TestSuite $suite)
232
-    {
233
-    }
234
-
235
-    /**
236
-     * A testsuite ended.
237
-     *
238
-     * @param TestSuite $suite
239
-     */
240
-    public function endTestSuite(TestSuite $suite)
241
-    {
242
-    }
243
-
244
-    /**
245
-     * A test started.
246
-     *
247
-     * @param Test $test
248
-     */
249
-    public function startTest(Test $test)
250
-    {
251
-        if (!$this->isOfInterest($test)) {
252
-            return;
253
-        }
254
-
255
-        $class = \get_class($test);
256
-
257
-        if ($this->testClass != $class) {
258
-            if ($this->testClass != '') {
259
-                $this->doEndClass();
260
-            }
261
-
262
-            $classAnnotations = \PHPUnit\Util\Test::parseTestMethodAnnotations($class);
263
-            if (isset($classAnnotations['class']['testdox'][0])) {
264
-                $this->currentTestClassPrettified = $classAnnotations['class']['testdox'][0];
265
-            } else {
266
-                $this->currentTestClassPrettified = $this->prettifier->prettifyTestClass($class);
267
-            }
268
-
269
-            $this->startClass($class);
270
-
271
-            $this->testClass = $class;
272
-            $this->tests     = [];
273
-        }
274
-
275
-        if ($test instanceof TestCase) {
276
-            $annotations = $test->getAnnotations();
277
-
278
-            if (isset($annotations['method']['testdox'][0])) {
279
-                $this->currentTestMethodPrettified = $annotations['method']['testdox'][0];
280
-            } else {
281
-                $this->currentTestMethodPrettified = $this->prettifier->prettifyTestMethod($test->getName(false));
282
-            }
283
-
284
-            if ($test->usesDataProvider()) {
285
-                $this->currentTestMethodPrettified .= ' ' . $test->dataDescription();
286
-            }
287
-        }
288
-
289
-        $this->testStatus = BaseTestRunner::STATUS_PASSED;
290
-    }
291
-
292
-    /**
293
-     * A test ended.
294
-     *
295
-     * @param Test  $test
296
-     * @param float $time
297
-     */
298
-    public function endTest(Test $test, $time)
299
-    {
300
-        if (!$this->isOfInterest($test)) {
301
-            return;
302
-        }
303
-
304
-        if (!isset($this->tests[$this->currentTestMethodPrettified])) {
305
-            if ($this->testStatus == BaseTestRunner::STATUS_PASSED) {
306
-                $this->tests[$this->currentTestMethodPrettified]['success'] = 1;
307
-                $this->tests[$this->currentTestMethodPrettified]['failure'] = 0;
308
-            } else {
309
-                $this->tests[$this->currentTestMethodPrettified]['success'] = 0;
310
-                $this->tests[$this->currentTestMethodPrettified]['failure'] = 1;
311
-            }
312
-        } else {
313
-            if ($this->testStatus == BaseTestRunner::STATUS_PASSED) {
314
-                $this->tests[$this->currentTestMethodPrettified]['success']++;
315
-            } else {
316
-                $this->tests[$this->currentTestMethodPrettified]['failure']++;
317
-            }
318
-        }
319
-
320
-        $this->currentTestClassPrettified  = null;
321
-        $this->currentTestMethodPrettified = null;
322
-    }
323
-
324
-    protected function doEndClass()
325
-    {
326
-        foreach ($this->tests as $name => $data) {
327
-            $this->onTest($name, $data['failure'] == 0);
328
-        }
329
-
330
-        $this->endClass($this->testClass);
331
-    }
332
-
333
-    /**
334
-     * Handler for 'start run' event.
335
-     */
336
-    protected function startRun()
337
-    {
338
-    }
339
-
340
-    /**
341
-     * Handler for 'start class' event.
342
-     *
343
-     * @param string $name
344
-     */
345
-    protected function startClass($name)
346
-    {
347
-    }
348
-
349
-    /**
350
-     * Handler for 'on test' event.
351
-     *
352
-     * @param string $name
353
-     * @param bool   $success
354
-     */
355
-    protected function onTest($name, $success = true)
356
-    {
357
-    }
358
-
359
-    /**
360
-     * Handler for 'end class' event.
361
-     *
362
-     * @param string $name
363
-     */
364
-    protected function endClass($name)
365
-    {
366
-    }
367
-
368
-    /**
369
-     * Handler for 'end run' event.
370
-     */
371
-    protected function endRun()
372
-    {
373
-    }
374
-
375
-    /**
376
-     * @param Test $test
377
-     *
378
-     * @return bool
379
-     */
380
-    private function isOfInterest(Test $test)
381
-    {
382
-        if (!$test instanceof TestCase) {
383
-            return false;
384
-        }
385
-
386
-        if ($test instanceof WarningTestCase) {
387
-            return false;
388
-        }
389
-
390
-        if (!empty($this->groups)) {
391
-            foreach ($test->getGroups() as $group) {
392
-                if (\in_array($group, $this->groups)) {
393
-                    return true;
394
-                }
395
-            }
396
-
397
-            return false;
398
-        }
399
-
400
-        if (!empty($this->excludeGroups)) {
401
-            foreach ($test->getGroups() as $group) {
402
-                if (\in_array($group, $this->excludeGroups)) {
403
-                    return false;
404
-                }
405
-            }
406
-
407
-            return true;
408
-        }
409
-
410
-        return true;
411
-    }
27
+	/**
28
+	 * @var NamePrettifier
29
+	 */
30
+	protected $prettifier;
31
+
32
+	/**
33
+	 * @var string
34
+	 */
35
+	protected $testClass = '';
36
+
37
+	/**
38
+	 * @var int
39
+	 */
40
+	protected $testStatus;
41
+
42
+	/**
43
+	 * @var array
44
+	 */
45
+	protected $tests = [];
46
+
47
+	/**
48
+	 * @var int
49
+	 */
50
+	protected $successful = 0;
51
+
52
+	/**
53
+	 * @var int
54
+	 */
55
+	protected $warned = 0;
56
+
57
+	/**
58
+	 * @var int
59
+	 */
60
+	protected $failed = 0;
61
+
62
+	/**
63
+	 * @var int
64
+	 */
65
+	protected $risky = 0;
66
+
67
+	/**
68
+	 * @var int
69
+	 */
70
+	protected $skipped = 0;
71
+
72
+	/**
73
+	 * @var int
74
+	 */
75
+	protected $incomplete = 0;
76
+
77
+	/**
78
+	 * @var string|null
79
+	 */
80
+	protected $currentTestClassPrettified;
81
+
82
+	/**
83
+	 * @var string|null
84
+	 */
85
+	protected $currentTestMethodPrettified;
86
+
87
+	/**
88
+	 * @var array
89
+	 */
90
+	private $groups;
91
+
92
+	/**
93
+	 * @var array
94
+	 */
95
+	private $excludeGroups;
96
+
97
+	/**
98
+	 * @param resource $out
99
+	 * @param array    $groups
100
+	 * @param array    $excludeGroups
101
+	 */
102
+	public function __construct($out = null, array $groups = [], array $excludeGroups = [])
103
+	{
104
+		parent::__construct($out);
105
+
106
+		$this->groups        = $groups;
107
+		$this->excludeGroups = $excludeGroups;
108
+
109
+		$this->prettifier = new NamePrettifier;
110
+		$this->startRun();
111
+	}
112
+
113
+	/**
114
+	 * Flush buffer and close output.
115
+	 */
116
+	public function flush()
117
+	{
118
+		$this->doEndClass();
119
+		$this->endRun();
120
+
121
+		parent::flush();
122
+	}
123
+
124
+	/**
125
+	 * An error occurred.
126
+	 *
127
+	 * @param Test       $test
128
+	 * @param \Exception $e
129
+	 * @param float      $time
130
+	 */
131
+	public function addError(Test $test, \Exception $e, $time)
132
+	{
133
+		if (!$this->isOfInterest($test)) {
134
+			return;
135
+		}
136
+
137
+		$this->testStatus = BaseTestRunner::STATUS_ERROR;
138
+		$this->failed++;
139
+	}
140
+
141
+	/**
142
+	 * A warning occurred.
143
+	 *
144
+	 * @param Test    $test
145
+	 * @param Warning $e
146
+	 * @param float   $time
147
+	 */
148
+	public function addWarning(Test $test, Warning $e, $time)
149
+	{
150
+		if (!$this->isOfInterest($test)) {
151
+			return;
152
+		}
153
+
154
+		$this->testStatus = BaseTestRunner::STATUS_WARNING;
155
+		$this->warned++;
156
+	}
157
+
158
+	/**
159
+	 * A failure occurred.
160
+	 *
161
+	 * @param Test                 $test
162
+	 * @param AssertionFailedError $e
163
+	 * @param float                $time
164
+	 */
165
+	public function addFailure(Test $test, AssertionFailedError $e, $time)
166
+	{
167
+		if (!$this->isOfInterest($test)) {
168
+			return;
169
+		}
170
+
171
+		$this->testStatus = BaseTestRunner::STATUS_FAILURE;
172
+		$this->failed++;
173
+	}
174
+
175
+	/**
176
+	 * Incomplete test.
177
+	 *
178
+	 * @param Test       $test
179
+	 * @param \Exception $e
180
+	 * @param float      $time
181
+	 */
182
+	public function addIncompleteTest(Test $test, \Exception $e, $time)
183
+	{
184
+		if (!$this->isOfInterest($test)) {
185
+			return;
186
+		}
187
+
188
+		$this->testStatus = BaseTestRunner::STATUS_INCOMPLETE;
189
+		$this->incomplete++;
190
+	}
191
+
192
+	/**
193
+	 * Risky test.
194
+	 *
195
+	 * @param Test       $test
196
+	 * @param \Exception $e
197
+	 * @param float      $time
198
+	 */
199
+	public function addRiskyTest(Test $test, \Exception $e, $time)
200
+	{
201
+		if (!$this->isOfInterest($test)) {
202
+			return;
203
+		}
204
+
205
+		$this->testStatus = BaseTestRunner::STATUS_RISKY;
206
+		$this->risky++;
207
+	}
208
+
209
+	/**
210
+	 * Skipped test.
211
+	 *
212
+	 * @param Test       $test
213
+	 * @param \Exception $e
214
+	 * @param float      $time
215
+	 */
216
+	public function addSkippedTest(Test $test, \Exception $e, $time)
217
+	{
218
+		if (!$this->isOfInterest($test)) {
219
+			return;
220
+		}
221
+
222
+		$this->testStatus = BaseTestRunner::STATUS_SKIPPED;
223
+		$this->skipped++;
224
+	}
225
+
226
+	/**
227
+	 * A testsuite started.
228
+	 *
229
+	 * @param TestSuite $suite
230
+	 */
231
+	public function startTestSuite(TestSuite $suite)
232
+	{
233
+	}
234
+
235
+	/**
236
+	 * A testsuite ended.
237
+	 *
238
+	 * @param TestSuite $suite
239
+	 */
240
+	public function endTestSuite(TestSuite $suite)
241
+	{
242
+	}
243
+
244
+	/**
245
+	 * A test started.
246
+	 *
247
+	 * @param Test $test
248
+	 */
249
+	public function startTest(Test $test)
250
+	{
251
+		if (!$this->isOfInterest($test)) {
252
+			return;
253
+		}
254
+
255
+		$class = \get_class($test);
256
+
257
+		if ($this->testClass != $class) {
258
+			if ($this->testClass != '') {
259
+				$this->doEndClass();
260
+			}
261
+
262
+			$classAnnotations = \PHPUnit\Util\Test::parseTestMethodAnnotations($class);
263
+			if (isset($classAnnotations['class']['testdox'][0])) {
264
+				$this->currentTestClassPrettified = $classAnnotations['class']['testdox'][0];
265
+			} else {
266
+				$this->currentTestClassPrettified = $this->prettifier->prettifyTestClass($class);
267
+			}
268
+
269
+			$this->startClass($class);
270
+
271
+			$this->testClass = $class;
272
+			$this->tests     = [];
273
+		}
274
+
275
+		if ($test instanceof TestCase) {
276
+			$annotations = $test->getAnnotations();
277
+
278
+			if (isset($annotations['method']['testdox'][0])) {
279
+				$this->currentTestMethodPrettified = $annotations['method']['testdox'][0];
280
+			} else {
281
+				$this->currentTestMethodPrettified = $this->prettifier->prettifyTestMethod($test->getName(false));
282
+			}
283
+
284
+			if ($test->usesDataProvider()) {
285
+				$this->currentTestMethodPrettified .= ' ' . $test->dataDescription();
286
+			}
287
+		}
288
+
289
+		$this->testStatus = BaseTestRunner::STATUS_PASSED;
290
+	}
291
+
292
+	/**
293
+	 * A test ended.
294
+	 *
295
+	 * @param Test  $test
296
+	 * @param float $time
297
+	 */
298
+	public function endTest(Test $test, $time)
299
+	{
300
+		if (!$this->isOfInterest($test)) {
301
+			return;
302
+		}
303
+
304
+		if (!isset($this->tests[$this->currentTestMethodPrettified])) {
305
+			if ($this->testStatus == BaseTestRunner::STATUS_PASSED) {
306
+				$this->tests[$this->currentTestMethodPrettified]['success'] = 1;
307
+				$this->tests[$this->currentTestMethodPrettified]['failure'] = 0;
308
+			} else {
309
+				$this->tests[$this->currentTestMethodPrettified]['success'] = 0;
310
+				$this->tests[$this->currentTestMethodPrettified]['failure'] = 1;
311
+			}
312
+		} else {
313
+			if ($this->testStatus == BaseTestRunner::STATUS_PASSED) {
314
+				$this->tests[$this->currentTestMethodPrettified]['success']++;
315
+			} else {
316
+				$this->tests[$this->currentTestMethodPrettified]['failure']++;
317
+			}
318
+		}
319
+
320
+		$this->currentTestClassPrettified  = null;
321
+		$this->currentTestMethodPrettified = null;
322
+	}
323
+
324
+	protected function doEndClass()
325
+	{
326
+		foreach ($this->tests as $name => $data) {
327
+			$this->onTest($name, $data['failure'] == 0);
328
+		}
329
+
330
+		$this->endClass($this->testClass);
331
+	}
332
+
333
+	/**
334
+	 * Handler for 'start run' event.
335
+	 */
336
+	protected function startRun()
337
+	{
338
+	}
339
+
340
+	/**
341
+	 * Handler for 'start class' event.
342
+	 *
343
+	 * @param string $name
344
+	 */
345
+	protected function startClass($name)
346
+	{
347
+	}
348
+
349
+	/**
350
+	 * Handler for 'on test' event.
351
+	 *
352
+	 * @param string $name
353
+	 * @param bool   $success
354
+	 */
355
+	protected function onTest($name, $success = true)
356
+	{
357
+	}
358
+
359
+	/**
360
+	 * Handler for 'end class' event.
361
+	 *
362
+	 * @param string $name
363
+	 */
364
+	protected function endClass($name)
365
+	{
366
+	}
367
+
368
+	/**
369
+	 * Handler for 'end run' event.
370
+	 */
371
+	protected function endRun()
372
+	{
373
+	}
374
+
375
+	/**
376
+	 * @param Test $test
377
+	 *
378
+	 * @return bool
379
+	 */
380
+	private function isOfInterest(Test $test)
381
+	{
382
+		if (!$test instanceof TestCase) {
383
+			return false;
384
+		}
385
+
386
+		if ($test instanceof WarningTestCase) {
387
+			return false;
388
+		}
389
+
390
+		if (!empty($this->groups)) {
391
+			foreach ($test->getGroups() as $group) {
392
+				if (\in_array($group, $this->groups)) {
393
+					return true;
394
+				}
395
+			}
396
+
397
+			return false;
398
+		}
399
+
400
+		if (!empty($this->excludeGroups)) {
401
+			foreach ($test->getGroups() as $group) {
402
+				if (\in_array($group, $this->excludeGroups)) {
403
+					return false;
404
+				}
405
+			}
406
+
407
+			return true;
408
+		}
409
+
410
+		return true;
411
+	}
412 412
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Util/Printer.php 1 patch
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -16,131 +16,131 @@
 block discarded – undo
16 16
  */
17 17
 class Printer
18 18
 {
19
-    /**
20
-     * If true, flush output after every write.
21
-     *
22
-     * @var bool
23
-     */
24
-    protected $autoFlush = false;
25
-
26
-    /**
27
-     * @var resource
28
-     */
29
-    protected $out;
30
-
31
-    /**
32
-     * @var string
33
-     */
34
-    protected $outTarget;
35
-
36
-    /**
37
-     * Constructor.
38
-     *
39
-     * @param mixed $out
40
-     *
41
-     * @throws Exception
42
-     */
43
-    public function __construct($out = null)
44
-    {
45
-        if ($out !== null) {
46
-            if (\is_string($out)) {
47
-                if (\strpos($out, 'socket://') === 0) {
48
-                    $out = \explode(':', \str_replace('socket://', '', $out));
49
-
50
-                    if (\count($out) != 2) {
51
-                        throw new Exception;
52
-                    }
53
-
54
-                    $this->out = \fsockopen($out[0], $out[1]);
55
-                } else {
56
-                    if (\strpos($out, 'php://') === false && !\is_dir(\dirname($out))) {
57
-                        \mkdir(\dirname($out), 0777, true);
58
-                    }
59
-
60
-                    $this->out = \fopen($out, 'wt');
61
-                }
62
-
63
-                $this->outTarget = $out;
64
-            } else {
65
-                $this->out = $out;
66
-            }
67
-        }
68
-    }
69
-
70
-    /**
71
-     * Flush buffer and close output if it's not to a PHP stream
72
-     */
73
-    public function flush()
74
-    {
75
-        if ($this->out && \strncmp($this->outTarget, 'php://', 6) !== 0) {
76
-            \fclose($this->out);
77
-        }
78
-    }
79
-
80
-    /**
81
-     * Performs a safe, incremental flush.
82
-     *
83
-     * Do not confuse this function with the flush() function of this class,
84
-     * since the flush() function may close the file being written to, rendering
85
-     * the current object no longer usable.
86
-     */
87
-    public function incrementalFlush()
88
-    {
89
-        if ($this->out) {
90
-            \fflush($this->out);
91
-        } else {
92
-            \flush();
93
-        }
94
-    }
95
-
96
-    /**
97
-     * @param string $buffer
98
-     */
99
-    public function write($buffer)
100
-    {
101
-        if ($this->out) {
102
-            \fwrite($this->out, $buffer);
103
-
104
-            if ($this->autoFlush) {
105
-                $this->incrementalFlush();
106
-            }
107
-        } else {
108
-            if (PHP_SAPI != 'cli' && PHP_SAPI != 'phpdbg') {
109
-                $buffer = \htmlspecialchars($buffer, ENT_SUBSTITUTE);
110
-            }
111
-
112
-            print $buffer;
113
-
114
-            if ($this->autoFlush) {
115
-                $this->incrementalFlush();
116
-            }
117
-        }
118
-    }
119
-
120
-    /**
121
-     * Check auto-flush mode.
122
-     *
123
-     * @return bool
124
-     */
125
-    public function getAutoFlush()
126
-    {
127
-        return $this->autoFlush;
128
-    }
129
-
130
-    /**
131
-     * Set auto-flushing mode.
132
-     *
133
-     * If set, *incremental* flushes will be done after each write. This should
134
-     * not be confused with the different effects of this class' flush() method.
135
-     *
136
-     * @param bool $autoFlush
137
-     */
138
-    public function setAutoFlush($autoFlush)
139
-    {
140
-        if (\is_bool($autoFlush)) {
141
-            $this->autoFlush = $autoFlush;
142
-        } else {
143
-            throw InvalidArgumentHelper::factory(1, 'boolean');
144
-        }
145
-    }
19
+	/**
20
+	 * If true, flush output after every write.
21
+	 *
22
+	 * @var bool
23
+	 */
24
+	protected $autoFlush = false;
25
+
26
+	/**
27
+	 * @var resource
28
+	 */
29
+	protected $out;
30
+
31
+	/**
32
+	 * @var string
33
+	 */
34
+	protected $outTarget;
35
+
36
+	/**
37
+	 * Constructor.
38
+	 *
39
+	 * @param mixed $out
40
+	 *
41
+	 * @throws Exception
42
+	 */
43
+	public function __construct($out = null)
44
+	{
45
+		if ($out !== null) {
46
+			if (\is_string($out)) {
47
+				if (\strpos($out, 'socket://') === 0) {
48
+					$out = \explode(':', \str_replace('socket://', '', $out));
49
+
50
+					if (\count($out) != 2) {
51
+						throw new Exception;
52
+					}
53
+
54
+					$this->out = \fsockopen($out[0], $out[1]);
55
+				} else {
56
+					if (\strpos($out, 'php://') === false && !\is_dir(\dirname($out))) {
57
+						\mkdir(\dirname($out), 0777, true);
58
+					}
59
+
60
+					$this->out = \fopen($out, 'wt');
61
+				}
62
+
63
+				$this->outTarget = $out;
64
+			} else {
65
+				$this->out = $out;
66
+			}
67
+		}
68
+	}
69
+
70
+	/**
71
+	 * Flush buffer and close output if it's not to a PHP stream
72
+	 */
73
+	public function flush()
74
+	{
75
+		if ($this->out && \strncmp($this->outTarget, 'php://', 6) !== 0) {
76
+			\fclose($this->out);
77
+		}
78
+	}
79
+
80
+	/**
81
+	 * Performs a safe, incremental flush.
82
+	 *
83
+	 * Do not confuse this function with the flush() function of this class,
84
+	 * since the flush() function may close the file being written to, rendering
85
+	 * the current object no longer usable.
86
+	 */
87
+	public function incrementalFlush()
88
+	{
89
+		if ($this->out) {
90
+			\fflush($this->out);
91
+		} else {
92
+			\flush();
93
+		}
94
+	}
95
+
96
+	/**
97
+	 * @param string $buffer
98
+	 */
99
+	public function write($buffer)
100
+	{
101
+		if ($this->out) {
102
+			\fwrite($this->out, $buffer);
103
+
104
+			if ($this->autoFlush) {
105
+				$this->incrementalFlush();
106
+			}
107
+		} else {
108
+			if (PHP_SAPI != 'cli' && PHP_SAPI != 'phpdbg') {
109
+				$buffer = \htmlspecialchars($buffer, ENT_SUBSTITUTE);
110
+			}
111
+
112
+			print $buffer;
113
+
114
+			if ($this->autoFlush) {
115
+				$this->incrementalFlush();
116
+			}
117
+		}
118
+	}
119
+
120
+	/**
121
+	 * Check auto-flush mode.
122
+	 *
123
+	 * @return bool
124
+	 */
125
+	public function getAutoFlush()
126
+	{
127
+		return $this->autoFlush;
128
+	}
129
+
130
+	/**
131
+	 * Set auto-flushing mode.
132
+	 *
133
+	 * If set, *incremental* flushes will be done after each write. This should
134
+	 * not be confused with the different effects of this class' flush() method.
135
+	 *
136
+	 * @param bool $autoFlush
137
+	 */
138
+	public function setAutoFlush($autoFlush)
139
+	{
140
+		if (\is_bool($autoFlush)) {
141
+			$this->autoFlush = $autoFlush;
142
+		} else {
143
+			throw InvalidArgumentHelper::factory(1, 'boolean');
144
+		}
145
+	}
146 146
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Util/Configuration.php 1 patch
Indentation   +1052 added lines, -1052 removed lines patch added patch discarded remove patch
@@ -150,1059 +150,1059 @@
 block discarded – undo
150 150
  */
151 151
 class Configuration
152 152
 {
153
-    const TEST_SUITE_FILTER_SEPARATOR = ',';
154
-
155
-    private static $instances = [];
156
-
157
-    protected $document;
158
-    protected $xpath;
159
-    protected $filename;
160
-
161
-    /**
162
-     * Loads a PHPUnit configuration file.
163
-     *
164
-     * @param string $filename
165
-     */
166
-    protected function __construct($filename)
167
-    {
168
-        $this->filename = $filename;
169
-        $this->document = Xml::loadFile($filename, false, true, true);
170
-        $this->xpath    = new DOMXPath($this->document);
171
-    }
172
-
173
-    final private function __clone()
174
-    {
175
-    }
176
-
177
-    /**
178
-     * Returns a PHPUnit configuration object.
179
-     *
180
-     * @param string $filename
181
-     *
182
-     * @return Configuration
183
-     */
184
-    public static function getInstance($filename)
185
-    {
186
-        $realpath = \realpath($filename);
187
-
188
-        if ($realpath === false) {
189
-            throw new Exception(
190
-                \sprintf(
191
-                    'Could not read "%s".',
192
-                    $filename
193
-                )
194
-            );
195
-        }
196
-
197
-        if (!isset(self::$instances[$realpath])) {
198
-            self::$instances[$realpath] = new self($realpath);
199
-        }
200
-
201
-        return self::$instances[$realpath];
202
-    }
203
-
204
-    /**
205
-     * Returns the realpath to the configuration file.
206
-     *
207
-     * @return string
208
-     */
209
-    public function getFilename()
210
-    {
211
-        return $this->filename;
212
-    }
213
-
214
-    /**
215
-     * Returns the configuration for SUT filtering.
216
-     *
217
-     * @return array
218
-     */
219
-    public function getFilterConfiguration()
220
-    {
221
-        $addUncoveredFilesFromWhitelist     = true;
222
-        $processUncoveredFilesFromWhitelist = false;
223
-
224
-        $tmp = $this->xpath->query('filter/whitelist');
225
-
226
-        if ($tmp->length == 0) {
227
-            return [
228
-                'whitelist' => [
229
-                    'addUncoveredFilesFromWhitelist'     => $addUncoveredFilesFromWhitelist,
230
-                    'processUncoveredFilesFromWhitelist' => $processUncoveredFilesFromWhitelist,
231
-                    'include'                            => [
232
-                        'directory' => [],
233
-                        'file'      => []
234
-                    ],
235
-                    'exclude' => [
236
-                        'directory' => [],
237
-                        'file'      => []
238
-                    ]
239
-                ]
240
-            ];
241
-        }
242
-
243
-        if ($tmp->length == 1) {
244
-            if ($tmp->item(0)->hasAttribute('addUncoveredFilesFromWhitelist')) {
245
-                $addUncoveredFilesFromWhitelist = $this->getBoolean(
246
-                    (string) $tmp->item(0)->getAttribute(
247
-                        'addUncoveredFilesFromWhitelist'
248
-                    ),
249
-                    true
250
-                );
251
-            }
252
-
253
-            if ($tmp->item(0)->hasAttribute('processUncoveredFilesFromWhitelist')) {
254
-                $processUncoveredFilesFromWhitelist = $this->getBoolean(
255
-                    (string) $tmp->item(0)->getAttribute(
256
-                        'processUncoveredFilesFromWhitelist'
257
-                    ),
258
-                    false
259
-                );
260
-            }
261
-        }
262
-
263
-        return [
264
-            'whitelist' => [
265
-                'addUncoveredFilesFromWhitelist'     => $addUncoveredFilesFromWhitelist,
266
-                'processUncoveredFilesFromWhitelist' => $processUncoveredFilesFromWhitelist,
267
-                'include'                            => [
268
-                    'directory' => $this->readFilterDirectories(
269
-                        'filter/whitelist/directory'
270
-                    ),
271
-                    'file' => $this->readFilterFiles(
272
-                        'filter/whitelist/file'
273
-                    )
274
-                ],
275
-                'exclude' => [
276
-                    'directory' => $this->readFilterDirectories(
277
-                        'filter/whitelist/exclude/directory'
278
-                    ),
279
-                    'file' => $this->readFilterFiles(
280
-                        'filter/whitelist/exclude/file'
281
-                    )
282
-                ]
283
-            ]
284
-        ];
285
-    }
286
-
287
-    /**
288
-     * Returns the configuration for groups.
289
-     *
290
-     * @return array
291
-     */
292
-    public function getGroupConfiguration()
293
-    {
294
-        return $this->parseGroupConfiguration('groups');
295
-    }
296
-
297
-    /**
298
-     * Returns the configuration for testdox groups.
299
-     *
300
-     * @return array
301
-     */
302
-    public function getTestdoxGroupConfiguration()
303
-    {
304
-        return $this->parseGroupConfiguration('testdoxGroups');
305
-    }
306
-
307
-    /**
308
-     * @param string $root
309
-     *
310
-     * @return array
311
-     */
312
-    private function parseGroupConfiguration($root)
313
-    {
314
-        $groups = [
315
-            'include' => [],
316
-            'exclude' => []
317
-        ];
318
-
319
-        foreach ($this->xpath->query($root . '/include/group') as $group) {
320
-            $groups['include'][] = (string) $group->textContent;
321
-        }
322
-
323
-        foreach ($this->xpath->query($root . '/exclude/group') as $group) {
324
-            $groups['exclude'][] = (string) $group->textContent;
325
-        }
326
-
327
-        return $groups;
328
-    }
329
-
330
-    /**
331
-     * Returns the configuration for listeners.
332
-     *
333
-     * @return array
334
-     */
335
-    public function getListenerConfiguration()
336
-    {
337
-        $result = [];
338
-
339
-        foreach ($this->xpath->query('listeners/listener') as $listener) {
340
-            $class     = (string) $listener->getAttribute('class');
341
-            $file      = '';
342
-            $arguments = [];
343
-
344
-            if ($listener->getAttribute('file')) {
345
-                $file = $this->toAbsolutePath(
346
-                    (string) $listener->getAttribute('file'),
347
-                    true
348
-                );
349
-            }
350
-
351
-            foreach ($listener->childNodes as $node) {
352
-                if ($node instanceof DOMElement && $node->tagName == 'arguments') {
353
-                    foreach ($node->childNodes as $argument) {
354
-                        if ($argument instanceof DOMElement) {
355
-                            if ($argument->tagName == 'file' || $argument->tagName == 'directory') {
356
-                                $arguments[] = $this->toAbsolutePath((string) $argument->textContent);
357
-                            } else {
358
-                                $arguments[] = Xml::xmlToVariable($argument);
359
-                            }
360
-                        }
361
-                    }
362
-                }
363
-            }
364
-
365
-            $result[] = [
366
-                'class'     => $class,
367
-                'file'      => $file,
368
-                'arguments' => $arguments
369
-            ];
370
-        }
371
-
372
-        return $result;
373
-    }
374
-
375
-    /**
376
-     * Returns the logging configuration.
377
-     *
378
-     * @return array
379
-     */
380
-    public function getLoggingConfiguration()
381
-    {
382
-        $result = [];
383
-
384
-        foreach ($this->xpath->query('logging/log') as $log) {
385
-            $type   = (string) $log->getAttribute('type');
386
-            $target = (string) $log->getAttribute('target');
387
-
388
-            if (!$target) {
389
-                continue;
390
-            }
391
-
392
-            $target = $this->toAbsolutePath($target);
393
-
394
-            if ($type == 'coverage-html') {
395
-                if ($log->hasAttribute('lowUpperBound')) {
396
-                    $result['lowUpperBound'] = $this->getInteger(
397
-                        (string) $log->getAttribute('lowUpperBound'),
398
-                        50
399
-                    );
400
-                }
401
-
402
-                if ($log->hasAttribute('highLowerBound')) {
403
-                    $result['highLowerBound'] = $this->getInteger(
404
-                        (string) $log->getAttribute('highLowerBound'),
405
-                        90
406
-                    );
407
-                }
408
-            } elseif ($type == 'coverage-crap4j') {
409
-                if ($log->hasAttribute('threshold')) {
410
-                    $result['crap4jThreshold'] = $this->getInteger(
411
-                        (string) $log->getAttribute('threshold'),
412
-                        30
413
-                    );
414
-                }
415
-            } elseif ($type == 'coverage-text') {
416
-                if ($log->hasAttribute('showUncoveredFiles')) {
417
-                    $result['coverageTextShowUncoveredFiles'] = $this->getBoolean(
418
-                        (string) $log->getAttribute('showUncoveredFiles'),
419
-                        false
420
-                    );
421
-                }
422
-                if ($log->hasAttribute('showOnlySummary')) {
423
-                    $result['coverageTextShowOnlySummary'] = $this->getBoolean(
424
-                        (string) $log->getAttribute('showOnlySummary'),
425
-                        false
426
-                    );
427
-                }
428
-            }
429
-
430
-            $result[$type] = $target;
431
-        }
432
-
433
-        return $result;
434
-    }
435
-
436
-    /**
437
-     * Returns the PHP configuration.
438
-     *
439
-     * @return array
440
-     */
441
-    public function getPHPConfiguration()
442
-    {
443
-        $result = [
444
-            'include_path' => [],
445
-            'ini'          => [],
446
-            'const'        => [],
447
-            'var'          => [],
448
-            'env'          => [],
449
-            'post'         => [],
450
-            'get'          => [],
451
-            'cookie'       => [],
452
-            'server'       => [],
453
-            'files'        => [],
454
-            'request'      => []
455
-        ];
456
-
457
-        foreach ($this->xpath->query('php/includePath') as $includePath) {
458
-            $path = (string) $includePath->textContent;
459
-
460
-            if ($path) {
461
-                $result['include_path'][] = $this->toAbsolutePath($path);
462
-            }
463
-        }
464
-
465
-        foreach ($this->xpath->query('php/ini') as $ini) {
466
-            $name  = (string) $ini->getAttribute('name');
467
-            $value = (string) $ini->getAttribute('value');
468
-
469
-            $result['ini'][$name]['value'] = $value;
470
-        }
471
-
472
-        foreach ($this->xpath->query('php/const') as $const) {
473
-            $name  = (string) $const->getAttribute('name');
474
-            $value = (string) $const->getAttribute('value');
475
-
476
-            $result['const'][$name]['value'] = $this->getBoolean($value, $value);
477
-        }
478
-
479
-        foreach (['var', 'env', 'post', 'get', 'cookie', 'server', 'files', 'request'] as $array) {
480
-            foreach ($this->xpath->query('php/' . $array) as $var) {
481
-                $name     = (string) $var->getAttribute('name');
482
-                $value    = (string) $var->getAttribute('value');
483
-                $verbatim = false;
484
-                $force    = false;
485
-
486
-                if ($var->hasAttribute('verbatim')) {
487
-                    $verbatim                          = $this->getBoolean($var->getAttribute('verbatim'), false);
488
-                    $result[$array][$name]['verbatim'] = $verbatim;
489
-                }
490
-
491
-                if ($var->hasAttribute('force')) {
492
-                    $force                          = $this->getBoolean($var->getAttribute('force'), false);
493
-                    $result[$array][$name]['force'] = $force;
494
-                }
495
-
496
-                if (!$verbatim) {
497
-                    $value = $this->getBoolean($value, $value);
498
-                }
499
-
500
-                $result[$array][$name]['value'] = $value;
501
-            }
502
-        }
503
-
504
-        return $result;
505
-    }
506
-
507
-    /**
508
-     * Handles the PHP configuration.
509
-     */
510
-    public function handlePHPConfiguration()
511
-    {
512
-        $configuration = $this->getPHPConfiguration();
513
-
514
-        if (!empty($configuration['include_path'])) {
515
-            \ini_set(
516
-                'include_path',
517
-                \implode(PATH_SEPARATOR, $configuration['include_path']) .
518
-                PATH_SEPARATOR .
519
-                \ini_get('include_path')
520
-            );
521
-        }
522
-
523
-        foreach ($configuration['ini'] as $name => $data) {
524
-            $value = $data['value'];
525
-
526
-            if (\defined($value)) {
527
-                $value = (string) \constant($value);
528
-            }
529
-
530
-            \ini_set($name, $value);
531
-        }
532
-
533
-        foreach ($configuration['const'] as $name => $data) {
534
-            $value = $data['value'];
535
-
536
-            if (!\defined($name)) {
537
-                \define($name, $value);
538
-            }
539
-        }
540
-
541
-        foreach (['var', 'post', 'get', 'cookie', 'server', 'files', 'request'] as $array) {
542
-            // See https://github.com/sebastianbergmann/phpunit/issues/277
543
-            switch ($array) {
544
-                case 'var':
545
-                    $target = &$GLOBALS;
546
-
547
-                    break;
548
-
549
-                case 'server':
550
-                    $target = &$_SERVER;
551
-
552
-                    break;
553
-
554
-                default:
555
-                    $target = &$GLOBALS['_' . \strtoupper($array)];
556
-
557
-                    break;
558
-            }
559
-
560
-            foreach ($configuration[$array] as $name => $data) {
561
-                $target[$name] = $data['value'];
562
-            }
563
-        }
564
-
565
-        foreach ($configuration['env'] as $name => $data) {
566
-            $value = $data['value'];
567
-            $force = isset($data['force']) ? $data['force'] : false;
568
-
569
-            if (false === \getenv($name)) {
570
-                \putenv("{$name}={$value}");
571
-            }
572
-
573
-            if (!isset($_ENV[$name])) {
574
-                $_ENV[$name] = $value;
575
-            }
576
-
577
-            if (true === $force) {
578
-                $_ENV[$name] = $value;
579
-            }
580
-        }
581
-    }
582
-
583
-    /**
584
-     * Returns the PHPUnit configuration.
585
-     *
586
-     * @return array
587
-     */
588
-    public function getPHPUnitConfiguration()
589
-    {
590
-        $result = [];
591
-        $root   = $this->document->documentElement;
592
-
593
-        if ($root->hasAttribute('cacheTokens')) {
594
-            $result['cacheTokens'] = $this->getBoolean(
595
-                (string) $root->getAttribute('cacheTokens'),
596
-                false
597
-            );
598
-        }
599
-
600
-        if ($root->hasAttribute('columns')) {
601
-            $columns = (string) $root->getAttribute('columns');
602
-
603
-            if ($columns == 'max') {
604
-                $result['columns'] = 'max';
605
-            } else {
606
-                $result['columns'] = $this->getInteger($columns, 80);
607
-            }
608
-        }
609
-
610
-        if ($root->hasAttribute('colors')) {
611
-            /* only allow boolean for compatibility with previous versions
153
+	const TEST_SUITE_FILTER_SEPARATOR = ',';
154
+
155
+	private static $instances = [];
156
+
157
+	protected $document;
158
+	protected $xpath;
159
+	protected $filename;
160
+
161
+	/**
162
+	 * Loads a PHPUnit configuration file.
163
+	 *
164
+	 * @param string $filename
165
+	 */
166
+	protected function __construct($filename)
167
+	{
168
+		$this->filename = $filename;
169
+		$this->document = Xml::loadFile($filename, false, true, true);
170
+		$this->xpath    = new DOMXPath($this->document);
171
+	}
172
+
173
+	final private function __clone()
174
+	{
175
+	}
176
+
177
+	/**
178
+	 * Returns a PHPUnit configuration object.
179
+	 *
180
+	 * @param string $filename
181
+	 *
182
+	 * @return Configuration
183
+	 */
184
+	public static function getInstance($filename)
185
+	{
186
+		$realpath = \realpath($filename);
187
+
188
+		if ($realpath === false) {
189
+			throw new Exception(
190
+				\sprintf(
191
+					'Could not read "%s".',
192
+					$filename
193
+				)
194
+			);
195
+		}
196
+
197
+		if (!isset(self::$instances[$realpath])) {
198
+			self::$instances[$realpath] = new self($realpath);
199
+		}
200
+
201
+		return self::$instances[$realpath];
202
+	}
203
+
204
+	/**
205
+	 * Returns the realpath to the configuration file.
206
+	 *
207
+	 * @return string
208
+	 */
209
+	public function getFilename()
210
+	{
211
+		return $this->filename;
212
+	}
213
+
214
+	/**
215
+	 * Returns the configuration for SUT filtering.
216
+	 *
217
+	 * @return array
218
+	 */
219
+	public function getFilterConfiguration()
220
+	{
221
+		$addUncoveredFilesFromWhitelist     = true;
222
+		$processUncoveredFilesFromWhitelist = false;
223
+
224
+		$tmp = $this->xpath->query('filter/whitelist');
225
+
226
+		if ($tmp->length == 0) {
227
+			return [
228
+				'whitelist' => [
229
+					'addUncoveredFilesFromWhitelist'     => $addUncoveredFilesFromWhitelist,
230
+					'processUncoveredFilesFromWhitelist' => $processUncoveredFilesFromWhitelist,
231
+					'include'                            => [
232
+						'directory' => [],
233
+						'file'      => []
234
+					],
235
+					'exclude' => [
236
+						'directory' => [],
237
+						'file'      => []
238
+					]
239
+				]
240
+			];
241
+		}
242
+
243
+		if ($tmp->length == 1) {
244
+			if ($tmp->item(0)->hasAttribute('addUncoveredFilesFromWhitelist')) {
245
+				$addUncoveredFilesFromWhitelist = $this->getBoolean(
246
+					(string) $tmp->item(0)->getAttribute(
247
+						'addUncoveredFilesFromWhitelist'
248
+					),
249
+					true
250
+				);
251
+			}
252
+
253
+			if ($tmp->item(0)->hasAttribute('processUncoveredFilesFromWhitelist')) {
254
+				$processUncoveredFilesFromWhitelist = $this->getBoolean(
255
+					(string) $tmp->item(0)->getAttribute(
256
+						'processUncoveredFilesFromWhitelist'
257
+					),
258
+					false
259
+				);
260
+			}
261
+		}
262
+
263
+		return [
264
+			'whitelist' => [
265
+				'addUncoveredFilesFromWhitelist'     => $addUncoveredFilesFromWhitelist,
266
+				'processUncoveredFilesFromWhitelist' => $processUncoveredFilesFromWhitelist,
267
+				'include'                            => [
268
+					'directory' => $this->readFilterDirectories(
269
+						'filter/whitelist/directory'
270
+					),
271
+					'file' => $this->readFilterFiles(
272
+						'filter/whitelist/file'
273
+					)
274
+				],
275
+				'exclude' => [
276
+					'directory' => $this->readFilterDirectories(
277
+						'filter/whitelist/exclude/directory'
278
+					),
279
+					'file' => $this->readFilterFiles(
280
+						'filter/whitelist/exclude/file'
281
+					)
282
+				]
283
+			]
284
+		];
285
+	}
286
+
287
+	/**
288
+	 * Returns the configuration for groups.
289
+	 *
290
+	 * @return array
291
+	 */
292
+	public function getGroupConfiguration()
293
+	{
294
+		return $this->parseGroupConfiguration('groups');
295
+	}
296
+
297
+	/**
298
+	 * Returns the configuration for testdox groups.
299
+	 *
300
+	 * @return array
301
+	 */
302
+	public function getTestdoxGroupConfiguration()
303
+	{
304
+		return $this->parseGroupConfiguration('testdoxGroups');
305
+	}
306
+
307
+	/**
308
+	 * @param string $root
309
+	 *
310
+	 * @return array
311
+	 */
312
+	private function parseGroupConfiguration($root)
313
+	{
314
+		$groups = [
315
+			'include' => [],
316
+			'exclude' => []
317
+		];
318
+
319
+		foreach ($this->xpath->query($root . '/include/group') as $group) {
320
+			$groups['include'][] = (string) $group->textContent;
321
+		}
322
+
323
+		foreach ($this->xpath->query($root . '/exclude/group') as $group) {
324
+			$groups['exclude'][] = (string) $group->textContent;
325
+		}
326
+
327
+		return $groups;
328
+	}
329
+
330
+	/**
331
+	 * Returns the configuration for listeners.
332
+	 *
333
+	 * @return array
334
+	 */
335
+	public function getListenerConfiguration()
336
+	{
337
+		$result = [];
338
+
339
+		foreach ($this->xpath->query('listeners/listener') as $listener) {
340
+			$class     = (string) $listener->getAttribute('class');
341
+			$file      = '';
342
+			$arguments = [];
343
+
344
+			if ($listener->getAttribute('file')) {
345
+				$file = $this->toAbsolutePath(
346
+					(string) $listener->getAttribute('file'),
347
+					true
348
+				);
349
+			}
350
+
351
+			foreach ($listener->childNodes as $node) {
352
+				if ($node instanceof DOMElement && $node->tagName == 'arguments') {
353
+					foreach ($node->childNodes as $argument) {
354
+						if ($argument instanceof DOMElement) {
355
+							if ($argument->tagName == 'file' || $argument->tagName == 'directory') {
356
+								$arguments[] = $this->toAbsolutePath((string) $argument->textContent);
357
+							} else {
358
+								$arguments[] = Xml::xmlToVariable($argument);
359
+							}
360
+						}
361
+					}
362
+				}
363
+			}
364
+
365
+			$result[] = [
366
+				'class'     => $class,
367
+				'file'      => $file,
368
+				'arguments' => $arguments
369
+			];
370
+		}
371
+
372
+		return $result;
373
+	}
374
+
375
+	/**
376
+	 * Returns the logging configuration.
377
+	 *
378
+	 * @return array
379
+	 */
380
+	public function getLoggingConfiguration()
381
+	{
382
+		$result = [];
383
+
384
+		foreach ($this->xpath->query('logging/log') as $log) {
385
+			$type   = (string) $log->getAttribute('type');
386
+			$target = (string) $log->getAttribute('target');
387
+
388
+			if (!$target) {
389
+				continue;
390
+			}
391
+
392
+			$target = $this->toAbsolutePath($target);
393
+
394
+			if ($type == 'coverage-html') {
395
+				if ($log->hasAttribute('lowUpperBound')) {
396
+					$result['lowUpperBound'] = $this->getInteger(
397
+						(string) $log->getAttribute('lowUpperBound'),
398
+						50
399
+					);
400
+				}
401
+
402
+				if ($log->hasAttribute('highLowerBound')) {
403
+					$result['highLowerBound'] = $this->getInteger(
404
+						(string) $log->getAttribute('highLowerBound'),
405
+						90
406
+					);
407
+				}
408
+			} elseif ($type == 'coverage-crap4j') {
409
+				if ($log->hasAttribute('threshold')) {
410
+					$result['crap4jThreshold'] = $this->getInteger(
411
+						(string) $log->getAttribute('threshold'),
412
+						30
413
+					);
414
+				}
415
+			} elseif ($type == 'coverage-text') {
416
+				if ($log->hasAttribute('showUncoveredFiles')) {
417
+					$result['coverageTextShowUncoveredFiles'] = $this->getBoolean(
418
+						(string) $log->getAttribute('showUncoveredFiles'),
419
+						false
420
+					);
421
+				}
422
+				if ($log->hasAttribute('showOnlySummary')) {
423
+					$result['coverageTextShowOnlySummary'] = $this->getBoolean(
424
+						(string) $log->getAttribute('showOnlySummary'),
425
+						false
426
+					);
427
+				}
428
+			}
429
+
430
+			$result[$type] = $target;
431
+		}
432
+
433
+		return $result;
434
+	}
435
+
436
+	/**
437
+	 * Returns the PHP configuration.
438
+	 *
439
+	 * @return array
440
+	 */
441
+	public function getPHPConfiguration()
442
+	{
443
+		$result = [
444
+			'include_path' => [],
445
+			'ini'          => [],
446
+			'const'        => [],
447
+			'var'          => [],
448
+			'env'          => [],
449
+			'post'         => [],
450
+			'get'          => [],
451
+			'cookie'       => [],
452
+			'server'       => [],
453
+			'files'        => [],
454
+			'request'      => []
455
+		];
456
+
457
+		foreach ($this->xpath->query('php/includePath') as $includePath) {
458
+			$path = (string) $includePath->textContent;
459
+
460
+			if ($path) {
461
+				$result['include_path'][] = $this->toAbsolutePath($path);
462
+			}
463
+		}
464
+
465
+		foreach ($this->xpath->query('php/ini') as $ini) {
466
+			$name  = (string) $ini->getAttribute('name');
467
+			$value = (string) $ini->getAttribute('value');
468
+
469
+			$result['ini'][$name]['value'] = $value;
470
+		}
471
+
472
+		foreach ($this->xpath->query('php/const') as $const) {
473
+			$name  = (string) $const->getAttribute('name');
474
+			$value = (string) $const->getAttribute('value');
475
+
476
+			$result['const'][$name]['value'] = $this->getBoolean($value, $value);
477
+		}
478
+
479
+		foreach (['var', 'env', 'post', 'get', 'cookie', 'server', 'files', 'request'] as $array) {
480
+			foreach ($this->xpath->query('php/' . $array) as $var) {
481
+				$name     = (string) $var->getAttribute('name');
482
+				$value    = (string) $var->getAttribute('value');
483
+				$verbatim = false;
484
+				$force    = false;
485
+
486
+				if ($var->hasAttribute('verbatim')) {
487
+					$verbatim                          = $this->getBoolean($var->getAttribute('verbatim'), false);
488
+					$result[$array][$name]['verbatim'] = $verbatim;
489
+				}
490
+
491
+				if ($var->hasAttribute('force')) {
492
+					$force                          = $this->getBoolean($var->getAttribute('force'), false);
493
+					$result[$array][$name]['force'] = $force;
494
+				}
495
+
496
+				if (!$verbatim) {
497
+					$value = $this->getBoolean($value, $value);
498
+				}
499
+
500
+				$result[$array][$name]['value'] = $value;
501
+			}
502
+		}
503
+
504
+		return $result;
505
+	}
506
+
507
+	/**
508
+	 * Handles the PHP configuration.
509
+	 */
510
+	public function handlePHPConfiguration()
511
+	{
512
+		$configuration = $this->getPHPConfiguration();
513
+
514
+		if (!empty($configuration['include_path'])) {
515
+			\ini_set(
516
+				'include_path',
517
+				\implode(PATH_SEPARATOR, $configuration['include_path']) .
518
+				PATH_SEPARATOR .
519
+				\ini_get('include_path')
520
+			);
521
+		}
522
+
523
+		foreach ($configuration['ini'] as $name => $data) {
524
+			$value = $data['value'];
525
+
526
+			if (\defined($value)) {
527
+				$value = (string) \constant($value);
528
+			}
529
+
530
+			\ini_set($name, $value);
531
+		}
532
+
533
+		foreach ($configuration['const'] as $name => $data) {
534
+			$value = $data['value'];
535
+
536
+			if (!\defined($name)) {
537
+				\define($name, $value);
538
+			}
539
+		}
540
+
541
+		foreach (['var', 'post', 'get', 'cookie', 'server', 'files', 'request'] as $array) {
542
+			// See https://github.com/sebastianbergmann/phpunit/issues/277
543
+			switch ($array) {
544
+				case 'var':
545
+					$target = &$GLOBALS;
546
+
547
+					break;
548
+
549
+				case 'server':
550
+					$target = &$_SERVER;
551
+
552
+					break;
553
+
554
+				default:
555
+					$target = &$GLOBALS['_' . \strtoupper($array)];
556
+
557
+					break;
558
+			}
559
+
560
+			foreach ($configuration[$array] as $name => $data) {
561
+				$target[$name] = $data['value'];
562
+			}
563
+		}
564
+
565
+		foreach ($configuration['env'] as $name => $data) {
566
+			$value = $data['value'];
567
+			$force = isset($data['force']) ? $data['force'] : false;
568
+
569
+			if (false === \getenv($name)) {
570
+				\putenv("{$name}={$value}");
571
+			}
572
+
573
+			if (!isset($_ENV[$name])) {
574
+				$_ENV[$name] = $value;
575
+			}
576
+
577
+			if (true === $force) {
578
+				$_ENV[$name] = $value;
579
+			}
580
+		}
581
+	}
582
+
583
+	/**
584
+	 * Returns the PHPUnit configuration.
585
+	 *
586
+	 * @return array
587
+	 */
588
+	public function getPHPUnitConfiguration()
589
+	{
590
+		$result = [];
591
+		$root   = $this->document->documentElement;
592
+
593
+		if ($root->hasAttribute('cacheTokens')) {
594
+			$result['cacheTokens'] = $this->getBoolean(
595
+				(string) $root->getAttribute('cacheTokens'),
596
+				false
597
+			);
598
+		}
599
+
600
+		if ($root->hasAttribute('columns')) {
601
+			$columns = (string) $root->getAttribute('columns');
602
+
603
+			if ($columns == 'max') {
604
+				$result['columns'] = 'max';
605
+			} else {
606
+				$result['columns'] = $this->getInteger($columns, 80);
607
+			}
608
+		}
609
+
610
+		if ($root->hasAttribute('colors')) {
611
+			/* only allow boolean for compatibility with previous versions
612 612
               'always' only allowed from command line */
613
-            if ($this->getBoolean($root->getAttribute('colors'), false)) {
614
-                $result['colors'] = ResultPrinter::COLOR_AUTO;
615
-            } else {
616
-                $result['colors'] = ResultPrinter::COLOR_NEVER;
617
-            }
618
-        }
619
-
620
-        /*
613
+			if ($this->getBoolean($root->getAttribute('colors'), false)) {
614
+				$result['colors'] = ResultPrinter::COLOR_AUTO;
615
+			} else {
616
+				$result['colors'] = ResultPrinter::COLOR_NEVER;
617
+			}
618
+		}
619
+
620
+		/*
621 621
          * Issue #657
622 622
          */
623
-        if ($root->hasAttribute('stderr')) {
624
-            $result['stderr'] = $this->getBoolean(
625
-                (string) $root->getAttribute('stderr'),
626
-                false
627
-            );
628
-        }
629
-
630
-        if ($root->hasAttribute('backupGlobals')) {
631
-            $result['backupGlobals'] = $this->getBoolean(
632
-                (string) $root->getAttribute('backupGlobals'),
633
-                false
634
-            );
635
-        }
636
-
637
-        if ($root->hasAttribute('backupStaticAttributes')) {
638
-            $result['backupStaticAttributes'] = $this->getBoolean(
639
-                (string) $root->getAttribute('backupStaticAttributes'),
640
-                false
641
-            );
642
-        }
643
-
644
-        if ($root->getAttribute('bootstrap')) {
645
-            $result['bootstrap'] = $this->toAbsolutePath(
646
-                (string) $root->getAttribute('bootstrap')
647
-            );
648
-        }
649
-
650
-        if ($root->hasAttribute('convertDeprecationsToExceptions')) {
651
-            $result['convertDeprecationsToExceptions'] = $this->getBoolean(
652
-                (string) $root->getAttribute('convertDeprecationsToExceptions'),
653
-                true
654
-            );
655
-        }
656
-
657
-        if ($root->hasAttribute('convertErrorsToExceptions')) {
658
-            $result['convertErrorsToExceptions'] = $this->getBoolean(
659
-                (string) $root->getAttribute('convertErrorsToExceptions'),
660
-                true
661
-            );
662
-        }
663
-
664
-        if ($root->hasAttribute('convertNoticesToExceptions')) {
665
-            $result['convertNoticesToExceptions'] = $this->getBoolean(
666
-                (string) $root->getAttribute('convertNoticesToExceptions'),
667
-                true
668
-            );
669
-        }
670
-
671
-        if ($root->hasAttribute('convertWarningsToExceptions')) {
672
-            $result['convertWarningsToExceptions'] = $this->getBoolean(
673
-                (string) $root->getAttribute('convertWarningsToExceptions'),
674
-                true
675
-            );
676
-        }
677
-
678
-        if ($root->hasAttribute('forceCoversAnnotation')) {
679
-            $result['forceCoversAnnotation'] = $this->getBoolean(
680
-                (string) $root->getAttribute('forceCoversAnnotation'),
681
-                false
682
-            );
683
-        }
684
-
685
-        if ($root->hasAttribute('disableCodeCoverageIgnore')) {
686
-            $result['disableCodeCoverageIgnore'] = $this->getBoolean(
687
-                (string) $root->getAttribute('disableCodeCoverageIgnore'),
688
-                false
689
-            );
690
-        }
691
-
692
-        if ($root->hasAttribute('processIsolation')) {
693
-            $result['processIsolation'] = $this->getBoolean(
694
-                (string) $root->getAttribute('processIsolation'),
695
-                false
696
-            );
697
-        }
698
-
699
-        if ($root->hasAttribute('stopOnError')) {
700
-            $result['stopOnError'] = $this->getBoolean(
701
-                (string) $root->getAttribute('stopOnError'),
702
-                false
703
-            );
704
-        }
705
-
706
-        if ($root->hasAttribute('stopOnFailure')) {
707
-            $result['stopOnFailure'] = $this->getBoolean(
708
-                (string) $root->getAttribute('stopOnFailure'),
709
-                false
710
-            );
711
-        }
712
-
713
-        if ($root->hasAttribute('stopOnWarning')) {
714
-            $result['stopOnWarning'] = $this->getBoolean(
715
-                (string) $root->getAttribute('stopOnWarning'),
716
-                false
717
-            );
718
-        }
719
-
720
-        if ($root->hasAttribute('stopOnIncomplete')) {
721
-            $result['stopOnIncomplete'] = $this->getBoolean(
722
-                (string) $root->getAttribute('stopOnIncomplete'),
723
-                false
724
-            );
725
-        }
726
-
727
-        if ($root->hasAttribute('stopOnRisky')) {
728
-            $result['stopOnRisky'] = $this->getBoolean(
729
-                (string) $root->getAttribute('stopOnRisky'),
730
-                false
731
-            );
732
-        }
733
-
734
-        if ($root->hasAttribute('stopOnSkipped')) {
735
-            $result['stopOnSkipped'] = $this->getBoolean(
736
-                (string) $root->getAttribute('stopOnSkipped'),
737
-                false
738
-            );
739
-        }
740
-
741
-        if ($root->hasAttribute('failOnWarning')) {
742
-            $result['failOnWarning'] = $this->getBoolean(
743
-                (string) $root->getAttribute('failOnWarning'),
744
-                false
745
-            );
746
-        }
747
-
748
-        if ($root->hasAttribute('failOnRisky')) {
749
-            $result['failOnRisky'] = $this->getBoolean(
750
-                (string) $root->getAttribute('failOnRisky'),
751
-                false
752
-            );
753
-        }
754
-
755
-        if ($root->hasAttribute('testSuiteLoaderClass')) {
756
-            $result['testSuiteLoaderClass'] = (string) $root->getAttribute(
757
-                'testSuiteLoaderClass'
758
-            );
759
-        }
760
-
761
-        if ($root->hasAttribute('defaultTestSuite')) {
762
-            $result['defaultTestSuite'] = (string) $root->getAttribute(
763
-                'defaultTestSuite'
764
-            );
765
-        }
766
-
767
-        if ($root->getAttribute('testSuiteLoaderFile')) {
768
-            $result['testSuiteLoaderFile'] = $this->toAbsolutePath(
769
-                (string) $root->getAttribute('testSuiteLoaderFile')
770
-            );
771
-        }
772
-
773
-        if ($root->hasAttribute('printerClass')) {
774
-            $result['printerClass'] = (string) $root->getAttribute(
775
-                'printerClass'
776
-            );
777
-        }
778
-
779
-        if ($root->getAttribute('printerFile')) {
780
-            $result['printerFile'] = $this->toAbsolutePath(
781
-                (string) $root->getAttribute('printerFile')
782
-            );
783
-        }
784
-
785
-        if ($root->hasAttribute('beStrictAboutChangesToGlobalState')) {
786
-            $result['beStrictAboutChangesToGlobalState'] = $this->getBoolean(
787
-                (string) $root->getAttribute('beStrictAboutChangesToGlobalState'),
788
-                false
789
-            );
790
-        }
791
-
792
-        if ($root->hasAttribute('beStrictAboutOutputDuringTests')) {
793
-            $result['disallowTestOutput'] = $this->getBoolean(
794
-                (string) $root->getAttribute('beStrictAboutOutputDuringTests'),
795
-                false
796
-            );
797
-        }
798
-
799
-        if ($root->hasAttribute('beStrictAboutResourceUsageDuringSmallTests')) {
800
-            $result['beStrictAboutResourceUsageDuringSmallTests'] = $this->getBoolean(
801
-                (string) $root->getAttribute('beStrictAboutResourceUsageDuringSmallTests'),
802
-                false
803
-            );
804
-        }
805
-
806
-        if ($root->hasAttribute('beStrictAboutTestsThatDoNotTestAnything')) {
807
-            $result['reportUselessTests'] = $this->getBoolean(
808
-                (string) $root->getAttribute('beStrictAboutTestsThatDoNotTestAnything'),
809
-                true
810
-            );
811
-        }
812
-
813
-        if ($root->hasAttribute('beStrictAboutTodoAnnotatedTests')) {
814
-            $result['disallowTodoAnnotatedTests'] = $this->getBoolean(
815
-                (string) $root->getAttribute('beStrictAboutTodoAnnotatedTests'),
816
-                false
817
-            );
818
-        }
819
-
820
-        if ($root->hasAttribute('beStrictAboutCoversAnnotation')) {
821
-            $result['strictCoverage'] = $this->getBoolean(
822
-                (string) $root->getAttribute('beStrictAboutCoversAnnotation'),
823
-                false
824
-            );
825
-        }
826
-
827
-        if ($root->hasAttribute('enforceTimeLimit')) {
828
-            $result['enforceTimeLimit'] = $this->getBoolean(
829
-                (string) $root->getAttribute('enforceTimeLimit'),
830
-                false
831
-            );
832
-        }
833
-
834
-        if ($root->hasAttribute('ignoreDeprecatedCodeUnitsFromCodeCoverage')) {
835
-            $result['ignoreDeprecatedCodeUnitsFromCodeCoverage'] = $this->getBoolean(
836
-                (string) $root->getAttribute('ignoreDeprecatedCodeUnitsFromCodeCoverage'),
837
-                false
838
-            );
839
-        }
840
-
841
-        if ($root->hasAttribute('timeoutForSmallTests')) {
842
-            $result['timeoutForSmallTests'] = $this->getInteger(
843
-                (string) $root->getAttribute('timeoutForSmallTests'),
844
-                1
845
-            );
846
-        }
847
-
848
-        if ($root->hasAttribute('timeoutForMediumTests')) {
849
-            $result['timeoutForMediumTests'] = $this->getInteger(
850
-                (string) $root->getAttribute('timeoutForMediumTests'),
851
-                10
852
-            );
853
-        }
854
-
855
-        if ($root->hasAttribute('timeoutForLargeTests')) {
856
-            $result['timeoutForLargeTests'] = $this->getInteger(
857
-                (string) $root->getAttribute('timeoutForLargeTests'),
858
-                60
859
-            );
860
-        }
861
-
862
-        if ($root->hasAttribute('reverseDefectList')) {
863
-            $result['reverseDefectList'] = $this->getBoolean(
864
-                (string) $root->getAttribute('reverseDefectList'),
865
-                false
866
-            );
867
-        }
868
-
869
-        if ($root->hasAttribute('verbose')) {
870
-            $result['verbose'] = $this->getBoolean(
871
-                (string) $root->getAttribute('verbose'),
872
-                false
873
-            );
874
-        }
875
-
876
-        if ($root->hasAttribute('registerMockObjectsFromTestArgumentsRecursively')) {
877
-            $result['registerMockObjectsFromTestArgumentsRecursively'] = $this->getBoolean(
878
-                (string) $root->getAttribute('registerMockObjectsFromTestArgumentsRecursively'),
879
-                false
880
-            );
881
-        }
882
-
883
-        if ($root->hasAttribute('extensionsDirectory')) {
884
-            $result['extensionsDirectory'] = $this->toAbsolutePath(
885
-                (string) $root->getAttribute(
886
-                    'extensionsDirectory'
887
-                )
888
-            );
889
-        }
890
-
891
-        return $result;
892
-    }
893
-
894
-    /**
895
-     * Returns the test suite configuration.
896
-     *
897
-     * @param string|null $testSuiteFilter
898
-     *
899
-     * @return TestSuite
900
-     */
901
-    public function getTestSuiteConfiguration($testSuiteFilter = null)
902
-    {
903
-        $testSuiteNodes = $this->xpath->query('testsuites/testsuite');
904
-
905
-        if ($testSuiteNodes->length == 0) {
906
-            $testSuiteNodes = $this->xpath->query('testsuite');
907
-        }
908
-
909
-        if ($testSuiteNodes->length == 1) {
910
-            return $this->getTestSuite($testSuiteNodes->item(0), $testSuiteFilter);
911
-        }
912
-
913
-        //if ($testSuiteNodes->length > 1) { there cannot be a negative number of Nodes
914
-        $suite = new TestSuite;
915
-
916
-        foreach ($testSuiteNodes as $testSuiteNode) {
917
-            $suite->addTestSuite(
918
-                $this->getTestSuite($testSuiteNode, $testSuiteFilter)
919
-            );
920
-        }
921
-
922
-        return $suite;
923
-    }
924
-
925
-    /**
926
-     * Returns the test suite names from the configuration.
927
-     *
928
-     * @return array
929
-     */
930
-    public function getTestSuiteNames()
931
-    {
932
-        $names = [];
933
-        $nodes = $this->xpath->query('*/testsuite');
934
-        foreach ($nodes as $node) {
935
-            $names[] = $node->getAttribute('name');
936
-        }
937
-
938
-        return $names;
939
-    }
940
-
941
-    /**
942
-     * @param DOMElement  $testSuiteNode
943
-     * @param string|null $testSuiteFilter
944
-     *
945
-     * @return TestSuite
946
-     */
947
-    protected function getTestSuite(DOMElement $testSuiteNode, $testSuiteFilter = null)
948
-    {
949
-        if ($testSuiteNode->hasAttribute('name')) {
950
-            $suite = new TestSuite(
951
-                (string) $testSuiteNode->getAttribute('name')
952
-            );
953
-        } else {
954
-            $suite = new TestSuite;
955
-        }
956
-
957
-        $exclude = [];
958
-
959
-        foreach ($testSuiteNode->getElementsByTagName('exclude') as $excludeNode) {
960
-            $excludeFile = (string) $excludeNode->textContent;
961
-            if ($excludeFile) {
962
-                $exclude[] = $this->toAbsolutePath($excludeFile);
963
-            }
964
-        }
965
-
966
-        $fileIteratorFacade = new File_Iterator_Facade;
967
-        $testSuiteFilter    = $testSuiteFilter ? \explode(self::TEST_SUITE_FILTER_SEPARATOR, $testSuiteFilter) : [];
968
-
969
-        foreach ($testSuiteNode->getElementsByTagName('directory') as $directoryNode) {
970
-            if (!empty($testSuiteFilter) && !\in_array($directoryNode->parentNode->getAttribute('name'), $testSuiteFilter)) {
971
-                continue;
972
-            }
973
-
974
-            $directory = (string) $directoryNode->textContent;
975
-
976
-            if (empty($directory)) {
977
-                continue;
978
-            }
979
-
980
-            if ($directoryNode->hasAttribute('phpVersion')) {
981
-                $phpVersion = (string) $directoryNode->getAttribute('phpVersion');
982
-            } else {
983
-                $phpVersion = PHP_VERSION;
984
-            }
985
-
986
-            if ($directoryNode->hasAttribute('phpVersionOperator')) {
987
-                $phpVersionOperator = (string) $directoryNode->getAttribute('phpVersionOperator');
988
-            } else {
989
-                $phpVersionOperator = '>=';
990
-            }
991
-
992
-            if (!\version_compare(PHP_VERSION, $phpVersion, $phpVersionOperator)) {
993
-                continue;
994
-            }
995
-
996
-            if ($directoryNode->hasAttribute('prefix')) {
997
-                $prefix = (string) $directoryNode->getAttribute('prefix');
998
-            } else {
999
-                $prefix = '';
1000
-            }
1001
-
1002
-            if ($directoryNode->hasAttribute('suffix')) {
1003
-                $suffix = (string) $directoryNode->getAttribute('suffix');
1004
-            } else {
1005
-                $suffix = 'Test.php';
1006
-            }
1007
-
1008
-            $files = $fileIteratorFacade->getFilesAsArray(
1009
-                $this->toAbsolutePath($directory),
1010
-                $suffix,
1011
-                $prefix,
1012
-                $exclude
1013
-            );
1014
-            $suite->addTestFiles($files);
1015
-        }
1016
-
1017
-        foreach ($testSuiteNode->getElementsByTagName('file') as $fileNode) {
1018
-            if (!empty($testSuiteFilter) && !\in_array($fileNode->parentNode->getAttribute('name'), $testSuiteFilter)) {
1019
-                continue;
1020
-            }
1021
-
1022
-            $file = (string) $fileNode->textContent;
1023
-
1024
-            if (empty($file)) {
1025
-                continue;
1026
-            }
1027
-
1028
-            // Get the absolute path to the file
1029
-            $file = $fileIteratorFacade->getFilesAsArray(
1030
-                $this->toAbsolutePath($file)
1031
-            );
1032
-
1033
-            if (!isset($file[0])) {
1034
-                continue;
1035
-            }
1036
-
1037
-            $file = $file[0];
1038
-
1039
-            if ($fileNode->hasAttribute('phpVersion')) {
1040
-                $phpVersion = (string) $fileNode->getAttribute('phpVersion');
1041
-            } else {
1042
-                $phpVersion = PHP_VERSION;
1043
-            }
1044
-
1045
-            if ($fileNode->hasAttribute('phpVersionOperator')) {
1046
-                $phpVersionOperator = (string) $fileNode->getAttribute('phpVersionOperator');
1047
-            } else {
1048
-                $phpVersionOperator = '>=';
1049
-            }
1050
-
1051
-            if (!\version_compare(PHP_VERSION, $phpVersion, $phpVersionOperator)) {
1052
-                continue;
1053
-            }
1054
-
1055
-            $suite->addTestFile($file);
1056
-        }
1057
-
1058
-        return $suite;
1059
-    }
1060
-
1061
-    /**
1062
-     * if $value is 'false' or 'true', this returns the value that $value represents.
1063
-     * Otherwise, returns $default, which may be a string in rare cases.
1064
-     * See PHPUnit\Util\ConfigurationTest::testPHPConfigurationIsReadCorrectly
1065
-     *
1066
-     * @param string      $value
1067
-     * @param string|bool $default
1068
-     *
1069
-     * @return string|bool
1070
-     */
1071
-    protected function getBoolean($value, $default)
1072
-    {
1073
-        if (\strtolower($value) == 'false') {
1074
-            return false;
1075
-        }
1076
-
1077
-        if (\strtolower($value) == 'true') {
1078
-            return true;
1079
-        }
1080
-
1081
-        return $default;
1082
-    }
1083
-
1084
-    /**
1085
-     * @param string $value
1086
-     * @param int    $default
1087
-     *
1088
-     * @return int
1089
-     */
1090
-    protected function getInteger($value, $default)
1091
-    {
1092
-        if (\is_numeric($value)) {
1093
-            return (int) $value;
1094
-        }
1095
-
1096
-        return $default;
1097
-    }
1098
-
1099
-    /**
1100
-     * @param string $query
1101
-     *
1102
-     * @return array
1103
-     */
1104
-    protected function readFilterDirectories($query)
1105
-    {
1106
-        $directories = [];
1107
-
1108
-        foreach ($this->xpath->query($query) as $directory) {
1109
-            $directoryPath = (string) $directory->textContent;
1110
-
1111
-            if (!$directoryPath) {
1112
-                continue;
1113
-            }
1114
-
1115
-            if ($directory->hasAttribute('prefix')) {
1116
-                $prefix = (string) $directory->getAttribute('prefix');
1117
-            } else {
1118
-                $prefix = '';
1119
-            }
1120
-
1121
-            if ($directory->hasAttribute('suffix')) {
1122
-                $suffix = (string) $directory->getAttribute('suffix');
1123
-            } else {
1124
-                $suffix = '.php';
1125
-            }
1126
-
1127
-            if ($directory->hasAttribute('group')) {
1128
-                $group = (string) $directory->getAttribute('group');
1129
-            } else {
1130
-                $group = 'DEFAULT';
1131
-            }
1132
-
1133
-            $directories[] = [
1134
-                'path'   => $this->toAbsolutePath($directoryPath),
1135
-                'prefix' => $prefix,
1136
-                'suffix' => $suffix,
1137
-                'group'  => $group
1138
-            ];
1139
-        }
1140
-
1141
-        return $directories;
1142
-    }
1143
-
1144
-    /**
1145
-     * @param string $query
1146
-     *
1147
-     * @return array
1148
-     */
1149
-    protected function readFilterFiles($query)
1150
-    {
1151
-        $files = [];
1152
-
1153
-        foreach ($this->xpath->query($query) as $file) {
1154
-            $filePath = (string) $file->textContent;
1155
-
1156
-            if ($filePath) {
1157
-                $files[] = $this->toAbsolutePath($filePath);
1158
-            }
1159
-        }
1160
-
1161
-        return $files;
1162
-    }
1163
-
1164
-    /**
1165
-     * @param string $path
1166
-     * @param bool   $useIncludePath
1167
-     *
1168
-     * @return string
1169
-     */
1170
-    protected function toAbsolutePath($path, $useIncludePath = false)
1171
-    {
1172
-        $path = \trim($path);
1173
-
1174
-        if ($path[0] === '/') {
1175
-            return $path;
1176
-        }
1177
-
1178
-        // Matches the following on Windows:
1179
-        //  - \\NetworkComputer\Path
1180
-        //  - \\.\D:
1181
-        //  - \\.\c:
1182
-        //  - C:\Windows
1183
-        //  - C:\windows
1184
-        //  - C:/windows
1185
-        //  - c:/windows
1186
-        if (\defined('PHP_WINDOWS_VERSION_BUILD') &&
1187
-            ($path[0] === '\\' || (\strlen($path) >= 3 && \preg_match('#^[A-Z]\:[/\\\]#i', \substr($path, 0, 3))))) {
1188
-            return $path;
1189
-        }
1190
-
1191
-        // Stream
1192
-        if (\strpos($path, '://') !== false) {
1193
-            return $path;
1194
-        }
1195
-
1196
-        $file = \dirname($this->filename) . DIRECTORY_SEPARATOR . $path;
1197
-
1198
-        if ($useIncludePath && !\file_exists($file)) {
1199
-            $includePathFile = \stream_resolve_include_path($path);
1200
-
1201
-            if ($includePathFile) {
1202
-                $file = $includePathFile;
1203
-            }
1204
-        }
1205
-
1206
-        return $file;
1207
-    }
623
+		if ($root->hasAttribute('stderr')) {
624
+			$result['stderr'] = $this->getBoolean(
625
+				(string) $root->getAttribute('stderr'),
626
+				false
627
+			);
628
+		}
629
+
630
+		if ($root->hasAttribute('backupGlobals')) {
631
+			$result['backupGlobals'] = $this->getBoolean(
632
+				(string) $root->getAttribute('backupGlobals'),
633
+				false
634
+			);
635
+		}
636
+
637
+		if ($root->hasAttribute('backupStaticAttributes')) {
638
+			$result['backupStaticAttributes'] = $this->getBoolean(
639
+				(string) $root->getAttribute('backupStaticAttributes'),
640
+				false
641
+			);
642
+		}
643
+
644
+		if ($root->getAttribute('bootstrap')) {
645
+			$result['bootstrap'] = $this->toAbsolutePath(
646
+				(string) $root->getAttribute('bootstrap')
647
+			);
648
+		}
649
+
650
+		if ($root->hasAttribute('convertDeprecationsToExceptions')) {
651
+			$result['convertDeprecationsToExceptions'] = $this->getBoolean(
652
+				(string) $root->getAttribute('convertDeprecationsToExceptions'),
653
+				true
654
+			);
655
+		}
656
+
657
+		if ($root->hasAttribute('convertErrorsToExceptions')) {
658
+			$result['convertErrorsToExceptions'] = $this->getBoolean(
659
+				(string) $root->getAttribute('convertErrorsToExceptions'),
660
+				true
661
+			);
662
+		}
663
+
664
+		if ($root->hasAttribute('convertNoticesToExceptions')) {
665
+			$result['convertNoticesToExceptions'] = $this->getBoolean(
666
+				(string) $root->getAttribute('convertNoticesToExceptions'),
667
+				true
668
+			);
669
+		}
670
+
671
+		if ($root->hasAttribute('convertWarningsToExceptions')) {
672
+			$result['convertWarningsToExceptions'] = $this->getBoolean(
673
+				(string) $root->getAttribute('convertWarningsToExceptions'),
674
+				true
675
+			);
676
+		}
677
+
678
+		if ($root->hasAttribute('forceCoversAnnotation')) {
679
+			$result['forceCoversAnnotation'] = $this->getBoolean(
680
+				(string) $root->getAttribute('forceCoversAnnotation'),
681
+				false
682
+			);
683
+		}
684
+
685
+		if ($root->hasAttribute('disableCodeCoverageIgnore')) {
686
+			$result['disableCodeCoverageIgnore'] = $this->getBoolean(
687
+				(string) $root->getAttribute('disableCodeCoverageIgnore'),
688
+				false
689
+			);
690
+		}
691
+
692
+		if ($root->hasAttribute('processIsolation')) {
693
+			$result['processIsolation'] = $this->getBoolean(
694
+				(string) $root->getAttribute('processIsolation'),
695
+				false
696
+			);
697
+		}
698
+
699
+		if ($root->hasAttribute('stopOnError')) {
700
+			$result['stopOnError'] = $this->getBoolean(
701
+				(string) $root->getAttribute('stopOnError'),
702
+				false
703
+			);
704
+		}
705
+
706
+		if ($root->hasAttribute('stopOnFailure')) {
707
+			$result['stopOnFailure'] = $this->getBoolean(
708
+				(string) $root->getAttribute('stopOnFailure'),
709
+				false
710
+			);
711
+		}
712
+
713
+		if ($root->hasAttribute('stopOnWarning')) {
714
+			$result['stopOnWarning'] = $this->getBoolean(
715
+				(string) $root->getAttribute('stopOnWarning'),
716
+				false
717
+			);
718
+		}
719
+
720
+		if ($root->hasAttribute('stopOnIncomplete')) {
721
+			$result['stopOnIncomplete'] = $this->getBoolean(
722
+				(string) $root->getAttribute('stopOnIncomplete'),
723
+				false
724
+			);
725
+		}
726
+
727
+		if ($root->hasAttribute('stopOnRisky')) {
728
+			$result['stopOnRisky'] = $this->getBoolean(
729
+				(string) $root->getAttribute('stopOnRisky'),
730
+				false
731
+			);
732
+		}
733
+
734
+		if ($root->hasAttribute('stopOnSkipped')) {
735
+			$result['stopOnSkipped'] = $this->getBoolean(
736
+				(string) $root->getAttribute('stopOnSkipped'),
737
+				false
738
+			);
739
+		}
740
+
741
+		if ($root->hasAttribute('failOnWarning')) {
742
+			$result['failOnWarning'] = $this->getBoolean(
743
+				(string) $root->getAttribute('failOnWarning'),
744
+				false
745
+			);
746
+		}
747
+
748
+		if ($root->hasAttribute('failOnRisky')) {
749
+			$result['failOnRisky'] = $this->getBoolean(
750
+				(string) $root->getAttribute('failOnRisky'),
751
+				false
752
+			);
753
+		}
754
+
755
+		if ($root->hasAttribute('testSuiteLoaderClass')) {
756
+			$result['testSuiteLoaderClass'] = (string) $root->getAttribute(
757
+				'testSuiteLoaderClass'
758
+			);
759
+		}
760
+
761
+		if ($root->hasAttribute('defaultTestSuite')) {
762
+			$result['defaultTestSuite'] = (string) $root->getAttribute(
763
+				'defaultTestSuite'
764
+			);
765
+		}
766
+
767
+		if ($root->getAttribute('testSuiteLoaderFile')) {
768
+			$result['testSuiteLoaderFile'] = $this->toAbsolutePath(
769
+				(string) $root->getAttribute('testSuiteLoaderFile')
770
+			);
771
+		}
772
+
773
+		if ($root->hasAttribute('printerClass')) {
774
+			$result['printerClass'] = (string) $root->getAttribute(
775
+				'printerClass'
776
+			);
777
+		}
778
+
779
+		if ($root->getAttribute('printerFile')) {
780
+			$result['printerFile'] = $this->toAbsolutePath(
781
+				(string) $root->getAttribute('printerFile')
782
+			);
783
+		}
784
+
785
+		if ($root->hasAttribute('beStrictAboutChangesToGlobalState')) {
786
+			$result['beStrictAboutChangesToGlobalState'] = $this->getBoolean(
787
+				(string) $root->getAttribute('beStrictAboutChangesToGlobalState'),
788
+				false
789
+			);
790
+		}
791
+
792
+		if ($root->hasAttribute('beStrictAboutOutputDuringTests')) {
793
+			$result['disallowTestOutput'] = $this->getBoolean(
794
+				(string) $root->getAttribute('beStrictAboutOutputDuringTests'),
795
+				false
796
+			);
797
+		}
798
+
799
+		if ($root->hasAttribute('beStrictAboutResourceUsageDuringSmallTests')) {
800
+			$result['beStrictAboutResourceUsageDuringSmallTests'] = $this->getBoolean(
801
+				(string) $root->getAttribute('beStrictAboutResourceUsageDuringSmallTests'),
802
+				false
803
+			);
804
+		}
805
+
806
+		if ($root->hasAttribute('beStrictAboutTestsThatDoNotTestAnything')) {
807
+			$result['reportUselessTests'] = $this->getBoolean(
808
+				(string) $root->getAttribute('beStrictAboutTestsThatDoNotTestAnything'),
809
+				true
810
+			);
811
+		}
812
+
813
+		if ($root->hasAttribute('beStrictAboutTodoAnnotatedTests')) {
814
+			$result['disallowTodoAnnotatedTests'] = $this->getBoolean(
815
+				(string) $root->getAttribute('beStrictAboutTodoAnnotatedTests'),
816
+				false
817
+			);
818
+		}
819
+
820
+		if ($root->hasAttribute('beStrictAboutCoversAnnotation')) {
821
+			$result['strictCoverage'] = $this->getBoolean(
822
+				(string) $root->getAttribute('beStrictAboutCoversAnnotation'),
823
+				false
824
+			);
825
+		}
826
+
827
+		if ($root->hasAttribute('enforceTimeLimit')) {
828
+			$result['enforceTimeLimit'] = $this->getBoolean(
829
+				(string) $root->getAttribute('enforceTimeLimit'),
830
+				false
831
+			);
832
+		}
833
+
834
+		if ($root->hasAttribute('ignoreDeprecatedCodeUnitsFromCodeCoverage')) {
835
+			$result['ignoreDeprecatedCodeUnitsFromCodeCoverage'] = $this->getBoolean(
836
+				(string) $root->getAttribute('ignoreDeprecatedCodeUnitsFromCodeCoverage'),
837
+				false
838
+			);
839
+		}
840
+
841
+		if ($root->hasAttribute('timeoutForSmallTests')) {
842
+			$result['timeoutForSmallTests'] = $this->getInteger(
843
+				(string) $root->getAttribute('timeoutForSmallTests'),
844
+				1
845
+			);
846
+		}
847
+
848
+		if ($root->hasAttribute('timeoutForMediumTests')) {
849
+			$result['timeoutForMediumTests'] = $this->getInteger(
850
+				(string) $root->getAttribute('timeoutForMediumTests'),
851
+				10
852
+			);
853
+		}
854
+
855
+		if ($root->hasAttribute('timeoutForLargeTests')) {
856
+			$result['timeoutForLargeTests'] = $this->getInteger(
857
+				(string) $root->getAttribute('timeoutForLargeTests'),
858
+				60
859
+			);
860
+		}
861
+
862
+		if ($root->hasAttribute('reverseDefectList')) {
863
+			$result['reverseDefectList'] = $this->getBoolean(
864
+				(string) $root->getAttribute('reverseDefectList'),
865
+				false
866
+			);
867
+		}
868
+
869
+		if ($root->hasAttribute('verbose')) {
870
+			$result['verbose'] = $this->getBoolean(
871
+				(string) $root->getAttribute('verbose'),
872
+				false
873
+			);
874
+		}
875
+
876
+		if ($root->hasAttribute('registerMockObjectsFromTestArgumentsRecursively')) {
877
+			$result['registerMockObjectsFromTestArgumentsRecursively'] = $this->getBoolean(
878
+				(string) $root->getAttribute('registerMockObjectsFromTestArgumentsRecursively'),
879
+				false
880
+			);
881
+		}
882
+
883
+		if ($root->hasAttribute('extensionsDirectory')) {
884
+			$result['extensionsDirectory'] = $this->toAbsolutePath(
885
+				(string) $root->getAttribute(
886
+					'extensionsDirectory'
887
+				)
888
+			);
889
+		}
890
+
891
+		return $result;
892
+	}
893
+
894
+	/**
895
+	 * Returns the test suite configuration.
896
+	 *
897
+	 * @param string|null $testSuiteFilter
898
+	 *
899
+	 * @return TestSuite
900
+	 */
901
+	public function getTestSuiteConfiguration($testSuiteFilter = null)
902
+	{
903
+		$testSuiteNodes = $this->xpath->query('testsuites/testsuite');
904
+
905
+		if ($testSuiteNodes->length == 0) {
906
+			$testSuiteNodes = $this->xpath->query('testsuite');
907
+		}
908
+
909
+		if ($testSuiteNodes->length == 1) {
910
+			return $this->getTestSuite($testSuiteNodes->item(0), $testSuiteFilter);
911
+		}
912
+
913
+		//if ($testSuiteNodes->length > 1) { there cannot be a negative number of Nodes
914
+		$suite = new TestSuite;
915
+
916
+		foreach ($testSuiteNodes as $testSuiteNode) {
917
+			$suite->addTestSuite(
918
+				$this->getTestSuite($testSuiteNode, $testSuiteFilter)
919
+			);
920
+		}
921
+
922
+		return $suite;
923
+	}
924
+
925
+	/**
926
+	 * Returns the test suite names from the configuration.
927
+	 *
928
+	 * @return array
929
+	 */
930
+	public function getTestSuiteNames()
931
+	{
932
+		$names = [];
933
+		$nodes = $this->xpath->query('*/testsuite');
934
+		foreach ($nodes as $node) {
935
+			$names[] = $node->getAttribute('name');
936
+		}
937
+
938
+		return $names;
939
+	}
940
+
941
+	/**
942
+	 * @param DOMElement  $testSuiteNode
943
+	 * @param string|null $testSuiteFilter
944
+	 *
945
+	 * @return TestSuite
946
+	 */
947
+	protected function getTestSuite(DOMElement $testSuiteNode, $testSuiteFilter = null)
948
+	{
949
+		if ($testSuiteNode->hasAttribute('name')) {
950
+			$suite = new TestSuite(
951
+				(string) $testSuiteNode->getAttribute('name')
952
+			);
953
+		} else {
954
+			$suite = new TestSuite;
955
+		}
956
+
957
+		$exclude = [];
958
+
959
+		foreach ($testSuiteNode->getElementsByTagName('exclude') as $excludeNode) {
960
+			$excludeFile = (string) $excludeNode->textContent;
961
+			if ($excludeFile) {
962
+				$exclude[] = $this->toAbsolutePath($excludeFile);
963
+			}
964
+		}
965
+
966
+		$fileIteratorFacade = new File_Iterator_Facade;
967
+		$testSuiteFilter    = $testSuiteFilter ? \explode(self::TEST_SUITE_FILTER_SEPARATOR, $testSuiteFilter) : [];
968
+
969
+		foreach ($testSuiteNode->getElementsByTagName('directory') as $directoryNode) {
970
+			if (!empty($testSuiteFilter) && !\in_array($directoryNode->parentNode->getAttribute('name'), $testSuiteFilter)) {
971
+				continue;
972
+			}
973
+
974
+			$directory = (string) $directoryNode->textContent;
975
+
976
+			if (empty($directory)) {
977
+				continue;
978
+			}
979
+
980
+			if ($directoryNode->hasAttribute('phpVersion')) {
981
+				$phpVersion = (string) $directoryNode->getAttribute('phpVersion');
982
+			} else {
983
+				$phpVersion = PHP_VERSION;
984
+			}
985
+
986
+			if ($directoryNode->hasAttribute('phpVersionOperator')) {
987
+				$phpVersionOperator = (string) $directoryNode->getAttribute('phpVersionOperator');
988
+			} else {
989
+				$phpVersionOperator = '>=';
990
+			}
991
+
992
+			if (!\version_compare(PHP_VERSION, $phpVersion, $phpVersionOperator)) {
993
+				continue;
994
+			}
995
+
996
+			if ($directoryNode->hasAttribute('prefix')) {
997
+				$prefix = (string) $directoryNode->getAttribute('prefix');
998
+			} else {
999
+				$prefix = '';
1000
+			}
1001
+
1002
+			if ($directoryNode->hasAttribute('suffix')) {
1003
+				$suffix = (string) $directoryNode->getAttribute('suffix');
1004
+			} else {
1005
+				$suffix = 'Test.php';
1006
+			}
1007
+
1008
+			$files = $fileIteratorFacade->getFilesAsArray(
1009
+				$this->toAbsolutePath($directory),
1010
+				$suffix,
1011
+				$prefix,
1012
+				$exclude
1013
+			);
1014
+			$suite->addTestFiles($files);
1015
+		}
1016
+
1017
+		foreach ($testSuiteNode->getElementsByTagName('file') as $fileNode) {
1018
+			if (!empty($testSuiteFilter) && !\in_array($fileNode->parentNode->getAttribute('name'), $testSuiteFilter)) {
1019
+				continue;
1020
+			}
1021
+
1022
+			$file = (string) $fileNode->textContent;
1023
+
1024
+			if (empty($file)) {
1025
+				continue;
1026
+			}
1027
+
1028
+			// Get the absolute path to the file
1029
+			$file = $fileIteratorFacade->getFilesAsArray(
1030
+				$this->toAbsolutePath($file)
1031
+			);
1032
+
1033
+			if (!isset($file[0])) {
1034
+				continue;
1035
+			}
1036
+
1037
+			$file = $file[0];
1038
+
1039
+			if ($fileNode->hasAttribute('phpVersion')) {
1040
+				$phpVersion = (string) $fileNode->getAttribute('phpVersion');
1041
+			} else {
1042
+				$phpVersion = PHP_VERSION;
1043
+			}
1044
+
1045
+			if ($fileNode->hasAttribute('phpVersionOperator')) {
1046
+				$phpVersionOperator = (string) $fileNode->getAttribute('phpVersionOperator');
1047
+			} else {
1048
+				$phpVersionOperator = '>=';
1049
+			}
1050
+
1051
+			if (!\version_compare(PHP_VERSION, $phpVersion, $phpVersionOperator)) {
1052
+				continue;
1053
+			}
1054
+
1055
+			$suite->addTestFile($file);
1056
+		}
1057
+
1058
+		return $suite;
1059
+	}
1060
+
1061
+	/**
1062
+	 * if $value is 'false' or 'true', this returns the value that $value represents.
1063
+	 * Otherwise, returns $default, which may be a string in rare cases.
1064
+	 * See PHPUnit\Util\ConfigurationTest::testPHPConfigurationIsReadCorrectly
1065
+	 *
1066
+	 * @param string      $value
1067
+	 * @param string|bool $default
1068
+	 *
1069
+	 * @return string|bool
1070
+	 */
1071
+	protected function getBoolean($value, $default)
1072
+	{
1073
+		if (\strtolower($value) == 'false') {
1074
+			return false;
1075
+		}
1076
+
1077
+		if (\strtolower($value) == 'true') {
1078
+			return true;
1079
+		}
1080
+
1081
+		return $default;
1082
+	}
1083
+
1084
+	/**
1085
+	 * @param string $value
1086
+	 * @param int    $default
1087
+	 *
1088
+	 * @return int
1089
+	 */
1090
+	protected function getInteger($value, $default)
1091
+	{
1092
+		if (\is_numeric($value)) {
1093
+			return (int) $value;
1094
+		}
1095
+
1096
+		return $default;
1097
+	}
1098
+
1099
+	/**
1100
+	 * @param string $query
1101
+	 *
1102
+	 * @return array
1103
+	 */
1104
+	protected function readFilterDirectories($query)
1105
+	{
1106
+		$directories = [];
1107
+
1108
+		foreach ($this->xpath->query($query) as $directory) {
1109
+			$directoryPath = (string) $directory->textContent;
1110
+
1111
+			if (!$directoryPath) {
1112
+				continue;
1113
+			}
1114
+
1115
+			if ($directory->hasAttribute('prefix')) {
1116
+				$prefix = (string) $directory->getAttribute('prefix');
1117
+			} else {
1118
+				$prefix = '';
1119
+			}
1120
+
1121
+			if ($directory->hasAttribute('suffix')) {
1122
+				$suffix = (string) $directory->getAttribute('suffix');
1123
+			} else {
1124
+				$suffix = '.php';
1125
+			}
1126
+
1127
+			if ($directory->hasAttribute('group')) {
1128
+				$group = (string) $directory->getAttribute('group');
1129
+			} else {
1130
+				$group = 'DEFAULT';
1131
+			}
1132
+
1133
+			$directories[] = [
1134
+				'path'   => $this->toAbsolutePath($directoryPath),
1135
+				'prefix' => $prefix,
1136
+				'suffix' => $suffix,
1137
+				'group'  => $group
1138
+			];
1139
+		}
1140
+
1141
+		return $directories;
1142
+	}
1143
+
1144
+	/**
1145
+	 * @param string $query
1146
+	 *
1147
+	 * @return array
1148
+	 */
1149
+	protected function readFilterFiles($query)
1150
+	{
1151
+		$files = [];
1152
+
1153
+		foreach ($this->xpath->query($query) as $file) {
1154
+			$filePath = (string) $file->textContent;
1155
+
1156
+			if ($filePath) {
1157
+				$files[] = $this->toAbsolutePath($filePath);
1158
+			}
1159
+		}
1160
+
1161
+		return $files;
1162
+	}
1163
+
1164
+	/**
1165
+	 * @param string $path
1166
+	 * @param bool   $useIncludePath
1167
+	 *
1168
+	 * @return string
1169
+	 */
1170
+	protected function toAbsolutePath($path, $useIncludePath = false)
1171
+	{
1172
+		$path = \trim($path);
1173
+
1174
+		if ($path[0] === '/') {
1175
+			return $path;
1176
+		}
1177
+
1178
+		// Matches the following on Windows:
1179
+		//  - \\NetworkComputer\Path
1180
+		//  - \\.\D:
1181
+		//  - \\.\c:
1182
+		//  - C:\Windows
1183
+		//  - C:\windows
1184
+		//  - C:/windows
1185
+		//  - c:/windows
1186
+		if (\defined('PHP_WINDOWS_VERSION_BUILD') &&
1187
+			($path[0] === '\\' || (\strlen($path) >= 3 && \preg_match('#^[A-Z]\:[/\\\]#i', \substr($path, 0, 3))))) {
1188
+			return $path;
1189
+		}
1190
+
1191
+		// Stream
1192
+		if (\strpos($path, '://') !== false) {
1193
+			return $path;
1194
+		}
1195
+
1196
+		$file = \dirname($this->filename) . DIRECTORY_SEPARATOR . $path;
1197
+
1198
+		if ($useIncludePath && !\file_exists($file)) {
1199
+			$includePathFile = \stream_resolve_include_path($path);
1200
+
1201
+			if ($includePathFile) {
1202
+				$file = $includePathFile;
1203
+			}
1204
+		}
1205
+
1206
+		return $file;
1207
+	}
1208 1208
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Util/XmlTestListRenderer.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -16,67 +16,67 @@
 block discarded – undo
16 16
 
17 17
 class XmlTestListRenderer
18 18
 {
19
-    public function render(TestSuite $suite): string
20
-    {
21
-        $writer = new \XmlWriter;
22
-
23
-        $writer->openMemory();
24
-        $writer->setIndent(true);
25
-        $writer->startDocument();
26
-        $writer->startElement('tests');
27
-
28
-        $currentTestCase = null;
29
-
30
-        foreach (new \RecursiveIteratorIterator($suite->getIterator()) as $test) {
31
-            if ($test instanceof TestCase) {
32
-                if (\get_class($test) !== $currentTestCase) {
33
-                    if ($currentTestCase !== null) {
34
-                        $writer->endElement();
35
-                    }
36
-
37
-                    $writer->startElement('testCaseClass');
38
-                    $writer->writeAttribute('name', \get_class($test));
39
-
40
-                    $currentTestCase = \get_class($test);
41
-                }
42
-
43
-                $writer->startElement('testCaseMethod');
44
-                $writer->writeAttribute('name', $test->getName(false));
45
-                $writer->writeAttribute('groups', \implode(',', $test->getGroups()));
46
-
47
-                if (!empty($test->getDataSetAsString(false))) {
48
-                    $writer->writeAttribute(
49
-                        'dataSet',
50
-                        \str_replace(
51
-                            ' with data set ',
52
-                            '',
53
-                            $test->getDataSetAsString(false)
54
-                        )
55
-                    );
56
-                }
57
-
58
-                $writer->endElement();
59
-            } elseif ($test instanceof PhptTestCase) {
60
-                if ($currentTestCase !== null) {
61
-                    $writer->endElement();
62
-
63
-                    $currentTestCase = null;
64
-                }
65
-
66
-                $writer->startElement('phptFile');
67
-                $writer->writeAttribute('path', $test->getName());
68
-                $writer->endElement();
69
-            } else {
70
-                continue;
71
-            }
72
-        }
73
-
74
-        if ($currentTestCase !== null) {
75
-            $writer->endElement();
76
-        }
77
-
78
-        $writer->endElement();
79
-
80
-        return $writer->outputMemory();
81
-    }
19
+	public function render(TestSuite $suite): string
20
+	{
21
+		$writer = new \XmlWriter;
22
+
23
+		$writer->openMemory();
24
+		$writer->setIndent(true);
25
+		$writer->startDocument();
26
+		$writer->startElement('tests');
27
+
28
+		$currentTestCase = null;
29
+
30
+		foreach (new \RecursiveIteratorIterator($suite->getIterator()) as $test) {
31
+			if ($test instanceof TestCase) {
32
+				if (\get_class($test) !== $currentTestCase) {
33
+					if ($currentTestCase !== null) {
34
+						$writer->endElement();
35
+					}
36
+
37
+					$writer->startElement('testCaseClass');
38
+					$writer->writeAttribute('name', \get_class($test));
39
+
40
+					$currentTestCase = \get_class($test);
41
+				}
42
+
43
+				$writer->startElement('testCaseMethod');
44
+				$writer->writeAttribute('name', $test->getName(false));
45
+				$writer->writeAttribute('groups', \implode(',', $test->getGroups()));
46
+
47
+				if (!empty($test->getDataSetAsString(false))) {
48
+					$writer->writeAttribute(
49
+						'dataSet',
50
+						\str_replace(
51
+							' with data set ',
52
+							'',
53
+							$test->getDataSetAsString(false)
54
+						)
55
+					);
56
+				}
57
+
58
+				$writer->endElement();
59
+			} elseif ($test instanceof PhptTestCase) {
60
+				if ($currentTestCase !== null) {
61
+					$writer->endElement();
62
+
63
+					$currentTestCase = null;
64
+				}
65
+
66
+				$writer->startElement('phptFile');
67
+				$writer->writeAttribute('path', $test->getName());
68
+				$writer->endElement();
69
+			} else {
70
+				continue;
71
+			}
72
+		}
73
+
74
+		if ($currentTestCase !== null) {
75
+			$writer->endElement();
76
+		}
77
+
78
+		$writer->endElement();
79
+
80
+		return $writer->outputMemory();
81
+	}
82 82
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Util/RegularExpression.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -14,21 +14,21 @@
 block discarded – undo
14 14
  */
15 15
 class RegularExpression
16 16
 {
17
-    /**
18
-     * @param string $pattern
19
-     * @param string $subject
20
-     * @param null   $matches
21
-     * @param int    $flags
22
-     * @param int    $offset
23
-     *
24
-     * @return int
25
-     */
26
-    public static function safeMatch($pattern, $subject, $matches = null, $flags = 0, $offset = 0)
27
-    {
28
-        $handler_terminator = ErrorHandler::handleErrorOnce(E_WARNING);
29
-        $match              = \preg_match($pattern, $subject, $matches, $flags, $offset);
30
-        $handler_terminator(); // cleaning
17
+	/**
18
+	 * @param string $pattern
19
+	 * @param string $subject
20
+	 * @param null   $matches
21
+	 * @param int    $flags
22
+	 * @param int    $offset
23
+	 *
24
+	 * @return int
25
+	 */
26
+	public static function safeMatch($pattern, $subject, $matches = null, $flags = 0, $offset = 0)
27
+	{
28
+		$handler_terminator = ErrorHandler::handleErrorOnce(E_WARNING);
29
+		$match              = \preg_match($pattern, $subject, $matches, $flags, $offset);
30
+		$handler_terminator(); // cleaning
31 31
 
32
-        return $match;
33
-    }
32
+		return $match;
33
+	}
34 34
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Util/Filter.php 1 patch
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -17,91 +17,91 @@
 block discarded – undo
17 17
  */
18 18
 class Filter
19 19
 {
20
-    /**
21
-     * Filters stack frames from PHPUnit classes.
22
-     *
23
-     * @param \Throwable $e
24
-     * @param bool       $asString
25
-     *
26
-     * @return string
27
-     */
28
-    public static function getFilteredStacktrace($e, $asString = true)
29
-    {
30
-        $prefix = false;
31
-        $script = \realpath($GLOBALS['_SERVER']['SCRIPT_NAME']);
20
+	/**
21
+	 * Filters stack frames from PHPUnit classes.
22
+	 *
23
+	 * @param \Throwable $e
24
+	 * @param bool       $asString
25
+	 *
26
+	 * @return string
27
+	 */
28
+	public static function getFilteredStacktrace($e, $asString = true)
29
+	{
30
+		$prefix = false;
31
+		$script = \realpath($GLOBALS['_SERVER']['SCRIPT_NAME']);
32 32
 
33
-        if (\defined('__PHPUNIT_PHAR_ROOT__')) {
34
-            $prefix = __PHPUNIT_PHAR_ROOT__;
35
-        }
33
+		if (\defined('__PHPUNIT_PHAR_ROOT__')) {
34
+			$prefix = __PHPUNIT_PHAR_ROOT__;
35
+		}
36 36
 
37
-        if ($asString === true) {
38
-            $filteredStacktrace = '';
39
-        } else {
40
-            $filteredStacktrace = [];
41
-        }
37
+		if ($asString === true) {
38
+			$filteredStacktrace = '';
39
+		} else {
40
+			$filteredStacktrace = [];
41
+		}
42 42
 
43
-        if ($e instanceof SyntheticError) {
44
-            $eTrace = $e->getSyntheticTrace();
45
-            $eFile  = $e->getSyntheticFile();
46
-            $eLine  = $e->getSyntheticLine();
47
-        } elseif ($e instanceof Exception) {
48
-            $eTrace = $e->getSerializableTrace();
49
-            $eFile  = $e->getFile();
50
-            $eLine  = $e->getLine();
51
-        } else {
52
-            if ($e->getPrevious()) {
53
-                $e = $e->getPrevious();
54
-            }
55
-            $eTrace = $e->getTrace();
56
-            $eFile  = $e->getFile();
57
-            $eLine  = $e->getLine();
58
-        }
43
+		if ($e instanceof SyntheticError) {
44
+			$eTrace = $e->getSyntheticTrace();
45
+			$eFile  = $e->getSyntheticFile();
46
+			$eLine  = $e->getSyntheticLine();
47
+		} elseif ($e instanceof Exception) {
48
+			$eTrace = $e->getSerializableTrace();
49
+			$eFile  = $e->getFile();
50
+			$eLine  = $e->getLine();
51
+		} else {
52
+			if ($e->getPrevious()) {
53
+				$e = $e->getPrevious();
54
+			}
55
+			$eTrace = $e->getTrace();
56
+			$eFile  = $e->getFile();
57
+			$eLine  = $e->getLine();
58
+		}
59 59
 
60
-        if (!self::frameExists($eTrace, $eFile, $eLine)) {
61
-            \array_unshift(
62
-                $eTrace,
63
-                ['file' => $eFile, 'line' => $eLine]
64
-            );
65
-        }
60
+		if (!self::frameExists($eTrace, $eFile, $eLine)) {
61
+			\array_unshift(
62
+				$eTrace,
63
+				['file' => $eFile, 'line' => $eLine]
64
+			);
65
+		}
66 66
 
67
-        $blacklist = new Blacklist;
67
+		$blacklist = new Blacklist;
68 68
 
69
-        foreach ($eTrace as $frame) {
70
-            if (isset($frame['file']) && \is_file($frame['file']) &&
71
-                !$blacklist->isBlacklisted($frame['file']) &&
72
-                ($prefix === false || \strpos($frame['file'], $prefix) !== 0) &&
73
-                $frame['file'] !== $script) {
74
-                if ($asString === true) {
75
-                    $filteredStacktrace .= \sprintf(
76
-                        "%s:%s\n",
77
-                        $frame['file'],
78
-                        $frame['line'] ?? '?'
79
-                    );
80
-                } else {
81
-                    $filteredStacktrace[] = $frame;
82
-                }
83
-            }
84
-        }
69
+		foreach ($eTrace as $frame) {
70
+			if (isset($frame['file']) && \is_file($frame['file']) &&
71
+				!$blacklist->isBlacklisted($frame['file']) &&
72
+				($prefix === false || \strpos($frame['file'], $prefix) !== 0) &&
73
+				$frame['file'] !== $script) {
74
+				if ($asString === true) {
75
+					$filteredStacktrace .= \sprintf(
76
+						"%s:%s\n",
77
+						$frame['file'],
78
+						$frame['line'] ?? '?'
79
+					);
80
+				} else {
81
+					$filteredStacktrace[] = $frame;
82
+				}
83
+			}
84
+		}
85 85
 
86
-        return $filteredStacktrace;
87
-    }
86
+		return $filteredStacktrace;
87
+	}
88 88
 
89
-    /**
90
-     * @param array  $trace
91
-     * @param string $file
92
-     * @param int    $line
93
-     *
94
-     * @return bool
95
-     */
96
-    private static function frameExists(array $trace, $file, $line)
97
-    {
98
-        foreach ($trace as $frame) {
99
-            if (isset($frame['file']) && $frame['file'] == $file &&
100
-                isset($frame['line']) && $frame['line'] == $line) {
101
-                return true;
102
-            }
103
-        }
89
+	/**
90
+	 * @param array  $trace
91
+	 * @param string $file
92
+	 * @param int    $line
93
+	 *
94
+	 * @return bool
95
+	 */
96
+	private static function frameExists(array $trace, $file, $line)
97
+	{
98
+		foreach ($trace as $frame) {
99
+			if (isset($frame['file']) && $frame['file'] == $file &&
100
+				isset($frame['line']) && $frame['line'] == $line) {
101
+				return true;
102
+			}
103
+		}
104 104
 
105
-        return false;
106
-    }
105
+		return false;
106
+	}
107 107
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Util/Blacklist.php 1 patch
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -17,97 +17,97 @@
 block discarded – undo
17 17
  */
18 18
 class Blacklist
19 19
 {
20
-    /**
21
-     * @var array
22
-     */
23
-    public static $blacklistedClassNames = [
24
-        'File_Iterator'                               => 1,
25
-        'PHP_Invoker'                                 => 1,
26
-        'PHP_Timer'                                   => 1,
27
-        'PHP_Token'                                   => 1,
28
-        'PHPUnit\Framework\TestCase'                  => 2,
29
-        'PHPUnit\DbUnit\TestCase'                     => 2,
30
-        'PHPUnit_Framework_MockObject_Generator'      => 1,
31
-        'Text_Template'                               => 1,
32
-        'Symfony\Component\Yaml\Yaml'                 => 1,
33
-        'SebastianBergmann\CodeCoverage\CodeCoverage' => 1,
34
-        'SebastianBergmann\Diff\Diff'                 => 1,
35
-        'SebastianBergmann\Environment\Runtime'       => 1,
36
-        'SebastianBergmann\Comparator\Comparator'     => 1,
37
-        'SebastianBergmann\Exporter\Exporter'         => 1,
38
-        'SebastianBergmann\GlobalState\Snapshot'      => 1,
39
-        'SebastianBergmann\RecursionContext\Context'  => 1,
40
-        'SebastianBergmann\Version'                   => 1,
41
-        'Composer\Autoload\ClassLoader'               => 1,
42
-        'Doctrine\Instantiator\Instantiator'          => 1,
43
-        'phpDocumentor\Reflection\DocBlock'           => 1,
44
-        'Prophecy\Prophet'                            => 1,
45
-        'DeepCopy\DeepCopy'                           => 1
46
-    ];
47
-
48
-    /**
49
-     * @var string[]
50
-     */
51
-    private static $directories;
52
-
53
-    /**
54
-     * @return string[]
55
-     */
56
-    public function getBlacklistedDirectories()
57
-    {
58
-        $this->initialize();
59
-
60
-        return self::$directories;
61
-    }
62
-
63
-    /**
64
-     * @param string $file
65
-     *
66
-     * @return bool
67
-     */
68
-    public function isBlacklisted($file)
69
-    {
70
-        if (\defined('PHPUNIT_TESTSUITE')) {
71
-            return false;
72
-        }
73
-
74
-        $this->initialize();
75
-
76
-        foreach (self::$directories as $directory) {
77
-            if (\strpos($file, $directory) === 0) {
78
-                return true;
79
-            }
80
-        }
81
-
82
-        return false;
83
-    }
84
-
85
-    private function initialize()
86
-    {
87
-        if (self::$directories === null) {
88
-            self::$directories = [];
89
-
90
-            foreach (self::$blacklistedClassNames as $className => $parent) {
91
-                if (!\class_exists($className)) {
92
-                    continue;
93
-                }
94
-
95
-                $reflector = new ReflectionClass($className);
96
-                $directory = $reflector->getFileName();
97
-
98
-                for ($i = 0; $i < $parent; $i++) {
99
-                    $directory = \dirname($directory);
100
-                }
101
-
102
-                self::$directories[] = $directory;
103
-            }
104
-
105
-            // Hide process isolation workaround on Windows.
106
-            if (DIRECTORY_SEPARATOR === '\\') {
107
-                // tempnam() prefix is limited to first 3 chars.
108
-                // @see http://php.net/manual/en/function.tempnam.php
109
-                self::$directories[] = \sys_get_temp_dir() . '\\PHP';
110
-            }
111
-        }
112
-    }
20
+	/**
21
+	 * @var array
22
+	 */
23
+	public static $blacklistedClassNames = [
24
+		'File_Iterator'                               => 1,
25
+		'PHP_Invoker'                                 => 1,
26
+		'PHP_Timer'                                   => 1,
27
+		'PHP_Token'                                   => 1,
28
+		'PHPUnit\Framework\TestCase'                  => 2,
29
+		'PHPUnit\DbUnit\TestCase'                     => 2,
30
+		'PHPUnit_Framework_MockObject_Generator'      => 1,
31
+		'Text_Template'                               => 1,
32
+		'Symfony\Component\Yaml\Yaml'                 => 1,
33
+		'SebastianBergmann\CodeCoverage\CodeCoverage' => 1,
34
+		'SebastianBergmann\Diff\Diff'                 => 1,
35
+		'SebastianBergmann\Environment\Runtime'       => 1,
36
+		'SebastianBergmann\Comparator\Comparator'     => 1,
37
+		'SebastianBergmann\Exporter\Exporter'         => 1,
38
+		'SebastianBergmann\GlobalState\Snapshot'      => 1,
39
+		'SebastianBergmann\RecursionContext\Context'  => 1,
40
+		'SebastianBergmann\Version'                   => 1,
41
+		'Composer\Autoload\ClassLoader'               => 1,
42
+		'Doctrine\Instantiator\Instantiator'          => 1,
43
+		'phpDocumentor\Reflection\DocBlock'           => 1,
44
+		'Prophecy\Prophet'                            => 1,
45
+		'DeepCopy\DeepCopy'                           => 1
46
+	];
47
+
48
+	/**
49
+	 * @var string[]
50
+	 */
51
+	private static $directories;
52
+
53
+	/**
54
+	 * @return string[]
55
+	 */
56
+	public function getBlacklistedDirectories()
57
+	{
58
+		$this->initialize();
59
+
60
+		return self::$directories;
61
+	}
62
+
63
+	/**
64
+	 * @param string $file
65
+	 *
66
+	 * @return bool
67
+	 */
68
+	public function isBlacklisted($file)
69
+	{
70
+		if (\defined('PHPUNIT_TESTSUITE')) {
71
+			return false;
72
+		}
73
+
74
+		$this->initialize();
75
+
76
+		foreach (self::$directories as $directory) {
77
+			if (\strpos($file, $directory) === 0) {
78
+				return true;
79
+			}
80
+		}
81
+
82
+		return false;
83
+	}
84
+
85
+	private function initialize()
86
+	{
87
+		if (self::$directories === null) {
88
+			self::$directories = [];
89
+
90
+			foreach (self::$blacklistedClassNames as $className => $parent) {
91
+				if (!\class_exists($className)) {
92
+					continue;
93
+				}
94
+
95
+				$reflector = new ReflectionClass($className);
96
+				$directory = $reflector->getFileName();
97
+
98
+				for ($i = 0; $i < $parent; $i++) {
99
+					$directory = \dirname($directory);
100
+				}
101
+
102
+				self::$directories[] = $directory;
103
+			}
104
+
105
+			// Hide process isolation workaround on Windows.
106
+			if (DIRECTORY_SEPARATOR === '\\') {
107
+				// tempnam() prefix is limited to first 3 chars.
108
+				// @see http://php.net/manual/en/function.tempnam.php
109
+				self::$directories[] = \sys_get_temp_dir() . '\\PHP';
110
+			}
111
+		}
112
+	}
113 113
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Util/Xml.php 1 patch
Indentation   +289 added lines, -289 removed lines patch added patch discarded remove patch
@@ -22,293 +22,293 @@
 block discarded – undo
22 22
  */
23 23
 class Xml
24 24
 {
25
-    /**
26
-     * Load an $actual document into a DOMDocument.  This is called
27
-     * from the selector assertions.
28
-     *
29
-     * If $actual is already a DOMDocument, it is returned with
30
-     * no changes.  Otherwise, $actual is loaded into a new DOMDocument
31
-     * as either HTML or XML, depending on the value of $isHtml. If $isHtml is
32
-     * false and $xinclude is true, xinclude is performed on the loaded
33
-     * DOMDocument.
34
-     *
35
-     * Note: prior to PHPUnit 3.3.0, this method loaded a file and
36
-     * not a string as it currently does.  To load a file into a
37
-     * DOMDocument, use loadFile() instead.
38
-     *
39
-     * @param string|DOMDocument $actual
40
-     * @param bool               $isHtml
41
-     * @param string             $filename
42
-     * @param bool               $xinclude
43
-     * @param bool               $strict
44
-     *
45
-     * @return DOMDocument
46
-     */
47
-    public static function load($actual, $isHtml = false, $filename = '', $xinclude = false, $strict = false)
48
-    {
49
-        if ($actual instanceof DOMDocument) {
50
-            return $actual;
51
-        }
52
-
53
-        if (!\is_string($actual)) {
54
-            throw new Exception('Could not load XML from ' . \gettype($actual));
55
-        }
56
-
57
-        if ($actual === '') {
58
-            throw new Exception('Could not load XML from empty string');
59
-        }
60
-
61
-        // Required for XInclude on Windows.
62
-        if ($xinclude) {
63
-            $cwd = \getcwd();
64
-            @\chdir(\dirname($filename));
65
-        }
66
-
67
-        $document                     = new DOMDocument;
68
-        $document->preserveWhiteSpace = false;
69
-
70
-        $internal  = \libxml_use_internal_errors(true);
71
-        $message   = '';
72
-        $reporting = \error_reporting(0);
73
-
74
-        if ('' !== $filename) {
75
-            // Necessary for xinclude
76
-            $document->documentURI = $filename;
77
-        }
78
-
79
-        if ($isHtml) {
80
-            $loaded = $document->loadHTML($actual);
81
-        } else {
82
-            $loaded = $document->loadXML($actual);
83
-        }
84
-
85
-        if (!$isHtml && $xinclude) {
86
-            $document->xinclude();
87
-        }
88
-
89
-        foreach (\libxml_get_errors() as $error) {
90
-            $message .= "\n" . $error->message;
91
-        }
92
-
93
-        \libxml_use_internal_errors($internal);
94
-        \error_reporting($reporting);
95
-
96
-        if (isset($cwd)) {
97
-            @\chdir($cwd);
98
-        }
99
-
100
-        if ($loaded === false || ($strict && $message !== '')) {
101
-            if ($filename !== '') {
102
-                throw new Exception(
103
-                    \sprintf(
104
-                        'Could not load "%s".%s',
105
-                        $filename,
106
-                        $message != '' ? "\n" . $message : ''
107
-                    )
108
-                );
109
-            }
110
-
111
-            if ($message === '') {
112
-                $message = 'Could not load XML for unknown reason';
113
-            }
114
-
115
-            throw new Exception($message);
116
-        }
117
-
118
-        return $document;
119
-    }
120
-
121
-    /**
122
-     * Loads an XML (or HTML) file into a DOMDocument object.
123
-     *
124
-     * @param string $filename
125
-     * @param bool   $isHtml
126
-     * @param bool   $xinclude
127
-     * @param bool   $strict
128
-     *
129
-     * @return DOMDocument
130
-     */
131
-    public static function loadFile($filename, $isHtml = false, $xinclude = false, $strict = false)
132
-    {
133
-        $reporting = \error_reporting(0);
134
-        $contents  = \file_get_contents($filename);
135
-        \error_reporting($reporting);
136
-
137
-        if ($contents === false) {
138
-            throw new Exception(
139
-                \sprintf(
140
-                    'Could not read "%s".',
141
-                    $filename
142
-                )
143
-            );
144
-        }
145
-
146
-        return self::load($contents, $isHtml, $filename, $xinclude, $strict);
147
-    }
148
-
149
-    /**
150
-     * @param DOMNode $node
151
-     */
152
-    public static function removeCharacterDataNodes(DOMNode $node)
153
-    {
154
-        if ($node->hasChildNodes()) {
155
-            for ($i = $node->childNodes->length - 1; $i >= 0; $i--) {
156
-                if (($child = $node->childNodes->item($i)) instanceof DOMCharacterData) {
157
-                    $node->removeChild($child);
158
-                }
159
-            }
160
-        }
161
-    }
162
-
163
-    /**
164
-     * Escapes a string for the use in XML documents
165
-     * Any Unicode character is allowed, excluding the surrogate blocks, FFFE,
166
-     * and FFFF (not even as character reference).
167
-     * See http://www.w3.org/TR/xml/#charsets
168
-     *
169
-     * @param string $string
170
-     *
171
-     * @return string
172
-     */
173
-    public static function prepareString($string)
174
-    {
175
-        return \preg_replace(
176
-            '/[\\x00-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]/',
177
-            '',
178
-            \htmlspecialchars(
179
-                self::convertToUtf8($string),
180
-                ENT_QUOTES,
181
-                'UTF-8'
182
-            )
183
-        );
184
-    }
185
-
186
-    /**
187
-     * "Convert" a DOMElement object into a PHP variable.
188
-     *
189
-     * @param DOMElement $element
190
-     *
191
-     * @return mixed
192
-     */
193
-    public static function xmlToVariable(DOMElement $element)
194
-    {
195
-        $variable = null;
196
-
197
-        switch ($element->tagName) {
198
-            case 'array':
199
-                $variable = [];
200
-
201
-                foreach ($element->childNodes as $entry) {
202
-                    if (!$entry instanceof DOMElement || $entry->tagName !== 'element') {
203
-                        continue;
204
-                    }
205
-                    $item = $entry->childNodes->item(0);
206
-
207
-                    if ($item instanceof DOMText) {
208
-                        $item = $entry->childNodes->item(1);
209
-                    }
210
-
211
-                    $value = self::xmlToVariable($item);
212
-
213
-                    if ($entry->hasAttribute('key')) {
214
-                        $variable[(string) $entry->getAttribute('key')] = $value;
215
-                    } else {
216
-                        $variable[] = $value;
217
-                    }
218
-                }
219
-
220
-                break;
221
-
222
-            case 'object':
223
-                $className = $element->getAttribute('class');
224
-
225
-                if ($element->hasChildNodes()) {
226
-                    $arguments       = $element->childNodes->item(0)->childNodes;
227
-                    $constructorArgs = [];
228
-
229
-                    foreach ($arguments as $argument) {
230
-                        if ($argument instanceof DOMElement) {
231
-                            $constructorArgs[] = self::xmlToVariable($argument);
232
-                        }
233
-                    }
234
-
235
-                    $class    = new ReflectionClass($className);
236
-                    $variable = $class->newInstanceArgs($constructorArgs);
237
-                } else {
238
-                    $variable = new $className;
239
-                }
240
-
241
-                break;
242
-
243
-            case 'boolean':
244
-                $variable = $element->textContent == 'true';
245
-
246
-                break;
247
-
248
-            case 'integer':
249
-            case 'double':
250
-            case 'string':
251
-                $variable = $element->textContent;
252
-
253
-                \settype($variable, $element->tagName);
254
-
255
-                break;
256
-        }
257
-
258
-        return $variable;
259
-    }
260
-
261
-    /**
262
-     * Converts a string to UTF-8 encoding.
263
-     *
264
-     * @param string $string
265
-     *
266
-     * @return string
267
-     */
268
-    private static function convertToUtf8($string)
269
-    {
270
-        if (!self::isUtf8($string)) {
271
-            if (\function_exists('mb_convert_encoding')) {
272
-                return \mb_convert_encoding($string, 'UTF-8');
273
-            }
274
-
275
-            return \utf8_encode($string);
276
-        }
277
-
278
-        return $string;
279
-    }
280
-
281
-    /**
282
-     * Checks a string for UTF-8 encoding.
283
-     *
284
-     * @param string $string
285
-     *
286
-     * @return bool
287
-     */
288
-    private static function isUtf8($string)
289
-    {
290
-        $length = \strlen($string);
291
-
292
-        for ($i = 0; $i < $length; $i++) {
293
-            if (\ord($string[$i]) < 0x80) {
294
-                $n = 0;
295
-            } elseif ((\ord($string[$i]) & 0xE0) == 0xC0) {
296
-                $n = 1;
297
-            } elseif ((\ord($string[$i]) & 0xF0) == 0xE0) {
298
-                $n = 2;
299
-            } elseif ((\ord($string[$i]) & 0xF0) == 0xF0) {
300
-                $n = 3;
301
-            } else {
302
-                return false;
303
-            }
304
-
305
-            for ($j = 0; $j < $n; $j++) {
306
-                if ((++$i == $length) || ((\ord($string[$i]) & 0xC0) != 0x80)) {
307
-                    return false;
308
-                }
309
-            }
310
-        }
311
-
312
-        return true;
313
-    }
25
+	/**
26
+	 * Load an $actual document into a DOMDocument.  This is called
27
+	 * from the selector assertions.
28
+	 *
29
+	 * If $actual is already a DOMDocument, it is returned with
30
+	 * no changes.  Otherwise, $actual is loaded into a new DOMDocument
31
+	 * as either HTML or XML, depending on the value of $isHtml. If $isHtml is
32
+	 * false and $xinclude is true, xinclude is performed on the loaded
33
+	 * DOMDocument.
34
+	 *
35
+	 * Note: prior to PHPUnit 3.3.0, this method loaded a file and
36
+	 * not a string as it currently does.  To load a file into a
37
+	 * DOMDocument, use loadFile() instead.
38
+	 *
39
+	 * @param string|DOMDocument $actual
40
+	 * @param bool               $isHtml
41
+	 * @param string             $filename
42
+	 * @param bool               $xinclude
43
+	 * @param bool               $strict
44
+	 *
45
+	 * @return DOMDocument
46
+	 */
47
+	public static function load($actual, $isHtml = false, $filename = '', $xinclude = false, $strict = false)
48
+	{
49
+		if ($actual instanceof DOMDocument) {
50
+			return $actual;
51
+		}
52
+
53
+		if (!\is_string($actual)) {
54
+			throw new Exception('Could not load XML from ' . \gettype($actual));
55
+		}
56
+
57
+		if ($actual === '') {
58
+			throw new Exception('Could not load XML from empty string');
59
+		}
60
+
61
+		// Required for XInclude on Windows.
62
+		if ($xinclude) {
63
+			$cwd = \getcwd();
64
+			@\chdir(\dirname($filename));
65
+		}
66
+
67
+		$document                     = new DOMDocument;
68
+		$document->preserveWhiteSpace = false;
69
+
70
+		$internal  = \libxml_use_internal_errors(true);
71
+		$message   = '';
72
+		$reporting = \error_reporting(0);
73
+
74
+		if ('' !== $filename) {
75
+			// Necessary for xinclude
76
+			$document->documentURI = $filename;
77
+		}
78
+
79
+		if ($isHtml) {
80
+			$loaded = $document->loadHTML($actual);
81
+		} else {
82
+			$loaded = $document->loadXML($actual);
83
+		}
84
+
85
+		if (!$isHtml && $xinclude) {
86
+			$document->xinclude();
87
+		}
88
+
89
+		foreach (\libxml_get_errors() as $error) {
90
+			$message .= "\n" . $error->message;
91
+		}
92
+
93
+		\libxml_use_internal_errors($internal);
94
+		\error_reporting($reporting);
95
+
96
+		if (isset($cwd)) {
97
+			@\chdir($cwd);
98
+		}
99
+
100
+		if ($loaded === false || ($strict && $message !== '')) {
101
+			if ($filename !== '') {
102
+				throw new Exception(
103
+					\sprintf(
104
+						'Could not load "%s".%s',
105
+						$filename,
106
+						$message != '' ? "\n" . $message : ''
107
+					)
108
+				);
109
+			}
110
+
111
+			if ($message === '') {
112
+				$message = 'Could not load XML for unknown reason';
113
+			}
114
+
115
+			throw new Exception($message);
116
+		}
117
+
118
+		return $document;
119
+	}
120
+
121
+	/**
122
+	 * Loads an XML (or HTML) file into a DOMDocument object.
123
+	 *
124
+	 * @param string $filename
125
+	 * @param bool   $isHtml
126
+	 * @param bool   $xinclude
127
+	 * @param bool   $strict
128
+	 *
129
+	 * @return DOMDocument
130
+	 */
131
+	public static function loadFile($filename, $isHtml = false, $xinclude = false, $strict = false)
132
+	{
133
+		$reporting = \error_reporting(0);
134
+		$contents  = \file_get_contents($filename);
135
+		\error_reporting($reporting);
136
+
137
+		if ($contents === false) {
138
+			throw new Exception(
139
+				\sprintf(
140
+					'Could not read "%s".',
141
+					$filename
142
+				)
143
+			);
144
+		}
145
+
146
+		return self::load($contents, $isHtml, $filename, $xinclude, $strict);
147
+	}
148
+
149
+	/**
150
+	 * @param DOMNode $node
151
+	 */
152
+	public static function removeCharacterDataNodes(DOMNode $node)
153
+	{
154
+		if ($node->hasChildNodes()) {
155
+			for ($i = $node->childNodes->length - 1; $i >= 0; $i--) {
156
+				if (($child = $node->childNodes->item($i)) instanceof DOMCharacterData) {
157
+					$node->removeChild($child);
158
+				}
159
+			}
160
+		}
161
+	}
162
+
163
+	/**
164
+	 * Escapes a string for the use in XML documents
165
+	 * Any Unicode character is allowed, excluding the surrogate blocks, FFFE,
166
+	 * and FFFF (not even as character reference).
167
+	 * See http://www.w3.org/TR/xml/#charsets
168
+	 *
169
+	 * @param string $string
170
+	 *
171
+	 * @return string
172
+	 */
173
+	public static function prepareString($string)
174
+	{
175
+		return \preg_replace(
176
+			'/[\\x00-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]/',
177
+			'',
178
+			\htmlspecialchars(
179
+				self::convertToUtf8($string),
180
+				ENT_QUOTES,
181
+				'UTF-8'
182
+			)
183
+		);
184
+	}
185
+
186
+	/**
187
+	 * "Convert" a DOMElement object into a PHP variable.
188
+	 *
189
+	 * @param DOMElement $element
190
+	 *
191
+	 * @return mixed
192
+	 */
193
+	public static function xmlToVariable(DOMElement $element)
194
+	{
195
+		$variable = null;
196
+
197
+		switch ($element->tagName) {
198
+			case 'array':
199
+				$variable = [];
200
+
201
+				foreach ($element->childNodes as $entry) {
202
+					if (!$entry instanceof DOMElement || $entry->tagName !== 'element') {
203
+						continue;
204
+					}
205
+					$item = $entry->childNodes->item(0);
206
+
207
+					if ($item instanceof DOMText) {
208
+						$item = $entry->childNodes->item(1);
209
+					}
210
+
211
+					$value = self::xmlToVariable($item);
212
+
213
+					if ($entry->hasAttribute('key')) {
214
+						$variable[(string) $entry->getAttribute('key')] = $value;
215
+					} else {
216
+						$variable[] = $value;
217
+					}
218
+				}
219
+
220
+				break;
221
+
222
+			case 'object':
223
+				$className = $element->getAttribute('class');
224
+
225
+				if ($element->hasChildNodes()) {
226
+					$arguments       = $element->childNodes->item(0)->childNodes;
227
+					$constructorArgs = [];
228
+
229
+					foreach ($arguments as $argument) {
230
+						if ($argument instanceof DOMElement) {
231
+							$constructorArgs[] = self::xmlToVariable($argument);
232
+						}
233
+					}
234
+
235
+					$class    = new ReflectionClass($className);
236
+					$variable = $class->newInstanceArgs($constructorArgs);
237
+				} else {
238
+					$variable = new $className;
239
+				}
240
+
241
+				break;
242
+
243
+			case 'boolean':
244
+				$variable = $element->textContent == 'true';
245
+
246
+				break;
247
+
248
+			case 'integer':
249
+			case 'double':
250
+			case 'string':
251
+				$variable = $element->textContent;
252
+
253
+				\settype($variable, $element->tagName);
254
+
255
+				break;
256
+		}
257
+
258
+		return $variable;
259
+	}
260
+
261
+	/**
262
+	 * Converts a string to UTF-8 encoding.
263
+	 *
264
+	 * @param string $string
265
+	 *
266
+	 * @return string
267
+	 */
268
+	private static function convertToUtf8($string)
269
+	{
270
+		if (!self::isUtf8($string)) {
271
+			if (\function_exists('mb_convert_encoding')) {
272
+				return \mb_convert_encoding($string, 'UTF-8');
273
+			}
274
+
275
+			return \utf8_encode($string);
276
+		}
277
+
278
+		return $string;
279
+	}
280
+
281
+	/**
282
+	 * Checks a string for UTF-8 encoding.
283
+	 *
284
+	 * @param string $string
285
+	 *
286
+	 * @return bool
287
+	 */
288
+	private static function isUtf8($string)
289
+	{
290
+		$length = \strlen($string);
291
+
292
+		for ($i = 0; $i < $length; $i++) {
293
+			if (\ord($string[$i]) < 0x80) {
294
+				$n = 0;
295
+			} elseif ((\ord($string[$i]) & 0xE0) == 0xC0) {
296
+				$n = 1;
297
+			} elseif ((\ord($string[$i]) & 0xF0) == 0xE0) {
298
+				$n = 2;
299
+			} elseif ((\ord($string[$i]) & 0xF0) == 0xF0) {
300
+				$n = 3;
301
+			} else {
302
+				return false;
303
+			}
304
+
305
+			for ($j = 0; $j < $n; $j++) {
306
+				if ((++$i == $length) || ((\ord($string[$i]) & 0xC0) != 0x80)) {
307
+					return false;
308
+				}
309
+			}
310
+		}
311
+
312
+		return true;
313
+	}
314 314
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Util/InvalidArgumentHelper.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -17,26 +17,26 @@
 block discarded – undo
17 17
  */
18 18
 class InvalidArgumentHelper
19 19
 {
20
-    /**
21
-     * @param int    $argument
22
-     * @param string $type
23
-     * @param mixed  $value
24
-     *
25
-     * @return Exception
26
-     */
27
-    public static function factory($argument, $type, $value = null)
28
-    {
29
-        $stack = \debug_backtrace();
20
+	/**
21
+	 * @param int    $argument
22
+	 * @param string $type
23
+	 * @param mixed  $value
24
+	 *
25
+	 * @return Exception
26
+	 */
27
+	public static function factory($argument, $type, $value = null)
28
+	{
29
+		$stack = \debug_backtrace();
30 30
 
31
-        return new Exception(
32
-            \sprintf(
33
-                'Argument #%d%sof %s::%s() must be a %s',
34
-                $argument,
35
-                $value !== null ? ' (' . \gettype($value) . '#' . $value . ')' : ' (No Value) ',
36
-                $stack[1]['class'],
37
-                $stack[1]['function'],
38
-                $type
39
-            )
40
-        );
41
-    }
31
+		return new Exception(
32
+			\sprintf(
33
+				'Argument #%d%sof %s::%s() must be a %s',
34
+				$argument,
35
+				$value !== null ? ' (' . \gettype($value) . '#' . $value . ')' : ' (No Value) ',
36
+				$stack[1]['class'],
37
+				$stack[1]['function'],
38
+				$type
39
+			)
40
+		);
41
+	}
42 42
 }
Please login to merge, or discard this patch.