Completed
Push — master ( 52755b...6c4366 )
by smiley
02:13
created
vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,4 +7,4 @@
 block discarded – undo
7 7
  * For the full copyright and license information, please view the LICENSE
8 8
  * file that was distributed with this source code.
9 9
  */
10
-eval('?>' . \file_get_contents('php://stdin'));
10
+eval('?>'.\file_get_contents('php://stdin'));
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Util/PHP/AbstractPhpProcess.php 2 patches
Indentation   +393 added lines, -393 removed lines patch added patch discarded remove patch
@@ -25,397 +25,397 @@
 block discarded – undo
25 25
  */
26 26
 abstract class AbstractPhpProcess
27 27
 {
28
-    /**
29
-     * @var Runtime
30
-     */
31
-    protected $runtime;
32
-
33
-    /**
34
-     * @var bool
35
-     */
36
-    protected $stderrRedirection = false;
37
-
38
-    /**
39
-     * @var string
40
-     */
41
-    protected $stdin = '';
42
-
43
-    /**
44
-     * @var string
45
-     */
46
-    protected $args = '';
47
-
48
-    /**
49
-     * @var array<string, string>
50
-     */
51
-    protected $env = [];
52
-
53
-    /**
54
-     * @var int
55
-     */
56
-    protected $timeout = 0;
57
-
58
-    /**
59
-     * Creates internal Runtime instance.
60
-     */
61
-    public function __construct()
62
-    {
63
-        $this->runtime = new Runtime();
64
-    }
65
-
66
-    /**
67
-     * Defines if should use STDERR redirection or not.
68
-     *
69
-     * Then $stderrRedirection is TRUE, STDERR is redirected to STDOUT.
70
-     *
71
-     * @throws Exception
72
-     *
73
-     * @param bool $stderrRedirection
74
-     */
75
-    public function setUseStderrRedirection($stderrRedirection)
76
-    {
77
-        if (!\is_bool($stderrRedirection)) {
78
-            throw InvalidArgumentHelper::factory(1, 'boolean');
79
-        }
80
-
81
-        $this->stderrRedirection = $stderrRedirection;
82
-    }
83
-
84
-    /**
85
-     * Returns TRUE if uses STDERR redirection or FALSE if not.
86
-     *
87
-     * @return bool
88
-     */
89
-    public function useStderrRedirection()
90
-    {
91
-        return $this->stderrRedirection;
92
-    }
93
-
94
-    /**
95
-     * Sets the input string to be sent via STDIN
96
-     *
97
-     * @param string $stdin
98
-     */
99
-    public function setStdin($stdin)
100
-    {
101
-        $this->stdin = (string) $stdin;
102
-    }
103
-
104
-    /**
105
-     * Returns the input string to be sent via STDIN
106
-     *
107
-     * @return string
108
-     */
109
-    public function getStdin()
110
-    {
111
-        return $this->stdin;
112
-    }
113
-
114
-    /**
115
-     * Sets the string of arguments to pass to the php job
116
-     *
117
-     * @param string $args
118
-     */
119
-    public function setArgs($args)
120
-    {
121
-        $this->args = (string) $args;
122
-    }
123
-
124
-    /**
125
-     * Returns the string of arguments to pass to the php job
126
-     *
127
-     * @retrun string
128
-     */
129
-    public function getArgs()
130
-    {
131
-        return $this->args;
132
-    }
133
-
134
-    /**
135
-     * Sets the array of environment variables to start the child process with
136
-     *
137
-     * @param array<string, string> $env
138
-     */
139
-    public function setEnv(array $env)
140
-    {
141
-        $this->env = $env;
142
-    }
143
-
144
-    /**
145
-     * Returns the array of environment variables to start the child process with
146
-     *
147
-     * @return array<string, string>
148
-     */
149
-    public function getEnv()
150
-    {
151
-        return $this->env;
152
-    }
153
-
154
-    /**
155
-     * Sets the amount of seconds to wait before timing out
156
-     *
157
-     * @param int $timeout
158
-     */
159
-    public function setTimeout($timeout)
160
-    {
161
-        $this->timeout = (int) $timeout;
162
-    }
163
-
164
-    /**
165
-     * Returns the amount of seconds to wait before timing out
166
-     *
167
-     * @return int
168
-     */
169
-    public function getTimeout()
170
-    {
171
-        return $this->timeout;
172
-    }
173
-
174
-    /**
175
-     * @return AbstractPhpProcess
176
-     */
177
-    public static function factory()
178
-    {
179
-        if (DIRECTORY_SEPARATOR == '\\') {
180
-            return new WindowsPhpProcess;
181
-        }
182
-
183
-        return new DefaultPhpProcess;
184
-    }
185
-
186
-    /**
187
-     * Runs a single test in a separate PHP process.
188
-     *
189
-     * @param string     $job
190
-     * @param Test       $test
191
-     * @param TestResult $result
192
-     *
193
-     * @throws Exception
194
-     */
195
-    public function runTestJob($job, Test $test, TestResult $result)
196
-    {
197
-        $result->startTest($test);
198
-
199
-        $_result = $this->runJob($job);
200
-
201
-        $this->processChildResult(
202
-            $test,
203
-            $result,
204
-            $_result['stdout'],
205
-            $_result['stderr']
206
-        );
207
-    }
208
-
209
-    /**
210
-     * Returns the command based into the configurations.
211
-     *
212
-     * @param array       $settings
213
-     * @param string|null $file
214
-     *
215
-     * @return string
216
-     */
217
-    public function getCommand(array $settings, $file = null)
218
-    {
219
-        $command = $this->runtime->getBinary();
220
-        $command .= $this->settingsToParameters($settings);
221
-
222
-        if ('phpdbg' === PHP_SAPI) {
223
-            $command .= ' -qrr ';
224
-
225
-            if ($file) {
226
-                $command .= '-e ' . \escapeshellarg($file);
227
-            } else {
228
-                $command .= \escapeshellarg(__DIR__ . '/eval-stdin.php');
229
-            }
230
-        } elseif ($file) {
231
-            $command .= ' -f ' . \escapeshellarg($file);
232
-        }
233
-
234
-        if ($this->args) {
235
-            $command .= ' -- ' . $this->args;
236
-        }
237
-
238
-        if (true === $this->stderrRedirection) {
239
-            $command .= ' 2>&1';
240
-        }
241
-
242
-        return $command;
243
-    }
244
-
245
-    /**
246
-     * Runs a single job (PHP code) using a separate PHP process.
247
-     *
248
-     * @param string $job
249
-     * @param array  $settings
250
-     *
251
-     * @return array
252
-     *
253
-     * @throws Exception
254
-     */
255
-    abstract public function runJob($job, array $settings = []);
256
-
257
-    /**
258
-     * @param array $settings
259
-     *
260
-     * @return string
261
-     */
262
-    protected function settingsToParameters(array $settings)
263
-    {
264
-        $buffer = '';
265
-
266
-        foreach ($settings as $setting) {
267
-            $buffer .= ' -d ' . $setting;
268
-        }
269
-
270
-        return $buffer;
271
-    }
272
-
273
-    /**
274
-     * Processes the TestResult object from an isolated process.
275
-     *
276
-     * @param Test       $test
277
-     * @param TestResult $result
278
-     * @param string     $stdout
279
-     * @param string     $stderr
280
-     */
281
-    private function processChildResult(Test $test, TestResult $result, $stdout, $stderr)
282
-    {
283
-        $time = 0;
284
-
285
-        if (!empty($stderr)) {
286
-            $result->addError(
287
-                $test,
288
-                new Exception(\trim($stderr)),
289
-                $time
290
-            );
291
-        } else {
292
-            \set_error_handler(function ($errno, $errstr, $errfile, $errline) {
293
-                throw new ErrorException($errstr, $errno, $errno, $errfile, $errline);
294
-            });
295
-
296
-            try {
297
-                if (\strpos($stdout, "#!/usr/bin/env php\n") === 0) {
298
-                    $stdout = \substr($stdout, 19);
299
-                }
300
-
301
-                $childResult = \unserialize(\str_replace("#!/usr/bin/env php\n", '', $stdout));
302
-                \restore_error_handler();
303
-            } catch (ErrorException $e) {
304
-                \restore_error_handler();
305
-                $childResult = false;
306
-
307
-                $result->addError(
308
-                    $test,
309
-                    new Exception(\trim($stdout), 0, $e),
310
-                    $time
311
-                );
312
-            }
313
-
314
-            if ($childResult !== false) {
315
-                if (!empty($childResult['output'])) {
316
-                    $output = $childResult['output'];
317
-                }
318
-
319
-                $test->setResult($childResult['testResult']);
320
-                $test->addToAssertionCount($childResult['numAssertions']);
321
-
322
-                /** @var TestResult $childResult */
323
-                $childResult = $childResult['result'];
324
-
325
-                if ($result->getCollectCodeCoverageInformation()) {
326
-                    $result->getCodeCoverage()->merge(
327
-                        $childResult->getCodeCoverage()
328
-                    );
329
-                }
330
-
331
-                $time           = $childResult->time();
332
-                $notImplemented = $childResult->notImplemented();
333
-                $risky          = $childResult->risky();
334
-                $skipped        = $childResult->skipped();
335
-                $errors         = $childResult->errors();
336
-                $warnings       = $childResult->warnings();
337
-                $failures       = $childResult->failures();
338
-
339
-                if (!empty($notImplemented)) {
340
-                    $result->addError(
341
-                        $test,
342
-                        $this->getException($notImplemented[0]),
343
-                        $time
344
-                    );
345
-                } elseif (!empty($risky)) {
346
-                    $result->addError(
347
-                        $test,
348
-                        $this->getException($risky[0]),
349
-                        $time
350
-                    );
351
-                } elseif (!empty($skipped)) {
352
-                    $result->addError(
353
-                        $test,
354
-                        $this->getException($skipped[0]),
355
-                        $time
356
-                    );
357
-                } elseif (!empty($errors)) {
358
-                    $result->addError(
359
-                        $test,
360
-                        $this->getException($errors[0]),
361
-                        $time
362
-                    );
363
-                } elseif (!empty($warnings)) {
364
-                    $result->addWarning(
365
-                        $test,
366
-                        $this->getException($warnings[0]),
367
-                        $time
368
-                    );
369
-                } elseif (!empty($failures)) {
370
-                    $result->addFailure(
371
-                        $test,
372
-                        $this->getException($failures[0]),
373
-                        $time
374
-                    );
375
-                }
376
-            }
377
-        }
378
-
379
-        $result->endTest($test, $time);
380
-
381
-        if (!empty($output)) {
382
-            print $output;
383
-        }
384
-    }
385
-
386
-    /**
387
-     * Gets the thrown exception from a PHPUnit\Framework\TestFailure.
388
-     *
389
-     * @param TestFailure $error
390
-     *
391
-     * @return Exception
392
-     *
393
-     * @see    https://github.com/sebastianbergmann/phpunit/issues/74
394
-     */
395
-    private function getException(TestFailure $error)
396
-    {
397
-        $exception = $error->thrownException();
398
-
399
-        if ($exception instanceof __PHP_Incomplete_Class) {
400
-            $exceptionArray = [];
401
-            foreach ((array) $exception as $key => $value) {
402
-                $key                  = \substr($key, \strrpos($key, "\0") + 1);
403
-                $exceptionArray[$key] = $value;
404
-            }
405
-
406
-            $exception = new SyntheticError(
407
-                \sprintf(
408
-                    '%s: %s',
409
-                    $exceptionArray['_PHP_Incomplete_Class_Name'],
410
-                    $exceptionArray['message']
411
-                ),
412
-                $exceptionArray['code'],
413
-                $exceptionArray['file'],
414
-                $exceptionArray['line'],
415
-                $exceptionArray['trace']
416
-            );
417
-        }
418
-
419
-        return $exception;
420
-    }
28
+	/**
29
+	 * @var Runtime
30
+	 */
31
+	protected $runtime;
32
+
33
+	/**
34
+	 * @var bool
35
+	 */
36
+	protected $stderrRedirection = false;
37
+
38
+	/**
39
+	 * @var string
40
+	 */
41
+	protected $stdin = '';
42
+
43
+	/**
44
+	 * @var string
45
+	 */
46
+	protected $args = '';
47
+
48
+	/**
49
+	 * @var array<string, string>
50
+	 */
51
+	protected $env = [];
52
+
53
+	/**
54
+	 * @var int
55
+	 */
56
+	protected $timeout = 0;
57
+
58
+	/**
59
+	 * Creates internal Runtime instance.
60
+	 */
61
+	public function __construct()
62
+	{
63
+		$this->runtime = new Runtime();
64
+	}
65
+
66
+	/**
67
+	 * Defines if should use STDERR redirection or not.
68
+	 *
69
+	 * Then $stderrRedirection is TRUE, STDERR is redirected to STDOUT.
70
+	 *
71
+	 * @throws Exception
72
+	 *
73
+	 * @param bool $stderrRedirection
74
+	 */
75
+	public function setUseStderrRedirection($stderrRedirection)
76
+	{
77
+		if (!\is_bool($stderrRedirection)) {
78
+			throw InvalidArgumentHelper::factory(1, 'boolean');
79
+		}
80
+
81
+		$this->stderrRedirection = $stderrRedirection;
82
+	}
83
+
84
+	/**
85
+	 * Returns TRUE if uses STDERR redirection or FALSE if not.
86
+	 *
87
+	 * @return bool
88
+	 */
89
+	public function useStderrRedirection()
90
+	{
91
+		return $this->stderrRedirection;
92
+	}
93
+
94
+	/**
95
+	 * Sets the input string to be sent via STDIN
96
+	 *
97
+	 * @param string $stdin
98
+	 */
99
+	public function setStdin($stdin)
100
+	{
101
+		$this->stdin = (string) $stdin;
102
+	}
103
+
104
+	/**
105
+	 * Returns the input string to be sent via STDIN
106
+	 *
107
+	 * @return string
108
+	 */
109
+	public function getStdin()
110
+	{
111
+		return $this->stdin;
112
+	}
113
+
114
+	/**
115
+	 * Sets the string of arguments to pass to the php job
116
+	 *
117
+	 * @param string $args
118
+	 */
119
+	public function setArgs($args)
120
+	{
121
+		$this->args = (string) $args;
122
+	}
123
+
124
+	/**
125
+	 * Returns the string of arguments to pass to the php job
126
+	 *
127
+	 * @retrun string
128
+	 */
129
+	public function getArgs()
130
+	{
131
+		return $this->args;
132
+	}
133
+
134
+	/**
135
+	 * Sets the array of environment variables to start the child process with
136
+	 *
137
+	 * @param array<string, string> $env
138
+	 */
139
+	public function setEnv(array $env)
140
+	{
141
+		$this->env = $env;
142
+	}
143
+
144
+	/**
145
+	 * Returns the array of environment variables to start the child process with
146
+	 *
147
+	 * @return array<string, string>
148
+	 */
149
+	public function getEnv()
150
+	{
151
+		return $this->env;
152
+	}
153
+
154
+	/**
155
+	 * Sets the amount of seconds to wait before timing out
156
+	 *
157
+	 * @param int $timeout
158
+	 */
159
+	public function setTimeout($timeout)
160
+	{
161
+		$this->timeout = (int) $timeout;
162
+	}
163
+
164
+	/**
165
+	 * Returns the amount of seconds to wait before timing out
166
+	 *
167
+	 * @return int
168
+	 */
169
+	public function getTimeout()
170
+	{
171
+		return $this->timeout;
172
+	}
173
+
174
+	/**
175
+	 * @return AbstractPhpProcess
176
+	 */
177
+	public static function factory()
178
+	{
179
+		if (DIRECTORY_SEPARATOR == '\\') {
180
+			return new WindowsPhpProcess;
181
+		}
182
+
183
+		return new DefaultPhpProcess;
184
+	}
185
+
186
+	/**
187
+	 * Runs a single test in a separate PHP process.
188
+	 *
189
+	 * @param string     $job
190
+	 * @param Test       $test
191
+	 * @param TestResult $result
192
+	 *
193
+	 * @throws Exception
194
+	 */
195
+	public function runTestJob($job, Test $test, TestResult $result)
196
+	{
197
+		$result->startTest($test);
198
+
199
+		$_result = $this->runJob($job);
200
+
201
+		$this->processChildResult(
202
+			$test,
203
+			$result,
204
+			$_result['stdout'],
205
+			$_result['stderr']
206
+		);
207
+	}
208
+
209
+	/**
210
+	 * Returns the command based into the configurations.
211
+	 *
212
+	 * @param array       $settings
213
+	 * @param string|null $file
214
+	 *
215
+	 * @return string
216
+	 */
217
+	public function getCommand(array $settings, $file = null)
218
+	{
219
+		$command = $this->runtime->getBinary();
220
+		$command .= $this->settingsToParameters($settings);
221
+
222
+		if ('phpdbg' === PHP_SAPI) {
223
+			$command .= ' -qrr ';
224
+
225
+			if ($file) {
226
+				$command .= '-e ' . \escapeshellarg($file);
227
+			} else {
228
+				$command .= \escapeshellarg(__DIR__ . '/eval-stdin.php');
229
+			}
230
+		} elseif ($file) {
231
+			$command .= ' -f ' . \escapeshellarg($file);
232
+		}
233
+
234
+		if ($this->args) {
235
+			$command .= ' -- ' . $this->args;
236
+		}
237
+
238
+		if (true === $this->stderrRedirection) {
239
+			$command .= ' 2>&1';
240
+		}
241
+
242
+		return $command;
243
+	}
244
+
245
+	/**
246
+	 * Runs a single job (PHP code) using a separate PHP process.
247
+	 *
248
+	 * @param string $job
249
+	 * @param array  $settings
250
+	 *
251
+	 * @return array
252
+	 *
253
+	 * @throws Exception
254
+	 */
255
+	abstract public function runJob($job, array $settings = []);
256
+
257
+	/**
258
+	 * @param array $settings
259
+	 *
260
+	 * @return string
261
+	 */
262
+	protected function settingsToParameters(array $settings)
263
+	{
264
+		$buffer = '';
265
+
266
+		foreach ($settings as $setting) {
267
+			$buffer .= ' -d ' . $setting;
268
+		}
269
+
270
+		return $buffer;
271
+	}
272
+
273
+	/**
274
+	 * Processes the TestResult object from an isolated process.
275
+	 *
276
+	 * @param Test       $test
277
+	 * @param TestResult $result
278
+	 * @param string     $stdout
279
+	 * @param string     $stderr
280
+	 */
281
+	private function processChildResult(Test $test, TestResult $result, $stdout, $stderr)
282
+	{
283
+		$time = 0;
284
+
285
+		if (!empty($stderr)) {
286
+			$result->addError(
287
+				$test,
288
+				new Exception(\trim($stderr)),
289
+				$time
290
+			);
291
+		} else {
292
+			\set_error_handler(function ($errno, $errstr, $errfile, $errline) {
293
+				throw new ErrorException($errstr, $errno, $errno, $errfile, $errline);
294
+			});
295
+
296
+			try {
297
+				if (\strpos($stdout, "#!/usr/bin/env php\n") === 0) {
298
+					$stdout = \substr($stdout, 19);
299
+				}
300
+
301
+				$childResult = \unserialize(\str_replace("#!/usr/bin/env php\n", '', $stdout));
302
+				\restore_error_handler();
303
+			} catch (ErrorException $e) {
304
+				\restore_error_handler();
305
+				$childResult = false;
306
+
307
+				$result->addError(
308
+					$test,
309
+					new Exception(\trim($stdout), 0, $e),
310
+					$time
311
+				);
312
+			}
313
+
314
+			if ($childResult !== false) {
315
+				if (!empty($childResult['output'])) {
316
+					$output = $childResult['output'];
317
+				}
318
+
319
+				$test->setResult($childResult['testResult']);
320
+				$test->addToAssertionCount($childResult['numAssertions']);
321
+
322
+				/** @var TestResult $childResult */
323
+				$childResult = $childResult['result'];
324
+
325
+				if ($result->getCollectCodeCoverageInformation()) {
326
+					$result->getCodeCoverage()->merge(
327
+						$childResult->getCodeCoverage()
328
+					);
329
+				}
330
+
331
+				$time           = $childResult->time();
332
+				$notImplemented = $childResult->notImplemented();
333
+				$risky          = $childResult->risky();
334
+				$skipped        = $childResult->skipped();
335
+				$errors         = $childResult->errors();
336
+				$warnings       = $childResult->warnings();
337
+				$failures       = $childResult->failures();
338
+
339
+				if (!empty($notImplemented)) {
340
+					$result->addError(
341
+						$test,
342
+						$this->getException($notImplemented[0]),
343
+						$time
344
+					);
345
+				} elseif (!empty($risky)) {
346
+					$result->addError(
347
+						$test,
348
+						$this->getException($risky[0]),
349
+						$time
350
+					);
351
+				} elseif (!empty($skipped)) {
352
+					$result->addError(
353
+						$test,
354
+						$this->getException($skipped[0]),
355
+						$time
356
+					);
357
+				} elseif (!empty($errors)) {
358
+					$result->addError(
359
+						$test,
360
+						$this->getException($errors[0]),
361
+						$time
362
+					);
363
+				} elseif (!empty($warnings)) {
364
+					$result->addWarning(
365
+						$test,
366
+						$this->getException($warnings[0]),
367
+						$time
368
+					);
369
+				} elseif (!empty($failures)) {
370
+					$result->addFailure(
371
+						$test,
372
+						$this->getException($failures[0]),
373
+						$time
374
+					);
375
+				}
376
+			}
377
+		}
378
+
379
+		$result->endTest($test, $time);
380
+
381
+		if (!empty($output)) {
382
+			print $output;
383
+		}
384
+	}
385
+
386
+	/**
387
+	 * Gets the thrown exception from a PHPUnit\Framework\TestFailure.
388
+	 *
389
+	 * @param TestFailure $error
390
+	 *
391
+	 * @return Exception
392
+	 *
393
+	 * @see    https://github.com/sebastianbergmann/phpunit/issues/74
394
+	 */
395
+	private function getException(TestFailure $error)
396
+	{
397
+		$exception = $error->thrownException();
398
+
399
+		if ($exception instanceof __PHP_Incomplete_Class) {
400
+			$exceptionArray = [];
401
+			foreach ((array) $exception as $key => $value) {
402
+				$key                  = \substr($key, \strrpos($key, "\0") + 1);
403
+				$exceptionArray[$key] = $value;
404
+			}
405
+
406
+			$exception = new SyntheticError(
407
+				\sprintf(
408
+					'%s: %s',
409
+					$exceptionArray['_PHP_Incomplete_Class_Name'],
410
+					$exceptionArray['message']
411
+				),
412
+				$exceptionArray['code'],
413
+				$exceptionArray['file'],
414
+				$exceptionArray['line'],
415
+				$exceptionArray['trace']
416
+			);
417
+		}
418
+
419
+		return $exception;
420
+	}
421 421
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -223,16 +223,16 @@  discard block
 block discarded – undo
223 223
             $command .= ' -qrr ';
224 224
 
225 225
             if ($file) {
226
-                $command .= '-e ' . \escapeshellarg($file);
226
+                $command .= '-e '.\escapeshellarg($file);
227 227
             } else {
228
-                $command .= \escapeshellarg(__DIR__ . '/eval-stdin.php');
228
+                $command .= \escapeshellarg(__DIR__.'/eval-stdin.php');
229 229
             }
230 230
         } elseif ($file) {
231
-            $command .= ' -f ' . \escapeshellarg($file);
231
+            $command .= ' -f '.\escapeshellarg($file);
232 232
         }
233 233
 
234 234
         if ($this->args) {
235
-            $command .= ' -- ' . $this->args;
235
+            $command .= ' -- '.$this->args;
236 236
         }
237 237
 
238 238
         if (true === $this->stderrRedirection) {
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
         $buffer = '';
265 265
 
266 266
         foreach ($settings as $setting) {
267
-            $buffer .= ' -d ' . $setting;
267
+            $buffer .= ' -d '.$setting;
268 268
         }
269 269
 
270 270
         return $buffer;
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
                 $time
290 290
             );
291 291
         } else {
292
-            \set_error_handler(function ($errno, $errstr, $errfile, $errline) {
292
+            \set_error_handler(function($errno, $errstr, $errfile, $errline) {
293 293
                 throw new ErrorException($errstr, $errno, $errno, $errfile, $errline);
294 294
             });
295 295
 
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Util/PHP/DefaultPhpProcess.php 1 patch
Indentation   +213 added lines, -213 removed lines patch added patch discarded remove patch
@@ -16,217 +16,217 @@
 block discarded – undo
16 16
  */
17 17
 class DefaultPhpProcess extends AbstractPhpProcess
18 18
 {
19
-    /**
20
-     * @var string
21
-     */
22
-    protected $tempFile;
23
-
24
-    /**
25
-     * @var bool
26
-     */
27
-    protected $useTempFile = false;
28
-
29
-    /**
30
-     * Runs a single job (PHP code) using a separate PHP process.
31
-     *
32
-     * @param string $job
33
-     * @param array  $settings
34
-     *
35
-     * @return array<string, string>
36
-     *
37
-     * @throws Exception
38
-     */
39
-    public function runJob($job, array $settings = [])
40
-    {
41
-        if ($this->useTempFile || $this->stdin) {
42
-            if (!($this->tempFile = \tempnam(\sys_get_temp_dir(), 'PHPUnit')) ||
43
-                \file_put_contents($this->tempFile, $job) === false) {
44
-                throw new Exception(
45
-                    'Unable to write temporary file'
46
-                );
47
-            }
48
-
49
-            $job = $this->stdin;
50
-        }
51
-
52
-        return $this->runProcess($job, $settings);
53
-    }
54
-
55
-    /**
56
-     * Returns an array of file handles to be used in place of pipes
57
-     *
58
-     * @return array
59
-     */
60
-    protected function getHandles()
61
-    {
62
-        return [];
63
-    }
64
-
65
-    /**
66
-     * Handles creating the child process and returning the STDOUT and STDERR
67
-     *
68
-     * @param string $job
69
-     * @param array  $settings
70
-     *
71
-     * @return array<string, string>
72
-     *
73
-     * @throws Exception
74
-     */
75
-    protected function runProcess($job, $settings)
76
-    {
77
-        $handles = $this->getHandles();
78
-
79
-        $env = null;
80
-
81
-        if ($this->env) {
82
-            $env = $_SERVER ?? [];
83
-            unset($env['argv'], $env['argc']);
84
-            $env = \array_merge($env, $this->env);
85
-
86
-            foreach ($env as $envKey => $envVar) {
87
-                if (\is_array($envVar)) {
88
-                    unset($env[$envKey]);
89
-                }
90
-            }
91
-        }
92
-
93
-        $pipeSpec = [
94
-            0 => $handles[0] ?? ['pipe', 'r'],
95
-            1 => $handles[1] ?? ['pipe', 'w'],
96
-            2 => $handles[2] ?? ['pipe', 'w'],
97
-        ];
98
-
99
-        $process = \proc_open(
100
-            $this->getCommand($settings, $this->tempFile),
101
-            $pipeSpec,
102
-            $pipes,
103
-            null,
104
-            $env
105
-        );
106
-
107
-        if (!\is_resource($process)) {
108
-            throw new Exception(
109
-                'Unable to spawn worker process'
110
-            );
111
-        }
112
-
113
-        if ($job) {
114
-            $this->process($pipes[0], $job);
115
-        }
116
-
117
-        \fclose($pipes[0]);
118
-
119
-        if ($this->timeout) {
120
-            $stderr = $stdout = '';
121
-
122
-            unset($pipes[0]);
123
-
124
-            while (true) {
125
-                $r = $pipes;
126
-                $w = null;
127
-                $e = null;
128
-
129
-                $n = @\stream_select($r, $w, $e, $this->timeout);
130
-
131
-                if ($n === false) {
132
-                    break;
133
-                } elseif ($n === 0) {
134
-                    \proc_terminate($process, 9);
135
-
136
-                    throw new Exception(
137
-                        \sprintf(
138
-                            'Job execution aborted after %d seconds',
139
-                            $this->timeout
140
-                        )
141
-                    );
142
-                } elseif ($n > 0) {
143
-                    foreach ($r as $pipe) {
144
-                        $pipeOffset = 0;
145
-
146
-                        foreach ($pipes as $i => $origPipe) {
147
-                            if ($pipe == $origPipe) {
148
-                                $pipeOffset = $i;
149
-
150
-                                break;
151
-                            }
152
-                        }
153
-
154
-                        if (!$pipeOffset) {
155
-                            break;
156
-                        }
157
-
158
-                        $line = \fread($pipe, 8192);
159
-
160
-                        if (\strlen($line) == 0) {
161
-                            \fclose($pipes[$pipeOffset]);
162
-
163
-                            unset($pipes[$pipeOffset]);
164
-                        } else {
165
-                            if ($pipeOffset == 1) {
166
-                                $stdout .= $line;
167
-                            } else {
168
-                                $stderr .= $line;
169
-                            }
170
-                        }
171
-                    }
172
-
173
-                    if (empty($pipes)) {
174
-                        break;
175
-                    }
176
-                }
177
-            }
178
-        } else {
179
-            if (isset($pipes[1])) {
180
-                $stdout = \stream_get_contents($pipes[1]);
181
-
182
-                \fclose($pipes[1]);
183
-            }
184
-
185
-            if (isset($pipes[2])) {
186
-                $stderr = \stream_get_contents($pipes[2]);
187
-
188
-                \fclose($pipes[2]);
189
-            }
190
-        }
191
-
192
-        if (isset($handles[1])) {
193
-            \rewind($handles[1]);
194
-
195
-            $stdout = \stream_get_contents($handles[1]);
196
-
197
-            \fclose($handles[1]);
198
-        }
199
-
200
-        if (isset($handles[2])) {
201
-            \rewind($handles[2]);
202
-
203
-            $stderr = \stream_get_contents($handles[2]);
204
-
205
-            \fclose($handles[2]);
206
-        }
207
-
208
-        \proc_close($process);
209
-
210
-        $this->cleanup();
211
-
212
-        return ['stdout' => $stdout, 'stderr' => $stderr];
213
-    }
214
-
215
-    /**
216
-     * @param resource $pipe
217
-     * @param string   $job
218
-     *
219
-     * @throws Exception
220
-     */
221
-    protected function process($pipe, $job)
222
-    {
223
-        \fwrite($pipe, $job);
224
-    }
225
-
226
-    protected function cleanup()
227
-    {
228
-        if ($this->tempFile) {
229
-            \unlink($this->tempFile);
230
-        }
231
-    }
19
+	/**
20
+	 * @var string
21
+	 */
22
+	protected $tempFile;
23
+
24
+	/**
25
+	 * @var bool
26
+	 */
27
+	protected $useTempFile = false;
28
+
29
+	/**
30
+	 * Runs a single job (PHP code) using a separate PHP process.
31
+	 *
32
+	 * @param string $job
33
+	 * @param array  $settings
34
+	 *
35
+	 * @return array<string, string>
36
+	 *
37
+	 * @throws Exception
38
+	 */
39
+	public function runJob($job, array $settings = [])
40
+	{
41
+		if ($this->useTempFile || $this->stdin) {
42
+			if (!($this->tempFile = \tempnam(\sys_get_temp_dir(), 'PHPUnit')) ||
43
+				\file_put_contents($this->tempFile, $job) === false) {
44
+				throw new Exception(
45
+					'Unable to write temporary file'
46
+				);
47
+			}
48
+
49
+			$job = $this->stdin;
50
+		}
51
+
52
+		return $this->runProcess($job, $settings);
53
+	}
54
+
55
+	/**
56
+	 * Returns an array of file handles to be used in place of pipes
57
+	 *
58
+	 * @return array
59
+	 */
60
+	protected function getHandles()
61
+	{
62
+		return [];
63
+	}
64
+
65
+	/**
66
+	 * Handles creating the child process and returning the STDOUT and STDERR
67
+	 *
68
+	 * @param string $job
69
+	 * @param array  $settings
70
+	 *
71
+	 * @return array<string, string>
72
+	 *
73
+	 * @throws Exception
74
+	 */
75
+	protected function runProcess($job, $settings)
76
+	{
77
+		$handles = $this->getHandles();
78
+
79
+		$env = null;
80
+
81
+		if ($this->env) {
82
+			$env = $_SERVER ?? [];
83
+			unset($env['argv'], $env['argc']);
84
+			$env = \array_merge($env, $this->env);
85
+
86
+			foreach ($env as $envKey => $envVar) {
87
+				if (\is_array($envVar)) {
88
+					unset($env[$envKey]);
89
+				}
90
+			}
91
+		}
92
+
93
+		$pipeSpec = [
94
+			0 => $handles[0] ?? ['pipe', 'r'],
95
+			1 => $handles[1] ?? ['pipe', 'w'],
96
+			2 => $handles[2] ?? ['pipe', 'w'],
97
+		];
98
+
99
+		$process = \proc_open(
100
+			$this->getCommand($settings, $this->tempFile),
101
+			$pipeSpec,
102
+			$pipes,
103
+			null,
104
+			$env
105
+		);
106
+
107
+		if (!\is_resource($process)) {
108
+			throw new Exception(
109
+				'Unable to spawn worker process'
110
+			);
111
+		}
112
+
113
+		if ($job) {
114
+			$this->process($pipes[0], $job);
115
+		}
116
+
117
+		\fclose($pipes[0]);
118
+
119
+		if ($this->timeout) {
120
+			$stderr = $stdout = '';
121
+
122
+			unset($pipes[0]);
123
+
124
+			while (true) {
125
+				$r = $pipes;
126
+				$w = null;
127
+				$e = null;
128
+
129
+				$n = @\stream_select($r, $w, $e, $this->timeout);
130
+
131
+				if ($n === false) {
132
+					break;
133
+				} elseif ($n === 0) {
134
+					\proc_terminate($process, 9);
135
+
136
+					throw new Exception(
137
+						\sprintf(
138
+							'Job execution aborted after %d seconds',
139
+							$this->timeout
140
+						)
141
+					);
142
+				} elseif ($n > 0) {
143
+					foreach ($r as $pipe) {
144
+						$pipeOffset = 0;
145
+
146
+						foreach ($pipes as $i => $origPipe) {
147
+							if ($pipe == $origPipe) {
148
+								$pipeOffset = $i;
149
+
150
+								break;
151
+							}
152
+						}
153
+
154
+						if (!$pipeOffset) {
155
+							break;
156
+						}
157
+
158
+						$line = \fread($pipe, 8192);
159
+
160
+						if (\strlen($line) == 0) {
161
+							\fclose($pipes[$pipeOffset]);
162
+
163
+							unset($pipes[$pipeOffset]);
164
+						} else {
165
+							if ($pipeOffset == 1) {
166
+								$stdout .= $line;
167
+							} else {
168
+								$stderr .= $line;
169
+							}
170
+						}
171
+					}
172
+
173
+					if (empty($pipes)) {
174
+						break;
175
+					}
176
+				}
177
+			}
178
+		} else {
179
+			if (isset($pipes[1])) {
180
+				$stdout = \stream_get_contents($pipes[1]);
181
+
182
+				\fclose($pipes[1]);
183
+			}
184
+
185
+			if (isset($pipes[2])) {
186
+				$stderr = \stream_get_contents($pipes[2]);
187
+
188
+				\fclose($pipes[2]);
189
+			}
190
+		}
191
+
192
+		if (isset($handles[1])) {
193
+			\rewind($handles[1]);
194
+
195
+			$stdout = \stream_get_contents($handles[1]);
196
+
197
+			\fclose($handles[1]);
198
+		}
199
+
200
+		if (isset($handles[2])) {
201
+			\rewind($handles[2]);
202
+
203
+			$stderr = \stream_get_contents($handles[2]);
204
+
205
+			\fclose($handles[2]);
206
+		}
207
+
208
+		\proc_close($process);
209
+
210
+		$this->cleanup();
211
+
212
+		return ['stdout' => $stdout, 'stderr' => $stderr];
213
+	}
214
+
215
+	/**
216
+	 * @param resource $pipe
217
+	 * @param string   $job
218
+	 *
219
+	 * @throws Exception
220
+	 */
221
+	protected function process($pipe, $job)
222
+	{
223
+		\fwrite($pipe, $job);
224
+	}
225
+
226
+	protected function cleanup()
227
+	{
228
+		if ($this->tempFile) {
229
+			\unlink($this->tempFile);
230
+		}
231
+	}
232 232
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Util/GlobalState.php 2 patches
Indentation   +181 added lines, -181 removed lines patch added patch discarded remove patch
@@ -13,185 +13,185 @@
 block discarded – undo
13 13
 
14 14
 class GlobalState
15 15
 {
16
-    /**
17
-     * @var string[]
18
-     */
19
-    protected static $superGlobalArrays = [
20
-        '_ENV',
21
-        '_POST',
22
-        '_GET',
23
-        '_COOKIE',
24
-        '_SERVER',
25
-        '_FILES',
26
-        '_REQUEST'
27
-    ];
28
-
29
-    /**
30
-     * @return string
31
-     */
32
-    public static function getIncludedFilesAsString()
33
-    {
34
-        return static::processIncludedFilesAsString(\get_included_files());
35
-    }
36
-
37
-    /**
38
-     * @param array $files
39
-     *
40
-     * @return string
41
-     */
42
-    public static function processIncludedFilesAsString(array $files)
43
-    {
44
-        $blacklist = new Blacklist;
45
-        $prefix    = false;
46
-        $result    = '';
47
-
48
-        if (\defined('__PHPUNIT_PHAR__')) {
49
-            $prefix = 'phar://' . __PHPUNIT_PHAR__ . '/';
50
-        }
51
-
52
-        for ($i = \count($files) - 1; $i > 0; $i--) {
53
-            $file = $files[$i];
54
-
55
-            if ($prefix !== false && \strpos($file, $prefix) === 0) {
56
-                continue;
57
-            }
58
-
59
-            // Skip virtual file system protocols
60
-            if (\preg_match('/^(vfs|phpvfs[a-z0-9]+):/', $file)) {
61
-                continue;
62
-            }
63
-
64
-            if (!$blacklist->isBlacklisted($file) && \is_file($file)) {
65
-                $result = 'require_once \'' . $file . "';\n" . $result;
66
-            }
67
-        }
68
-
69
-        return $result;
70
-    }
71
-
72
-    /**
73
-     * @return string
74
-     */
75
-    public static function getIniSettingsAsString()
76
-    {
77
-        $result      = '';
78
-        $iniSettings = \ini_get_all(null, false);
79
-
80
-        foreach ($iniSettings as $key => $value) {
81
-            $result .= \sprintf(
82
-                '@ini_set(%s, %s);' . "\n",
83
-                self::exportVariable($key),
84
-                self::exportVariable($value)
85
-            );
86
-        }
87
-
88
-        return $result;
89
-    }
90
-
91
-    /**
92
-     * @return string
93
-     */
94
-    public static function getConstantsAsString()
95
-    {
96
-        $constants = \get_defined_constants(true);
97
-        $result    = '';
98
-
99
-        if (isset($constants['user'])) {
100
-            foreach ($constants['user'] as $name => $value) {
101
-                $result .= \sprintf(
102
-                    'if (!defined(\'%s\')) define(\'%s\', %s);' . "\n",
103
-                    $name,
104
-                    $name,
105
-                    self::exportVariable($value)
106
-                );
107
-            }
108
-        }
109
-
110
-        return $result;
111
-    }
112
-
113
-    /**
114
-     * @return string
115
-     */
116
-    public static function getGlobalsAsString()
117
-    {
118
-        $result            = '';
119
-        $superGlobalArrays = self::getSuperGlobalArrays();
120
-
121
-        foreach ($superGlobalArrays as $superGlobalArray) {
122
-            if (isset($GLOBALS[$superGlobalArray]) && \is_array($GLOBALS[$superGlobalArray])) {
123
-                foreach (\array_keys($GLOBALS[$superGlobalArray]) as $key) {
124
-                    if ($GLOBALS[$superGlobalArray][$key] instanceof Closure) {
125
-                        continue;
126
-                    }
127
-
128
-                    $result .= \sprintf(
129
-                        '$GLOBALS[\'%s\'][\'%s\'] = %s;' . "\n",
130
-                        $superGlobalArray,
131
-                        $key,
132
-                        self::exportVariable($GLOBALS[$superGlobalArray][$key])
133
-                    );
134
-                }
135
-            }
136
-        }
137
-
138
-        $blacklist   = $superGlobalArrays;
139
-        $blacklist[] = 'GLOBALS';
140
-
141
-        foreach (\array_keys($GLOBALS) as $key) {
142
-            if (!\in_array($key, $blacklist) && !$GLOBALS[$key] instanceof Closure) {
143
-                $result .= \sprintf(
144
-                    '$GLOBALS[\'%s\'] = %s;' . "\n",
145
-                    $key,
146
-                    self::exportVariable($GLOBALS[$key])
147
-                );
148
-            }
149
-        }
150
-
151
-        return $result;
152
-    }
153
-
154
-    /**
155
-     * @return string[]
156
-     */
157
-    protected static function getSuperGlobalArrays()
158
-    {
159
-        return self::$superGlobalArrays;
160
-    }
161
-
162
-    protected static function exportVariable($variable)
163
-    {
164
-        if (\is_scalar($variable) || null === $variable ||
165
-            (\is_array($variable) && self::arrayOnlyContainsScalars($variable))) {
166
-            return \var_export($variable, true);
167
-        }
168
-
169
-        return 'unserialize(' .
170
-            \var_export(\serialize($variable), true) .
171
-            ')';
172
-    }
173
-
174
-    /**
175
-     * @param array $array
176
-     *
177
-     * @return bool
178
-     */
179
-    protected static function arrayOnlyContainsScalars(array $array)
180
-    {
181
-        $result = true;
182
-
183
-        foreach ($array as $element) {
184
-            if (\is_array($element)) {
185
-                $result = self::arrayOnlyContainsScalars($element);
186
-            } elseif (!\is_scalar($element) && null !== $element) {
187
-                $result = false;
188
-            }
189
-
190
-            if ($result === false) {
191
-                break;
192
-            }
193
-        }
194
-
195
-        return $result;
196
-    }
16
+	/**
17
+	 * @var string[]
18
+	 */
19
+	protected static $superGlobalArrays = [
20
+		'_ENV',
21
+		'_POST',
22
+		'_GET',
23
+		'_COOKIE',
24
+		'_SERVER',
25
+		'_FILES',
26
+		'_REQUEST'
27
+	];
28
+
29
+	/**
30
+	 * @return string
31
+	 */
32
+	public static function getIncludedFilesAsString()
33
+	{
34
+		return static::processIncludedFilesAsString(\get_included_files());
35
+	}
36
+
37
+	/**
38
+	 * @param array $files
39
+	 *
40
+	 * @return string
41
+	 */
42
+	public static function processIncludedFilesAsString(array $files)
43
+	{
44
+		$blacklist = new Blacklist;
45
+		$prefix    = false;
46
+		$result    = '';
47
+
48
+		if (\defined('__PHPUNIT_PHAR__')) {
49
+			$prefix = 'phar://' . __PHPUNIT_PHAR__ . '/';
50
+		}
51
+
52
+		for ($i = \count($files) - 1; $i > 0; $i--) {
53
+			$file = $files[$i];
54
+
55
+			if ($prefix !== false && \strpos($file, $prefix) === 0) {
56
+				continue;
57
+			}
58
+
59
+			// Skip virtual file system protocols
60
+			if (\preg_match('/^(vfs|phpvfs[a-z0-9]+):/', $file)) {
61
+				continue;
62
+			}
63
+
64
+			if (!$blacklist->isBlacklisted($file) && \is_file($file)) {
65
+				$result = 'require_once \'' . $file . "';\n" . $result;
66
+			}
67
+		}
68
+
69
+		return $result;
70
+	}
71
+
72
+	/**
73
+	 * @return string
74
+	 */
75
+	public static function getIniSettingsAsString()
76
+	{
77
+		$result      = '';
78
+		$iniSettings = \ini_get_all(null, false);
79
+
80
+		foreach ($iniSettings as $key => $value) {
81
+			$result .= \sprintf(
82
+				'@ini_set(%s, %s);' . "\n",
83
+				self::exportVariable($key),
84
+				self::exportVariable($value)
85
+			);
86
+		}
87
+
88
+		return $result;
89
+	}
90
+
91
+	/**
92
+	 * @return string
93
+	 */
94
+	public static function getConstantsAsString()
95
+	{
96
+		$constants = \get_defined_constants(true);
97
+		$result    = '';
98
+
99
+		if (isset($constants['user'])) {
100
+			foreach ($constants['user'] as $name => $value) {
101
+				$result .= \sprintf(
102
+					'if (!defined(\'%s\')) define(\'%s\', %s);' . "\n",
103
+					$name,
104
+					$name,
105
+					self::exportVariable($value)
106
+				);
107
+			}
108
+		}
109
+
110
+		return $result;
111
+	}
112
+
113
+	/**
114
+	 * @return string
115
+	 */
116
+	public static function getGlobalsAsString()
117
+	{
118
+		$result            = '';
119
+		$superGlobalArrays = self::getSuperGlobalArrays();
120
+
121
+		foreach ($superGlobalArrays as $superGlobalArray) {
122
+			if (isset($GLOBALS[$superGlobalArray]) && \is_array($GLOBALS[$superGlobalArray])) {
123
+				foreach (\array_keys($GLOBALS[$superGlobalArray]) as $key) {
124
+					if ($GLOBALS[$superGlobalArray][$key] instanceof Closure) {
125
+						continue;
126
+					}
127
+
128
+					$result .= \sprintf(
129
+						'$GLOBALS[\'%s\'][\'%s\'] = %s;' . "\n",
130
+						$superGlobalArray,
131
+						$key,
132
+						self::exportVariable($GLOBALS[$superGlobalArray][$key])
133
+					);
134
+				}
135
+			}
136
+		}
137
+
138
+		$blacklist   = $superGlobalArrays;
139
+		$blacklist[] = 'GLOBALS';
140
+
141
+		foreach (\array_keys($GLOBALS) as $key) {
142
+			if (!\in_array($key, $blacklist) && !$GLOBALS[$key] instanceof Closure) {
143
+				$result .= \sprintf(
144
+					'$GLOBALS[\'%s\'] = %s;' . "\n",
145
+					$key,
146
+					self::exportVariable($GLOBALS[$key])
147
+				);
148
+			}
149
+		}
150
+
151
+		return $result;
152
+	}
153
+
154
+	/**
155
+	 * @return string[]
156
+	 */
157
+	protected static function getSuperGlobalArrays()
158
+	{
159
+		return self::$superGlobalArrays;
160
+	}
161
+
162
+	protected static function exportVariable($variable)
163
+	{
164
+		if (\is_scalar($variable) || null === $variable ||
165
+			(\is_array($variable) && self::arrayOnlyContainsScalars($variable))) {
166
+			return \var_export($variable, true);
167
+		}
168
+
169
+		return 'unserialize(' .
170
+			\var_export(\serialize($variable), true) .
171
+			')';
172
+	}
173
+
174
+	/**
175
+	 * @param array $array
176
+	 *
177
+	 * @return bool
178
+	 */
179
+	protected static function arrayOnlyContainsScalars(array $array)
180
+	{
181
+		$result = true;
182
+
183
+		foreach ($array as $element) {
184
+			if (\is_array($element)) {
185
+				$result = self::arrayOnlyContainsScalars($element);
186
+			} elseif (!\is_scalar($element) && null !== $element) {
187
+				$result = false;
188
+			}
189
+
190
+			if ($result === false) {
191
+				break;
192
+			}
193
+		}
194
+
195
+		return $result;
196
+	}
197 197
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
         $result    = '';
47 47
 
48 48
         if (\defined('__PHPUNIT_PHAR__')) {
49
-            $prefix = 'phar://' . __PHPUNIT_PHAR__ . '/';
49
+            $prefix = 'phar://'.__PHPUNIT_PHAR__.'/';
50 50
         }
51 51
 
52 52
         for ($i = \count($files) - 1; $i > 0; $i--) {
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
             }
63 63
 
64 64
             if (!$blacklist->isBlacklisted($file) && \is_file($file)) {
65
-                $result = 'require_once \'' . $file . "';\n" . $result;
65
+                $result = 'require_once \''.$file."';\n".$result;
66 66
             }
67 67
         }
68 68
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 
80 80
         foreach ($iniSettings as $key => $value) {
81 81
             $result .= \sprintf(
82
-                '@ini_set(%s, %s);' . "\n",
82
+                '@ini_set(%s, %s);'."\n",
83 83
                 self::exportVariable($key),
84 84
                 self::exportVariable($value)
85 85
             );
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         if (isset($constants['user'])) {
100 100
             foreach ($constants['user'] as $name => $value) {
101 101
                 $result .= \sprintf(
102
-                    'if (!defined(\'%s\')) define(\'%s\', %s);' . "\n",
102
+                    'if (!defined(\'%s\')) define(\'%s\', %s);'."\n",
103 103
                     $name,
104 104
                     $name,
105 105
                     self::exportVariable($value)
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
                     }
127 127
 
128 128
                     $result .= \sprintf(
129
-                        '$GLOBALS[\'%s\'][\'%s\'] = %s;' . "\n",
129
+                        '$GLOBALS[\'%s\'][\'%s\'] = %s;'."\n",
130 130
                         $superGlobalArray,
131 131
                         $key,
132 132
                         self::exportVariable($GLOBALS[$superGlobalArray][$key])
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
         foreach (\array_keys($GLOBALS) as $key) {
142 142
             if (!\in_array($key, $blacklist) && !$GLOBALS[$key] instanceof Closure) {
143 143
                 $result .= \sprintf(
144
-                    '$GLOBALS[\'%s\'] = %s;' . "\n",
144
+                    '$GLOBALS[\'%s\'] = %s;'."\n",
145 145
                     $key,
146 146
                     self::exportVariable($GLOBALS[$key])
147 147
                 );
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
             return \var_export($variable, true);
167 167
         }
168 168
 
169
-        return 'unserialize(' .
170
-            \var_export(\serialize($variable), true) .
169
+        return 'unserialize('.
170
+            \var_export(\serialize($variable), true).
171 171
             ')';
172 172
     }
173 173
 
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Util/ConfigurationGenerator.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
 
13 13
 class ConfigurationGenerator
14 14
 {
15
-    /**
16
-     * @var string
17
-     */
18
-    private $defaultTemplate = <<<EOT
15
+	/**
16
+	 * @var string
17
+	 */
18
+	private $defaultTemplate = <<<EOT
19 19
 <?xml version="1.0" encoding="UTF-8"?>
20 20
 <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21 21
          xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/{phpunit_version}/phpunit.xsd"
@@ -38,30 +38,30 @@  discard block
 block discarded – undo
38 38
 
39 39
 EOT;
40 40
 
41
-    /**
42
-     * @param string $phpunitVersion
43
-     * @param string $bootstrapScript
44
-     * @param string $testsDirectory
45
-     * @param string $srcDirectory
46
-     *
47
-     * @return string
48
-     */
49
-    public function generateDefaultConfiguration($phpunitVersion, $bootstrapScript, $testsDirectory, $srcDirectory)
50
-    {
51
-        return \str_replace(
52
-            [
53
-                '{phpunit_version}',
54
-                '{bootstrap_script}',
55
-                '{tests_directory}',
56
-                '{src_directory}'
57
-            ],
58
-            [
59
-                $phpunitVersion,
60
-                $bootstrapScript,
61
-                $testsDirectory,
62
-                $srcDirectory
63
-            ],
64
-            $this->defaultTemplate
65
-        );
66
-    }
41
+	/**
42
+	 * @param string $phpunitVersion
43
+	 * @param string $bootstrapScript
44
+	 * @param string $testsDirectory
45
+	 * @param string $srcDirectory
46
+	 *
47
+	 * @return string
48
+	 */
49
+	public function generateDefaultConfiguration($phpunitVersion, $bootstrapScript, $testsDirectory, $srcDirectory)
50
+	{
51
+		return \str_replace(
52
+			[
53
+				'{phpunit_version}',
54
+				'{bootstrap_script}',
55
+				'{tests_directory}',
56
+				'{src_directory}'
57
+			],
58
+			[
59
+				$phpunitVersion,
60
+				$bootstrapScript,
61
+				$testsDirectory,
62
+				$srcDirectory
63
+			],
64
+			$this->defaultTemplate
65
+		);
66
+	}
67 67
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Util/ErrorHandler.php 2 patches
Indentation   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -20,99 +20,99 @@
 block discarded – undo
20 20
  */
21 21
 class ErrorHandler
22 22
 {
23
-    protected static $errorStack = [];
24
-
25
-    /**
26
-     * Returns the error stack.
27
-     *
28
-     * @return array
29
-     */
30
-    public static function getErrorStack()
31
-    {
32
-        return self::$errorStack;
33
-    }
34
-
35
-    /**
36
-     * @param int    $errno
37
-     * @param string $errstr
38
-     * @param string $errfile
39
-     * @param int    $errline
40
-     *
41
-     * @return false
42
-     *
43
-     * @throws Error
44
-     */
45
-    public static function handleError($errno, $errstr, $errfile, $errline)
46
-    {
47
-        if (!($errno & \error_reporting())) {
48
-            return false;
49
-        }
50
-
51
-        self::$errorStack[] = [$errno, $errstr, $errfile, $errline];
52
-
53
-        $trace = \debug_backtrace();
54
-        \array_shift($trace);
55
-
56
-        foreach ($trace as $frame) {
57
-            if ($frame['function'] == '__toString') {
58
-                return false;
59
-            }
60
-        }
61
-
62
-        if ($errno == E_NOTICE || $errno == E_USER_NOTICE || $errno == E_STRICT) {
63
-            if (Notice::$enabled !== true) {
64
-                return false;
65
-            }
66
-
67
-            $exception = Notice::class;
68
-        } elseif ($errno == E_WARNING || $errno == E_USER_WARNING) {
69
-            if (Warning::$enabled !== true) {
70
-                return false;
71
-            }
72
-
73
-            $exception = Warning::class;
74
-        } elseif ($errno == E_DEPRECATED || $errno == E_USER_DEPRECATED) {
75
-            if (Deprecated::$enabled !== true) {
76
-                return false;
77
-            }
78
-
79
-            $exception = Deprecated::class;
80
-        } else {
81
-            $exception = Error::class;
82
-        }
83
-
84
-        throw new $exception($errstr, $errno, $errfile, $errline);
85
-    }
86
-
87
-    /**
88
-     * Registers an error handler and returns a function that will restore
89
-     * the previous handler when invoked
90
-     *
91
-     * @param int $severity PHP predefined error constant
92
-     *
93
-     * @return \Closure
94
-     *
95
-     * @throws \Exception if event of specified severity is emitted
96
-     */
97
-    public static function handleErrorOnce($severity = E_WARNING)
98
-    {
99
-        $terminator = function () {
100
-            static $expired = false;
101
-            if (!$expired) {
102
-                $expired = true;
103
-                // cleans temporary error handler
104
-                return \restore_error_handler();
105
-            }
106
-        };
107
-
108
-        \set_error_handler(function ($errno, $errstr) use ($severity) {
109
-            if ($errno === $severity) {
110
-                return;
111
-            }
112
-
113
-            return false;
114
-        });
115
-
116
-        return $terminator;
117
-    }
23
+	protected static $errorStack = [];
24
+
25
+	/**
26
+	 * Returns the error stack.
27
+	 *
28
+	 * @return array
29
+	 */
30
+	public static function getErrorStack()
31
+	{
32
+		return self::$errorStack;
33
+	}
34
+
35
+	/**
36
+	 * @param int    $errno
37
+	 * @param string $errstr
38
+	 * @param string $errfile
39
+	 * @param int    $errline
40
+	 *
41
+	 * @return false
42
+	 *
43
+	 * @throws Error
44
+	 */
45
+	public static function handleError($errno, $errstr, $errfile, $errline)
46
+	{
47
+		if (!($errno & \error_reporting())) {
48
+			return false;
49
+		}
50
+
51
+		self::$errorStack[] = [$errno, $errstr, $errfile, $errline];
52
+
53
+		$trace = \debug_backtrace();
54
+		\array_shift($trace);
55
+
56
+		foreach ($trace as $frame) {
57
+			if ($frame['function'] == '__toString') {
58
+				return false;
59
+			}
60
+		}
61
+
62
+		if ($errno == E_NOTICE || $errno == E_USER_NOTICE || $errno == E_STRICT) {
63
+			if (Notice::$enabled !== true) {
64
+				return false;
65
+			}
66
+
67
+			$exception = Notice::class;
68
+		} elseif ($errno == E_WARNING || $errno == E_USER_WARNING) {
69
+			if (Warning::$enabled !== true) {
70
+				return false;
71
+			}
72
+
73
+			$exception = Warning::class;
74
+		} elseif ($errno == E_DEPRECATED || $errno == E_USER_DEPRECATED) {
75
+			if (Deprecated::$enabled !== true) {
76
+				return false;
77
+			}
78
+
79
+			$exception = Deprecated::class;
80
+		} else {
81
+			$exception = Error::class;
82
+		}
83
+
84
+		throw new $exception($errstr, $errno, $errfile, $errline);
85
+	}
86
+
87
+	/**
88
+	 * Registers an error handler and returns a function that will restore
89
+	 * the previous handler when invoked
90
+	 *
91
+	 * @param int $severity PHP predefined error constant
92
+	 *
93
+	 * @return \Closure
94
+	 *
95
+	 * @throws \Exception if event of specified severity is emitted
96
+	 */
97
+	public static function handleErrorOnce($severity = E_WARNING)
98
+	{
99
+		$terminator = function () {
100
+			static $expired = false;
101
+			if (!$expired) {
102
+				$expired = true;
103
+				// cleans temporary error handler
104
+				return \restore_error_handler();
105
+			}
106
+		};
107
+
108
+		\set_error_handler(function ($errno, $errstr) use ($severity) {
109
+			if ($errno === $severity) {
110
+				return;
111
+			}
112
+
113
+			return false;
114
+		});
115
+
116
+		return $terminator;
117
+	}
118 118
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
      */
97 97
     public static function handleErrorOnce($severity = E_WARNING)
98 98
     {
99
-        $terminator = function () {
99
+        $terminator = function() {
100 100
             static $expired = false;
101 101
             if (!$expired) {
102 102
                 $expired = true;
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
             }
106 106
         };
107 107
 
108
-        \set_error_handler(function ($errno, $errstr) use ($severity) {
108
+        \set_error_handler(function($errno, $errstr) use ($severity) {
109 109
             if ($errno === $severity) {
110 110
                 return;
111 111
             }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/TextUI/TestRunner.php 2 patches
Indentation   +1050 added lines, -1050 removed lines patch added patch discarded remove patch
@@ -52,1054 +52,1054 @@
 block discarded – undo
52 52
  */
53 53
 class TestRunner extends BaseTestRunner
54 54
 {
55
-    const SUCCESS_EXIT   = 0;
56
-    const FAILURE_EXIT   = 1;
57
-    const EXCEPTION_EXIT = 2;
58
-
59
-    /**
60
-     * @var CodeCoverageFilter
61
-     */
62
-    protected $codeCoverageFilter;
63
-
64
-    /**
65
-     * @var TestSuiteLoader
66
-     */
67
-    protected $loader;
68
-
69
-    /**
70
-     * @var ResultPrinter
71
-     */
72
-    protected $printer;
73
-
74
-    /**
75
-     * @var bool
76
-     */
77
-    protected static $versionStringPrinted = false;
78
-
79
-    /**
80
-     * @var Runtime
81
-     */
82
-    private $runtime;
83
-
84
-    /**
85
-     * @var bool
86
-     */
87
-    private $messagePrinted = false;
88
-
89
-    /**
90
-     * @param TestSuiteLoader    $loader
91
-     * @param CodeCoverageFilter $filter
92
-     */
93
-    public function __construct(TestSuiteLoader $loader = null, CodeCoverageFilter $filter = null)
94
-    {
95
-        if ($filter === null) {
96
-            $filter = new CodeCoverageFilter;
97
-        }
98
-
99
-        $this->codeCoverageFilter = $filter;
100
-        $this->loader             = $loader;
101
-        $this->runtime            = new Runtime;
102
-    }
103
-
104
-    /**
105
-     * @param Test|ReflectionClass $test
106
-     * @param array                $arguments
107
-     *
108
-     * @return TestResult
109
-     *
110
-     * @throws Exception
111
-     */
112
-    public static function run($test, array $arguments = [])
113
-    {
114
-        if ($test instanceof ReflectionClass) {
115
-            $test = new TestSuite($test);
116
-        }
117
-
118
-        if ($test instanceof Test) {
119
-            $aTestRunner = new self;
120
-
121
-            return $aTestRunner->doRun(
122
-                $test,
123
-                $arguments
124
-            );
125
-        }
126
-
127
-        throw new Exception('No test case or test suite found.');
128
-    }
129
-
130
-    /**
131
-     * @return TestResult
132
-     */
133
-    protected function createTestResult()
134
-    {
135
-        return new TestResult;
136
-    }
137
-
138
-    /**
139
-     * @param TestSuite $suite
140
-     * @param array     $arguments
141
-     */
142
-    private function processSuiteFilters(TestSuite $suite, array $arguments)
143
-    {
144
-        if (!$arguments['filter'] &&
145
-            empty($arguments['groups']) &&
146
-            empty($arguments['excludeGroups'])) {
147
-            return;
148
-        }
149
-
150
-        $filterFactory = new Factory;
151
-
152
-        if (!empty($arguments['excludeGroups'])) {
153
-            $filterFactory->addFilter(
154
-                new ReflectionClass(ExcludeGroupFilterIterator::class),
155
-                $arguments['excludeGroups']
156
-            );
157
-        }
158
-
159
-        if (!empty($arguments['groups'])) {
160
-            $filterFactory->addFilter(
161
-                new ReflectionClass(IncludeGroupFilterIterator::class),
162
-                $arguments['groups']
163
-            );
164
-        }
165
-
166
-        if ($arguments['filter']) {
167
-            $filterFactory->addFilter(
168
-                new ReflectionClass(NameFilterIterator::class),
169
-                $arguments['filter']
170
-            );
171
-        }
172
-
173
-        $suite->injectFilter($filterFactory);
174
-    }
175
-
176
-    /**
177
-     * @param Test  $suite
178
-     * @param array $arguments
179
-     * @param bool  $exit
180
-     *
181
-     * @return TestResult
182
-     */
183
-    public function doRun(Test $suite, array $arguments = [], $exit = true)
184
-    {
185
-        if (isset($arguments['configuration'])) {
186
-            $GLOBALS['__PHPUNIT_CONFIGURATION_FILE'] = $arguments['configuration'];
187
-        }
188
-
189
-        $this->handleConfiguration($arguments);
190
-
191
-        $this->processSuiteFilters($suite, $arguments);
192
-
193
-        if (isset($arguments['bootstrap'])) {
194
-            $GLOBALS['__PHPUNIT_BOOTSTRAP'] = $arguments['bootstrap'];
195
-        }
196
-
197
-        if ($arguments['backupGlobals'] === true) {
198
-            $suite->setBackupGlobals(true);
199
-        }
200
-
201
-        if ($arguments['backupStaticAttributes'] === true) {
202
-            $suite->setBackupStaticAttributes(true);
203
-        }
204
-
205
-        if ($arguments['beStrictAboutChangesToGlobalState'] === true) {
206
-            $suite->setbeStrictAboutChangesToGlobalState(true);
207
-        }
208
-
209
-        if (\is_int($arguments['repeat']) && $arguments['repeat'] > 0) {
210
-            $_suite = new TestSuite;
211
-
212
-            foreach (\range(1, $arguments['repeat']) as $step) {
213
-                $_suite->addTest($suite);
214
-            }
215
-
216
-            $suite = $_suite;
217
-            unset($_suite);
218
-        }
219
-
220
-        $result = $this->createTestResult();
221
-
222
-        if (!$arguments['convertErrorsToExceptions']) {
223
-            $result->convertErrorsToExceptions(false);
224
-        }
225
-
226
-        if (!$arguments['convertDeprecationsToExceptions']) {
227
-            Deprecated::$enabled = false;
228
-        }
229
-
230
-        if (!$arguments['convertNoticesToExceptions']) {
231
-            Notice::$enabled = false;
232
-        }
233
-
234
-        if (!$arguments['convertWarningsToExceptions']) {
235
-            Warning::$enabled = false;
236
-        }
237
-
238
-        if ($arguments['stopOnError']) {
239
-            $result->stopOnError(true);
240
-        }
241
-
242
-        if ($arguments['stopOnFailure']) {
243
-            $result->stopOnFailure(true);
244
-        }
245
-
246
-        if ($arguments['stopOnWarning']) {
247
-            $result->stopOnWarning(true);
248
-        }
249
-
250
-        if ($arguments['stopOnIncomplete']) {
251
-            $result->stopOnIncomplete(true);
252
-        }
253
-
254
-        if ($arguments['stopOnRisky']) {
255
-            $result->stopOnRisky(true);
256
-        }
257
-
258
-        if ($arguments['stopOnSkipped']) {
259
-            $result->stopOnSkipped(true);
260
-        }
261
-
262
-        if ($arguments['registerMockObjectsFromTestArgumentsRecursively']) {
263
-            $result->setRegisterMockObjectsFromTestArgumentsRecursively(true);
264
-        }
265
-
266
-        if ($this->printer === null) {
267
-            if (isset($arguments['printer']) &&
268
-                $arguments['printer'] instanceof Printer) {
269
-                $this->printer = $arguments['printer'];
270
-            } else {
271
-                $printerClass = ResultPrinter::class;
272
-
273
-                if (isset($arguments['printer']) && \is_string($arguments['printer']) && \class_exists($arguments['printer'], false)) {
274
-                    $class = new ReflectionClass($arguments['printer']);
275
-
276
-                    if ($class->isSubclassOf(ResultPrinter::class)) {
277
-                        $printerClass = $arguments['printer'];
278
-                    }
279
-                }
280
-
281
-                $this->printer = new $printerClass(
282
-                    (isset($arguments['stderr']) && $arguments['stderr'] === true) ? 'php://stderr' : null,
283
-                    $arguments['verbose'],
284
-                    $arguments['colors'],
285
-                    $arguments['debug'],
286
-                    $arguments['columns'],
287
-                    $arguments['reverseList']
288
-                );
289
-            }
290
-        }
291
-
292
-        $this->printer->write(
293
-            Version::getVersionString() . "\n"
294
-        );
295
-
296
-        self::$versionStringPrinted = true;
297
-
298
-        if ($arguments['verbose']) {
299
-            $runtime = $this->runtime->getNameWithVersion();
300
-
301
-            if ($this->runtime->hasXdebug()) {
302
-                $runtime .= \sprintf(
303
-                    ' with Xdebug %s',
304
-                    \phpversion('xdebug')
305
-                );
306
-            }
307
-
308
-            $this->writeMessage('Runtime', $runtime);
309
-
310
-            if (isset($arguments['configuration'])) {
311
-                $this->writeMessage(
312
-                    'Configuration',
313
-                    $arguments['configuration']->getFilename()
314
-                );
315
-            }
316
-
317
-            foreach ($arguments['loadedExtensions'] as $extension) {
318
-                $this->writeMessage(
319
-                    'Extension',
320
-                    $extension
321
-                );
322
-            }
323
-
324
-            foreach ($arguments['notLoadedExtensions'] as $extension) {
325
-                $this->writeMessage(
326
-                    'Extension',
327
-                    $extension
328
-                );
329
-            }
330
-        }
331
-
332
-        if ($this->runtime->discardsComments()) {
333
-            $this->writeMessage('Warning', 'opcache.save_comments=0 set; annotations will not work');
334
-        }
335
-
336
-        foreach ($arguments['listeners'] as $listener) {
337
-            $result->addListener($listener);
338
-        }
339
-
340
-        $result->addListener($this->printer);
341
-
342
-        $codeCoverageReports = 0;
343
-
344
-        if (!isset($arguments['noLogging'])) {
345
-            if (isset($arguments['testdoxHTMLFile'])) {
346
-                $result->addListener(
347
-                    new HtmlResultPrinter(
348
-                        $arguments['testdoxHTMLFile'],
349
-                        $arguments['testdoxGroups'],
350
-                        $arguments['testdoxExcludeGroups']
351
-                    )
352
-                );
353
-            }
354
-
355
-            if (isset($arguments['testdoxTextFile'])) {
356
-                $result->addListener(
357
-                    new TextResultPrinter(
358
-                        $arguments['testdoxTextFile'],
359
-                        $arguments['testdoxGroups'],
360
-                        $arguments['testdoxExcludeGroups']
361
-                    )
362
-                );
363
-            }
364
-
365
-            if (isset($arguments['testdoxXMLFile'])) {
366
-                $result->addListener(
367
-                    new XmlResultPrinter(
368
-                        $arguments['testdoxXMLFile']
369
-                    )
370
-                );
371
-            }
372
-
373
-            if (isset($arguments['teamcityLogfile'])) {
374
-                $result->addListener(
375
-                    new TeamCity($arguments['teamcityLogfile'])
376
-                );
377
-            }
378
-
379
-            if (isset($arguments['junitLogfile'])) {
380
-                $result->addListener(
381
-                    new JUnit(
382
-                        $arguments['junitLogfile'],
383
-                        $arguments['reportUselessTests']
384
-                    )
385
-                );
386
-            }
387
-
388
-            if (isset($arguments['coverageClover'])) {
389
-                $codeCoverageReports++;
390
-            }
391
-
392
-            if (isset($arguments['coverageCrap4J'])) {
393
-                $codeCoverageReports++;
394
-            }
395
-
396
-            if (isset($arguments['coverageHtml'])) {
397
-                $codeCoverageReports++;
398
-            }
399
-
400
-            if (isset($arguments['coveragePHP'])) {
401
-                $codeCoverageReports++;
402
-            }
403
-
404
-            if (isset($arguments['coverageText'])) {
405
-                $codeCoverageReports++;
406
-            }
407
-
408
-            if (isset($arguments['coverageXml'])) {
409
-                $codeCoverageReports++;
410
-            }
411
-        }
412
-
413
-        if (isset($arguments['noCoverage'])) {
414
-            $codeCoverageReports = 0;
415
-        }
416
-
417
-        if ($codeCoverageReports > 0 && !$this->runtime->canCollectCodeCoverage()) {
418
-            $this->writeMessage('Error', 'No code coverage driver is available');
419
-
420
-            $codeCoverageReports = 0;
421
-        }
422
-
423
-        if ($codeCoverageReports > 0) {
424
-            $codeCoverage = new CodeCoverage(
425
-                null,
426
-                $this->codeCoverageFilter
427
-            );
428
-
429
-            $codeCoverage->setUnintentionallyCoveredSubclassesWhitelist(
430
-                [SebastianBergmann\Comparator\Comparator::class]
431
-            );
432
-
433
-            $codeCoverage->setCheckForUnintentionallyCoveredCode(
434
-                $arguments['strictCoverage']
435
-            );
436
-
437
-            $codeCoverage->setCheckForMissingCoversAnnotation(
438
-                $arguments['strictCoverage']
439
-            );
440
-
441
-            if (isset($arguments['forceCoversAnnotation'])) {
442
-                $codeCoverage->setForceCoversAnnotation(
443
-                    $arguments['forceCoversAnnotation']
444
-                );
445
-            }
446
-
447
-            if (isset($arguments['ignoreDeprecatedCodeUnitsFromCodeCoverage'])) {
448
-                $codeCoverage->setIgnoreDeprecatedCode(
449
-                    $arguments['ignoreDeprecatedCodeUnitsFromCodeCoverage']
450
-                );
451
-            }
452
-
453
-            if (isset($arguments['disableCodeCoverageIgnore'])) {
454
-                $codeCoverage->setDisableIgnoredLines(true);
455
-            }
456
-
457
-            if (isset($arguments['whitelist'])) {
458
-                $this->codeCoverageFilter->addDirectoryToWhitelist($arguments['whitelist']);
459
-            }
460
-
461
-            if (isset($arguments['configuration'])) {
462
-                $filterConfiguration = $arguments['configuration']->getFilterConfiguration();
463
-
464
-                if (empty($filterConfiguration['whitelist']) && !isset($arguments['whitelist'])) {
465
-                    $this->writeMessage('Error', 'No whitelist is configured, no code coverage will be generated.');
466
-
467
-                    $codeCoverageReports = 0;
468
-
469
-                    unset($codeCoverage);
470
-                } else {
471
-                    $codeCoverage->setAddUncoveredFilesFromWhitelist(
472
-                        $filterConfiguration['whitelist']['addUncoveredFilesFromWhitelist']
473
-                    );
474
-
475
-                    $codeCoverage->setProcessUncoveredFilesFromWhitelist(
476
-                        $filterConfiguration['whitelist']['processUncoveredFilesFromWhitelist']
477
-                    );
478
-
479
-                    foreach ($filterConfiguration['whitelist']['include']['directory'] as $dir) {
480
-                        $this->codeCoverageFilter->addDirectoryToWhitelist(
481
-                            $dir['path'],
482
-                            $dir['suffix'],
483
-                            $dir['prefix']
484
-                        );
485
-                    }
486
-
487
-                    foreach ($filterConfiguration['whitelist']['include']['file'] as $file) {
488
-                        $this->codeCoverageFilter->addFileToWhitelist($file);
489
-                    }
490
-
491
-                    foreach ($filterConfiguration['whitelist']['exclude']['directory'] as $dir) {
492
-                        $this->codeCoverageFilter->removeDirectoryFromWhitelist(
493
-                            $dir['path'],
494
-                            $dir['suffix'],
495
-                            $dir['prefix']
496
-                        );
497
-                    }
498
-
499
-                    foreach ($filterConfiguration['whitelist']['exclude']['file'] as $file) {
500
-                        $this->codeCoverageFilter->removeFileFromWhitelist($file);
501
-                    }
502
-                }
503
-            }
504
-
505
-            if (isset($codeCoverage) && !$this->codeCoverageFilter->hasWhitelist()) {
506
-                $this->writeMessage('Error', 'Incorrect whitelist config, no code coverage will be generated.');
507
-
508
-                $codeCoverageReports = 0;
509
-
510
-                unset($codeCoverage);
511
-            }
512
-        }
513
-
514
-        $this->printer->write("\n");
515
-
516
-        if (isset($codeCoverage)) {
517
-            $result->setCodeCoverage($codeCoverage);
518
-
519
-            if ($codeCoverageReports > 1 && isset($arguments['cacheTokens'])) {
520
-                $codeCoverage->setCacheTokens($arguments['cacheTokens']);
521
-            }
522
-        }
523
-
524
-        $result->beStrictAboutTestsThatDoNotTestAnything($arguments['reportUselessTests']);
525
-        $result->beStrictAboutOutputDuringTests($arguments['disallowTestOutput']);
526
-        $result->beStrictAboutTodoAnnotatedTests($arguments['disallowTodoAnnotatedTests']);
527
-        $result->beStrictAboutResourceUsageDuringSmallTests($arguments['beStrictAboutResourceUsageDuringSmallTests']);
528
-        $result->enforceTimeLimit($arguments['enforceTimeLimit']);
529
-        $result->setTimeoutForSmallTests($arguments['timeoutForSmallTests']);
530
-        $result->setTimeoutForMediumTests($arguments['timeoutForMediumTests']);
531
-        $result->setTimeoutForLargeTests($arguments['timeoutForLargeTests']);
532
-
533
-        if ($suite instanceof TestSuite) {
534
-            $suite->setRunTestInSeparateProcess($arguments['processIsolation']);
535
-        }
536
-
537
-        $suite->run($result);
538
-
539
-        unset($suite);
540
-        $result->flushListeners();
541
-
542
-        if ($this->printer instanceof ResultPrinter) {
543
-            $this->printer->printResult($result);
544
-        }
545
-
546
-        if (isset($codeCoverage)) {
547
-            if (isset($arguments['coverageClover'])) {
548
-                $this->printer->write(
549
-                    "\nGenerating code coverage report in Clover XML format ..."
550
-                );
551
-
552
-                try {
553
-                    $writer = new CloverReport;
554
-                    $writer->process($codeCoverage, $arguments['coverageClover']);
555
-
556
-                    $this->printer->write(" done\n");
557
-                    unset($writer);
558
-                } catch (CodeCoverageException $e) {
559
-                    $this->printer->write(
560
-                        " failed\n" . $e->getMessage() . "\n"
561
-                    );
562
-                }
563
-            }
564
-
565
-            if (isset($arguments['coverageCrap4J'])) {
566
-                $this->printer->write(
567
-                    "\nGenerating Crap4J report XML file ..."
568
-                );
569
-
570
-                try {
571
-                    $writer = new Crap4jReport($arguments['crap4jThreshold']);
572
-                    $writer->process($codeCoverage, $arguments['coverageCrap4J']);
573
-
574
-                    $this->printer->write(" done\n");
575
-                    unset($writer);
576
-                } catch (CodeCoverageException $e) {
577
-                    $this->printer->write(
578
-                        " failed\n" . $e->getMessage() . "\n"
579
-                    );
580
-                }
581
-            }
582
-
583
-            if (isset($arguments['coverageHtml'])) {
584
-                $this->printer->write(
585
-                    "\nGenerating code coverage report in HTML format ..."
586
-                );
587
-
588
-                try {
589
-                    $writer = new HtmlReport(
590
-                        $arguments['reportLowUpperBound'],
591
-                        $arguments['reportHighLowerBound'],
592
-                        \sprintf(
593
-                            ' and <a href="https://phpunit.de/">PHPUnit %s</a>',
594
-                            Version::id()
595
-                        )
596
-                    );
597
-
598
-                    $writer->process($codeCoverage, $arguments['coverageHtml']);
599
-
600
-                    $this->printer->write(" done\n");
601
-                    unset($writer);
602
-                } catch (CodeCoverageException $e) {
603
-                    $this->printer->write(
604
-                        " failed\n" . $e->getMessage() . "\n"
605
-                    );
606
-                }
607
-            }
608
-
609
-            if (isset($arguments['coveragePHP'])) {
610
-                $this->printer->write(
611
-                    "\nGenerating code coverage report in PHP format ..."
612
-                );
613
-
614
-                try {
615
-                    $writer = new PhpReport;
616
-                    $writer->process($codeCoverage, $arguments['coveragePHP']);
617
-
618
-                    $this->printer->write(" done\n");
619
-                    unset($writer);
620
-                } catch (CodeCoverageException $e) {
621
-                    $this->printer->write(
622
-                        " failed\n" . $e->getMessage() . "\n"
623
-                    );
624
-                }
625
-            }
626
-
627
-            if (isset($arguments['coverageText'])) {
628
-                if ($arguments['coverageText'] == 'php://stdout') {
629
-                    $outputStream = $this->printer;
630
-                    $colors       = $arguments['colors'] && $arguments['colors'] != ResultPrinter::COLOR_NEVER;
631
-                } else {
632
-                    $outputStream = new Printer($arguments['coverageText']);
633
-                    $colors       = false;
634
-                }
635
-
636
-                $processor = new TextReport(
637
-                    $arguments['reportLowUpperBound'],
638
-                    $arguments['reportHighLowerBound'],
639
-                    $arguments['coverageTextShowUncoveredFiles'],
640
-                    $arguments['coverageTextShowOnlySummary']
641
-                );
642
-
643
-                $outputStream->write(
644
-                    $processor->process($codeCoverage, $colors)
645
-                );
646
-            }
647
-
648
-            if (isset($arguments['coverageXml'])) {
649
-                $this->printer->write(
650
-                    "\nGenerating code coverage report in PHPUnit XML format ..."
651
-                );
652
-
653
-                try {
654
-                    $writer = new XmlReport(Version::id());
655
-                    $writer->process($codeCoverage, $arguments['coverageXml']);
656
-
657
-                    $this->printer->write(" done\n");
658
-                    unset($writer);
659
-                } catch (CodeCoverageException $e) {
660
-                    $this->printer->write(
661
-                        " failed\n" . $e->getMessage() . "\n"
662
-                    );
663
-                }
664
-            }
665
-        }
666
-
667
-        if ($exit) {
668
-            if ($result->wasSuccessful()) {
669
-                if ($arguments['failOnRisky'] && !$result->allHarmless()) {
670
-                    exit(self::FAILURE_EXIT);
671
-                }
672
-
673
-                if ($arguments['failOnWarning'] && $result->warningCount() > 0) {
674
-                    exit(self::FAILURE_EXIT);
675
-                }
676
-
677
-                exit(self::SUCCESS_EXIT);
678
-            }
679
-
680
-            if ($result->errorCount() > 0) {
681
-                exit(self::EXCEPTION_EXIT);
682
-            }
683
-
684
-            if ($result->failureCount() > 0) {
685
-                exit(self::FAILURE_EXIT);
686
-            }
687
-        }
688
-
689
-        return $result;
690
-    }
691
-
692
-    /**
693
-     * @param ResultPrinter $resultPrinter
694
-     */
695
-    public function setPrinter(ResultPrinter $resultPrinter)
696
-    {
697
-        $this->printer = $resultPrinter;
698
-    }
699
-
700
-    /**
701
-     * Override to define how to handle a failed loading of
702
-     * a test suite.
703
-     *
704
-     * @param string $message
705
-     */
706
-    protected function runFailed($message)
707
-    {
708
-        $this->write($message . PHP_EOL);
709
-        exit(self::FAILURE_EXIT);
710
-    }
711
-
712
-    /**
713
-     * @param string $buffer
714
-     */
715
-    protected function write($buffer)
716
-    {
717
-        if (PHP_SAPI != 'cli' && PHP_SAPI != 'phpdbg') {
718
-            $buffer = \htmlspecialchars($buffer);
719
-        }
720
-
721
-        if ($this->printer !== null) {
722
-            $this->printer->write($buffer);
723
-        } else {
724
-            print $buffer;
725
-        }
726
-    }
727
-
728
-    /**
729
-     * Returns the loader to be used.
730
-     *
731
-     * @return TestSuiteLoader
732
-     */
733
-    public function getLoader()
734
-    {
735
-        if ($this->loader === null) {
736
-            $this->loader = new StandardTestSuiteLoader;
737
-        }
738
-
739
-        return $this->loader;
740
-    }
741
-
742
-    /**
743
-     * @param array $arguments
744
-     */
745
-    protected function handleConfiguration(array &$arguments)
746
-    {
747
-        if (isset($arguments['configuration']) &&
748
-            !$arguments['configuration'] instanceof Configuration) {
749
-            $arguments['configuration'] = Configuration::getInstance(
750
-                $arguments['configuration']
751
-            );
752
-        }
753
-
754
-        $arguments['debug']     = $arguments['debug'] ?? false;
755
-        $arguments['filter']    = $arguments['filter'] ?? false;
756
-        $arguments['listeners'] = $arguments['listeners'] ?? [];
757
-
758
-        if (isset($arguments['configuration'])) {
759
-            $arguments['configuration']->handlePHPConfiguration();
760
-
761
-            $phpunitConfiguration = $arguments['configuration']->getPHPUnitConfiguration();
762
-
763
-            if (isset($phpunitConfiguration['backupGlobals']) && !isset($arguments['backupGlobals'])) {
764
-                $arguments['backupGlobals'] = $phpunitConfiguration['backupGlobals'];
765
-            }
766
-
767
-            if (isset($phpunitConfiguration['backupStaticAttributes']) && !isset($arguments['backupStaticAttributes'])) {
768
-                $arguments['backupStaticAttributes'] = $phpunitConfiguration['backupStaticAttributes'];
769
-            }
770
-
771
-            if (isset($phpunitConfiguration['beStrictAboutChangesToGlobalState']) && !isset($arguments['beStrictAboutChangesToGlobalState'])) {
772
-                $arguments['beStrictAboutChangesToGlobalState'] = $phpunitConfiguration['beStrictAboutChangesToGlobalState'];
773
-            }
774
-
775
-            if (isset($phpunitConfiguration['bootstrap']) && !isset($arguments['bootstrap'])) {
776
-                $arguments['bootstrap'] = $phpunitConfiguration['bootstrap'];
777
-            }
778
-
779
-            if (isset($phpunitConfiguration['cacheTokens']) && !isset($arguments['cacheTokens'])) {
780
-                $arguments['cacheTokens'] = $phpunitConfiguration['cacheTokens'];
781
-            }
782
-
783
-            if (isset($phpunitConfiguration['colors']) && !isset($arguments['colors'])) {
784
-                $arguments['colors'] = $phpunitConfiguration['colors'];
785
-            }
786
-
787
-            if (isset($phpunitConfiguration['convertDeprecationsToExceptions']) && !isset($arguments['convertDeprecationsToExceptions'])) {
788
-                $arguments['convertDeprecationsToExceptions'] = $phpunitConfiguration['convertDeprecationsToExceptions'];
789
-            }
790
-
791
-            if (isset($phpunitConfiguration['convertErrorsToExceptions']) && !isset($arguments['convertErrorsToExceptions'])) {
792
-                $arguments['convertErrorsToExceptions'] = $phpunitConfiguration['convertErrorsToExceptions'];
793
-            }
794
-
795
-            if (isset($phpunitConfiguration['convertNoticesToExceptions']) && !isset($arguments['convertNoticesToExceptions'])) {
796
-                $arguments['convertNoticesToExceptions'] = $phpunitConfiguration['convertNoticesToExceptions'];
797
-            }
798
-
799
-            if (isset($phpunitConfiguration['convertWarningsToExceptions']) && !isset($arguments['convertWarningsToExceptions'])) {
800
-                $arguments['convertWarningsToExceptions'] = $phpunitConfiguration['convertWarningsToExceptions'];
801
-            }
802
-
803
-            if (isset($phpunitConfiguration['processIsolation']) && !isset($arguments['processIsolation'])) {
804
-                $arguments['processIsolation'] = $phpunitConfiguration['processIsolation'];
805
-            }
806
-
807
-            if (isset($phpunitConfiguration['stopOnError']) && !isset($arguments['stopOnError'])) {
808
-                $arguments['stopOnError'] = $phpunitConfiguration['stopOnError'];
809
-            }
810
-
811
-            if (isset($phpunitConfiguration['stopOnFailure']) && !isset($arguments['stopOnFailure'])) {
812
-                $arguments['stopOnFailure'] = $phpunitConfiguration['stopOnFailure'];
813
-            }
814
-
815
-            if (isset($phpunitConfiguration['stopOnWarning']) && !isset($arguments['stopOnWarning'])) {
816
-                $arguments['stopOnWarning'] = $phpunitConfiguration['stopOnWarning'];
817
-            }
818
-
819
-            if (isset($phpunitConfiguration['stopOnIncomplete']) && !isset($arguments['stopOnIncomplete'])) {
820
-                $arguments['stopOnIncomplete'] = $phpunitConfiguration['stopOnIncomplete'];
821
-            }
822
-
823
-            if (isset($phpunitConfiguration['stopOnRisky']) && !isset($arguments['stopOnRisky'])) {
824
-                $arguments['stopOnRisky'] = $phpunitConfiguration['stopOnRisky'];
825
-            }
826
-
827
-            if (isset($phpunitConfiguration['stopOnSkipped']) && !isset($arguments['stopOnSkipped'])) {
828
-                $arguments['stopOnSkipped'] = $phpunitConfiguration['stopOnSkipped'];
829
-            }
830
-
831
-            if (isset($phpunitConfiguration['failOnWarning']) && !isset($arguments['failOnWarning'])) {
832
-                $arguments['failOnWarning'] = $phpunitConfiguration['failOnWarning'];
833
-            }
834
-
835
-            if (isset($phpunitConfiguration['failOnRisky']) && !isset($arguments['failOnRisky'])) {
836
-                $arguments['failOnRisky'] = $phpunitConfiguration['failOnRisky'];
837
-            }
838
-
839
-            if (isset($phpunitConfiguration['timeoutForSmallTests']) && !isset($arguments['timeoutForSmallTests'])) {
840
-                $arguments['timeoutForSmallTests'] = $phpunitConfiguration['timeoutForSmallTests'];
841
-            }
842
-
843
-            if (isset($phpunitConfiguration['timeoutForMediumTests']) && !isset($arguments['timeoutForMediumTests'])) {
844
-                $arguments['timeoutForMediumTests'] = $phpunitConfiguration['timeoutForMediumTests'];
845
-            }
846
-
847
-            if (isset($phpunitConfiguration['timeoutForLargeTests']) && !isset($arguments['timeoutForLargeTests'])) {
848
-                $arguments['timeoutForLargeTests'] = $phpunitConfiguration['timeoutForLargeTests'];
849
-            }
850
-
851
-            if (isset($phpunitConfiguration['reportUselessTests']) && !isset($arguments['reportUselessTests'])) {
852
-                $arguments['reportUselessTests'] = $phpunitConfiguration['reportUselessTests'];
853
-            }
854
-
855
-            if (isset($phpunitConfiguration['strictCoverage']) && !isset($arguments['strictCoverage'])) {
856
-                $arguments['strictCoverage'] = $phpunitConfiguration['strictCoverage'];
857
-            }
858
-
859
-            if (isset($phpunitConfiguration['ignoreDeprecatedCodeUnitsFromCodeCoverage']) && !isset($arguments['ignoreDeprecatedCodeUnitsFromCodeCoverage'])) {
860
-                $arguments['ignoreDeprecatedCodeUnitsFromCodeCoverage'] = $phpunitConfiguration['ignoreDeprecatedCodeUnitsFromCodeCoverage'];
861
-            }
862
-
863
-            if (isset($phpunitConfiguration['disallowTestOutput']) && !isset($arguments['disallowTestOutput'])) {
864
-                $arguments['disallowTestOutput'] = $phpunitConfiguration['disallowTestOutput'];
865
-            }
866
-
867
-            if (isset($phpunitConfiguration['enforceTimeLimit']) && !isset($arguments['enforceTimeLimit'])) {
868
-                $arguments['enforceTimeLimit'] = $phpunitConfiguration['enforceTimeLimit'];
869
-            }
870
-
871
-            if (isset($phpunitConfiguration['disallowTodoAnnotatedTests']) && !isset($arguments['disallowTodoAnnotatedTests'])) {
872
-                $arguments['disallowTodoAnnotatedTests'] = $phpunitConfiguration['disallowTodoAnnotatedTests'];
873
-            }
874
-
875
-            if (isset($phpunitConfiguration['beStrictAboutResourceUsageDuringSmallTests']) && !isset($arguments['beStrictAboutResourceUsageDuringSmallTests'])) {
876
-                $arguments['beStrictAboutResourceUsageDuringSmallTests'] = $phpunitConfiguration['beStrictAboutResourceUsageDuringSmallTests'];
877
-            }
878
-
879
-            if (isset($phpunitConfiguration['verbose']) && !isset($arguments['verbose'])) {
880
-                $arguments['verbose'] = $phpunitConfiguration['verbose'];
881
-            }
882
-
883
-            if (isset($phpunitConfiguration['reverseDefectList']) && !isset($arguments['reverseList'])) {
884
-                $arguments['reverseList'] = $phpunitConfiguration['reverseDefectList'];
885
-            }
886
-
887
-            if (isset($phpunitConfiguration['forceCoversAnnotation']) && !isset($arguments['forceCoversAnnotation'])) {
888
-                $arguments['forceCoversAnnotation'] = $phpunitConfiguration['forceCoversAnnotation'];
889
-            }
890
-
891
-            if (isset($phpunitConfiguration['disableCodeCoverageIgnore']) && !isset($arguments['disableCodeCoverageIgnore'])) {
892
-                $arguments['disableCodeCoverageIgnore'] = $phpunitConfiguration['disableCodeCoverageIgnore'];
893
-            }
894
-
895
-            if (isset($phpunitConfiguration['registerMockObjectsFromTestArgumentsRecursively']) && !isset($arguments['registerMockObjectsFromTestArgumentsRecursively'])) {
896
-                $arguments['registerMockObjectsFromTestArgumentsRecursively'] = $phpunitConfiguration['registerMockObjectsFromTestArgumentsRecursively'];
897
-            }
898
-
899
-            $groupCliArgs = [];
900
-
901
-            if (!empty($arguments['groups'])) {
902
-                $groupCliArgs = $arguments['groups'];
903
-            }
904
-
905
-            $groupConfiguration = $arguments['configuration']->getGroupConfiguration();
906
-
907
-            if (!empty($groupConfiguration['include']) && !isset($arguments['groups'])) {
908
-                $arguments['groups'] = $groupConfiguration['include'];
909
-            }
910
-
911
-            if (!empty($groupConfiguration['exclude']) && !isset($arguments['excludeGroups'])) {
912
-                $arguments['excludeGroups'] = \array_diff($groupConfiguration['exclude'], $groupCliArgs);
913
-            }
914
-
915
-            foreach ($arguments['configuration']->getListenerConfiguration() as $listener) {
916
-                if (!\class_exists($listener['class'], false) &&
917
-                    $listener['file'] !== '') {
918
-                    require_once $listener['file'];
919
-                }
920
-
921
-                if (!\class_exists($listener['class'])) {
922
-                    throw new Exception(
923
-                        \sprintf(
924
-                            'Class "%s" does not exist',
925
-                            $listener['class']
926
-                        )
927
-                    );
928
-                }
929
-
930
-                $listenerClass = new ReflectionClass($listener['class']);
931
-
932
-                if (!$listenerClass->implementsInterface(TestListener::class)) {
933
-                    throw new Exception(
934
-                        \sprintf(
935
-                            'Class "%s" does not implement the PHPUnit\Framework\TestListener interface',
936
-                            $listener['class']
937
-                        )
938
-                    );
939
-                }
940
-
941
-                if (\count($listener['arguments']) == 0) {
942
-                    $listener = new $listener['class'];
943
-                } else {
944
-                    $listener = $listenerClass->newInstanceArgs(
945
-                        $listener['arguments']
946
-                    );
947
-                }
948
-
949
-                $arguments['listeners'][] = $listener;
950
-            }
951
-
952
-            $loggingConfiguration = $arguments['configuration']->getLoggingConfiguration();
953
-
954
-            if (isset($loggingConfiguration['coverage-clover']) && !isset($arguments['coverageClover'])) {
955
-                $arguments['coverageClover'] = $loggingConfiguration['coverage-clover'];
956
-            }
957
-
958
-            if (isset($loggingConfiguration['coverage-crap4j']) && !isset($arguments['coverageCrap4J'])) {
959
-                $arguments['coverageCrap4J'] = $loggingConfiguration['coverage-crap4j'];
960
-
961
-                if (isset($loggingConfiguration['crap4jThreshold']) && !isset($arguments['crap4jThreshold'])) {
962
-                    $arguments['crap4jThreshold'] = $loggingConfiguration['crap4jThreshold'];
963
-                }
964
-            }
965
-
966
-            if (isset($loggingConfiguration['coverage-html']) && !isset($arguments['coverageHtml'])) {
967
-                if (isset($loggingConfiguration['lowUpperBound']) && !isset($arguments['reportLowUpperBound'])) {
968
-                    $arguments['reportLowUpperBound'] = $loggingConfiguration['lowUpperBound'];
969
-                }
970
-
971
-                if (isset($loggingConfiguration['highLowerBound']) && !isset($arguments['reportHighLowerBound'])) {
972
-                    $arguments['reportHighLowerBound'] = $loggingConfiguration['highLowerBound'];
973
-                }
974
-
975
-                $arguments['coverageHtml'] = $loggingConfiguration['coverage-html'];
976
-            }
977
-
978
-            if (isset($loggingConfiguration['coverage-php']) && !isset($arguments['coveragePHP'])) {
979
-                $arguments['coveragePHP'] = $loggingConfiguration['coverage-php'];
980
-            }
981
-
982
-            if (isset($loggingConfiguration['coverage-text']) && !isset($arguments['coverageText'])) {
983
-                $arguments['coverageText'] = $loggingConfiguration['coverage-text'];
984
-
985
-                if (isset($loggingConfiguration['coverageTextShowUncoveredFiles'])) {
986
-                    $arguments['coverageTextShowUncoveredFiles'] = $loggingConfiguration['coverageTextShowUncoveredFiles'];
987
-                } else {
988
-                    $arguments['coverageTextShowUncoveredFiles'] = false;
989
-                }
990
-
991
-                if (isset($loggingConfiguration['coverageTextShowOnlySummary'])) {
992
-                    $arguments['coverageTextShowOnlySummary'] = $loggingConfiguration['coverageTextShowOnlySummary'];
993
-                } else {
994
-                    $arguments['coverageTextShowOnlySummary'] = false;
995
-                }
996
-            }
997
-
998
-            if (isset($loggingConfiguration['coverage-xml']) && !isset($arguments['coverageXml'])) {
999
-                $arguments['coverageXml'] = $loggingConfiguration['coverage-xml'];
1000
-            }
1001
-
1002
-            if (isset($loggingConfiguration['plain'])) {
1003
-                $arguments['listeners'][] = new ResultPrinter(
1004
-                    $loggingConfiguration['plain'],
1005
-                    true
1006
-                );
1007
-            }
1008
-
1009
-            if (isset($loggingConfiguration['teamcity']) && !isset($arguments['teamcityLogfile'])) {
1010
-                $arguments['teamcityLogfile'] = $loggingConfiguration['teamcity'];
1011
-            }
1012
-
1013
-            if (isset($loggingConfiguration['junit']) && !isset($arguments['junitLogfile'])) {
1014
-                $arguments['junitLogfile'] = $loggingConfiguration['junit'];
1015
-            }
1016
-
1017
-            if (isset($loggingConfiguration['testdox-html']) && !isset($arguments['testdoxHTMLFile'])) {
1018
-                $arguments['testdoxHTMLFile'] = $loggingConfiguration['testdox-html'];
1019
-            }
1020
-
1021
-            if (isset($loggingConfiguration['testdox-text']) && !isset($arguments['testdoxTextFile'])) {
1022
-                $arguments['testdoxTextFile'] = $loggingConfiguration['testdox-text'];
1023
-            }
1024
-
1025
-            if (isset($loggingConfiguration['testdox-xml']) && !isset($arguments['testdoxXMLFile'])) {
1026
-                $arguments['testdoxXMLFile'] = $loggingConfiguration['testdox-xml'];
1027
-            }
1028
-
1029
-            $testdoxGroupConfiguration = $arguments['configuration']->getTestdoxGroupConfiguration();
1030
-
1031
-            if (isset($testdoxGroupConfiguration['include']) &&
1032
-                !isset($arguments['testdoxGroups'])) {
1033
-                $arguments['testdoxGroups'] = $testdoxGroupConfiguration['include'];
1034
-            }
1035
-
1036
-            if (isset($testdoxGroupConfiguration['exclude']) &&
1037
-                !isset($arguments['testdoxExcludeGroups'])) {
1038
-                $arguments['testdoxExcludeGroups'] = $testdoxGroupConfiguration['exclude'];
1039
-            }
1040
-        }
1041
-
1042
-        $arguments['addUncoveredFilesFromWhitelist']                  = $arguments['addUncoveredFilesFromWhitelist'] ?? true;
1043
-        $arguments['backupGlobals']                                   = $arguments['backupGlobals'] ?? null;
1044
-        $arguments['backupStaticAttributes']                          = $arguments['backupStaticAttributes'] ?? null;
1045
-        $arguments['beStrictAboutChangesToGlobalState']               = $arguments['beStrictAboutChangesToGlobalState'] ?? null;
1046
-        $arguments['beStrictAboutResourceUsageDuringSmallTests']      = $arguments['beStrictAboutResourceUsageDuringSmallTests'] ?? false;
1047
-        $arguments['cacheTokens']                                     = $arguments['cacheTokens'] ?? false;
1048
-        $arguments['colors']                                          = $arguments['colors'] ?? ResultPrinter::COLOR_DEFAULT;
1049
-        $arguments['columns']                                         = $arguments['columns'] ?? 80;
1050
-        $arguments['convertDeprecationsToExceptions']                 = $arguments['convertDeprecationsToExceptions'] ?? true;
1051
-        $arguments['convertErrorsToExceptions']                       = $arguments['convertErrorsToExceptions'] ?? true;
1052
-        $arguments['convertNoticesToExceptions']                      = $arguments['convertNoticesToExceptions'] ?? true;
1053
-        $arguments['convertWarningsToExceptions']                     = $arguments['convertWarningsToExceptions'] ?? true;
1054
-        $arguments['crap4jThreshold']                                 = $arguments['crap4jThreshold'] ?? 30;
1055
-        $arguments['disallowTestOutput']                              = $arguments['disallowTestOutput'] ?? false;
1056
-        $arguments['disallowTodoAnnotatedTests']                      = $arguments['disallowTodoAnnotatedTests'] ?? false;
1057
-        $arguments['enforceTimeLimit']                                = $arguments['enforceTimeLimit'] ?? false;
1058
-        $arguments['excludeGroups']                                   = $arguments['excludeGroups'] ?? [];
1059
-        $arguments['failOnRisky']                                     = $arguments['failOnRisky'] ?? false;
1060
-        $arguments['failOnWarning']                                   = $arguments['failOnWarning'] ?? false;
1061
-        $arguments['groups']                                          = $arguments['groups'] ?? [];
1062
-        $arguments['processIsolation']                                = $arguments['processIsolation'] ?? false;
1063
-        $arguments['processUncoveredFilesFromWhitelist']              = $arguments['processUncoveredFilesFromWhitelist'] ?? false;
1064
-        $arguments['registerMockObjectsFromTestArgumentsRecursively'] = $arguments['registerMockObjectsFromTestArgumentsRecursively'] ?? false;
1065
-        $arguments['repeat']                                          = $arguments['repeat'] ?? false;
1066
-        $arguments['reportHighLowerBound']                            = $arguments['reportHighLowerBound'] ?? 90;
1067
-        $arguments['reportLowUpperBound']                             = $arguments['reportLowUpperBound'] ?? 50;
1068
-        $arguments['reportUselessTests']                              = $arguments['reportUselessTests'] ?? true;
1069
-        $arguments['reverseList']                                     = $arguments['reverseList'] ?? false;
1070
-        $arguments['stopOnError']                                     = $arguments['stopOnError'] ?? false;
1071
-        $arguments['stopOnFailure']                                   = $arguments['stopOnFailure'] ?? false;
1072
-        $arguments['stopOnIncomplete']                                = $arguments['stopOnIncomplete'] ?? false;
1073
-        $arguments['stopOnRisky']                                     = $arguments['stopOnRisky'] ?? false;
1074
-        $arguments['stopOnSkipped']                                   = $arguments['stopOnSkipped'] ?? false;
1075
-        $arguments['stopOnWarning']                                   = $arguments['stopOnWarning'] ?? false;
1076
-        $arguments['strictCoverage']                                  = $arguments['strictCoverage'] ?? false;
1077
-        $arguments['testdoxExcludeGroups']                            = $arguments['testdoxExcludeGroups'] ?? [];
1078
-        $arguments['testdoxGroups']                                   = $arguments['testdoxGroups'] ?? [];
1079
-        $arguments['timeoutForLargeTests']                            = $arguments['timeoutForLargeTests'] ?? 60;
1080
-        $arguments['timeoutForMediumTests']                           = $arguments['timeoutForMediumTests'] ?? 10;
1081
-        $arguments['timeoutForSmallTests']                            = $arguments['timeoutForSmallTests'] ?? 1;
1082
-        $arguments['verbose']                                         = $arguments['verbose'] ?? false;
1083
-    }
1084
-
1085
-    /**
1086
-     * @param string $type
1087
-     * @param string $message
1088
-     */
1089
-    private function writeMessage($type, $message)
1090
-    {
1091
-        if (!$this->messagePrinted) {
1092
-            $this->write("\n");
1093
-        }
1094
-
1095
-        $this->write(
1096
-            \sprintf(
1097
-                "%-15s%s\n",
1098
-                $type . ':',
1099
-                $message
1100
-            )
1101
-        );
1102
-
1103
-        $this->messagePrinted = true;
1104
-    }
55
+	const SUCCESS_EXIT   = 0;
56
+	const FAILURE_EXIT   = 1;
57
+	const EXCEPTION_EXIT = 2;
58
+
59
+	/**
60
+	 * @var CodeCoverageFilter
61
+	 */
62
+	protected $codeCoverageFilter;
63
+
64
+	/**
65
+	 * @var TestSuiteLoader
66
+	 */
67
+	protected $loader;
68
+
69
+	/**
70
+	 * @var ResultPrinter
71
+	 */
72
+	protected $printer;
73
+
74
+	/**
75
+	 * @var bool
76
+	 */
77
+	protected static $versionStringPrinted = false;
78
+
79
+	/**
80
+	 * @var Runtime
81
+	 */
82
+	private $runtime;
83
+
84
+	/**
85
+	 * @var bool
86
+	 */
87
+	private $messagePrinted = false;
88
+
89
+	/**
90
+	 * @param TestSuiteLoader    $loader
91
+	 * @param CodeCoverageFilter $filter
92
+	 */
93
+	public function __construct(TestSuiteLoader $loader = null, CodeCoverageFilter $filter = null)
94
+	{
95
+		if ($filter === null) {
96
+			$filter = new CodeCoverageFilter;
97
+		}
98
+
99
+		$this->codeCoverageFilter = $filter;
100
+		$this->loader             = $loader;
101
+		$this->runtime            = new Runtime;
102
+	}
103
+
104
+	/**
105
+	 * @param Test|ReflectionClass $test
106
+	 * @param array                $arguments
107
+	 *
108
+	 * @return TestResult
109
+	 *
110
+	 * @throws Exception
111
+	 */
112
+	public static function run($test, array $arguments = [])
113
+	{
114
+		if ($test instanceof ReflectionClass) {
115
+			$test = new TestSuite($test);
116
+		}
117
+
118
+		if ($test instanceof Test) {
119
+			$aTestRunner = new self;
120
+
121
+			return $aTestRunner->doRun(
122
+				$test,
123
+				$arguments
124
+			);
125
+		}
126
+
127
+		throw new Exception('No test case or test suite found.');
128
+	}
129
+
130
+	/**
131
+	 * @return TestResult
132
+	 */
133
+	protected function createTestResult()
134
+	{
135
+		return new TestResult;
136
+	}
137
+
138
+	/**
139
+	 * @param TestSuite $suite
140
+	 * @param array     $arguments
141
+	 */
142
+	private function processSuiteFilters(TestSuite $suite, array $arguments)
143
+	{
144
+		if (!$arguments['filter'] &&
145
+			empty($arguments['groups']) &&
146
+			empty($arguments['excludeGroups'])) {
147
+			return;
148
+		}
149
+
150
+		$filterFactory = new Factory;
151
+
152
+		if (!empty($arguments['excludeGroups'])) {
153
+			$filterFactory->addFilter(
154
+				new ReflectionClass(ExcludeGroupFilterIterator::class),
155
+				$arguments['excludeGroups']
156
+			);
157
+		}
158
+
159
+		if (!empty($arguments['groups'])) {
160
+			$filterFactory->addFilter(
161
+				new ReflectionClass(IncludeGroupFilterIterator::class),
162
+				$arguments['groups']
163
+			);
164
+		}
165
+
166
+		if ($arguments['filter']) {
167
+			$filterFactory->addFilter(
168
+				new ReflectionClass(NameFilterIterator::class),
169
+				$arguments['filter']
170
+			);
171
+		}
172
+
173
+		$suite->injectFilter($filterFactory);
174
+	}
175
+
176
+	/**
177
+	 * @param Test  $suite
178
+	 * @param array $arguments
179
+	 * @param bool  $exit
180
+	 *
181
+	 * @return TestResult
182
+	 */
183
+	public function doRun(Test $suite, array $arguments = [], $exit = true)
184
+	{
185
+		if (isset($arguments['configuration'])) {
186
+			$GLOBALS['__PHPUNIT_CONFIGURATION_FILE'] = $arguments['configuration'];
187
+		}
188
+
189
+		$this->handleConfiguration($arguments);
190
+
191
+		$this->processSuiteFilters($suite, $arguments);
192
+
193
+		if (isset($arguments['bootstrap'])) {
194
+			$GLOBALS['__PHPUNIT_BOOTSTRAP'] = $arguments['bootstrap'];
195
+		}
196
+
197
+		if ($arguments['backupGlobals'] === true) {
198
+			$suite->setBackupGlobals(true);
199
+		}
200
+
201
+		if ($arguments['backupStaticAttributes'] === true) {
202
+			$suite->setBackupStaticAttributes(true);
203
+		}
204
+
205
+		if ($arguments['beStrictAboutChangesToGlobalState'] === true) {
206
+			$suite->setbeStrictAboutChangesToGlobalState(true);
207
+		}
208
+
209
+		if (\is_int($arguments['repeat']) && $arguments['repeat'] > 0) {
210
+			$_suite = new TestSuite;
211
+
212
+			foreach (\range(1, $arguments['repeat']) as $step) {
213
+				$_suite->addTest($suite);
214
+			}
215
+
216
+			$suite = $_suite;
217
+			unset($_suite);
218
+		}
219
+
220
+		$result = $this->createTestResult();
221
+
222
+		if (!$arguments['convertErrorsToExceptions']) {
223
+			$result->convertErrorsToExceptions(false);
224
+		}
225
+
226
+		if (!$arguments['convertDeprecationsToExceptions']) {
227
+			Deprecated::$enabled = false;
228
+		}
229
+
230
+		if (!$arguments['convertNoticesToExceptions']) {
231
+			Notice::$enabled = false;
232
+		}
233
+
234
+		if (!$arguments['convertWarningsToExceptions']) {
235
+			Warning::$enabled = false;
236
+		}
237
+
238
+		if ($arguments['stopOnError']) {
239
+			$result->stopOnError(true);
240
+		}
241
+
242
+		if ($arguments['stopOnFailure']) {
243
+			$result->stopOnFailure(true);
244
+		}
245
+
246
+		if ($arguments['stopOnWarning']) {
247
+			$result->stopOnWarning(true);
248
+		}
249
+
250
+		if ($arguments['stopOnIncomplete']) {
251
+			$result->stopOnIncomplete(true);
252
+		}
253
+
254
+		if ($arguments['stopOnRisky']) {
255
+			$result->stopOnRisky(true);
256
+		}
257
+
258
+		if ($arguments['stopOnSkipped']) {
259
+			$result->stopOnSkipped(true);
260
+		}
261
+
262
+		if ($arguments['registerMockObjectsFromTestArgumentsRecursively']) {
263
+			$result->setRegisterMockObjectsFromTestArgumentsRecursively(true);
264
+		}
265
+
266
+		if ($this->printer === null) {
267
+			if (isset($arguments['printer']) &&
268
+				$arguments['printer'] instanceof Printer) {
269
+				$this->printer = $arguments['printer'];
270
+			} else {
271
+				$printerClass = ResultPrinter::class;
272
+
273
+				if (isset($arguments['printer']) && \is_string($arguments['printer']) && \class_exists($arguments['printer'], false)) {
274
+					$class = new ReflectionClass($arguments['printer']);
275
+
276
+					if ($class->isSubclassOf(ResultPrinter::class)) {
277
+						$printerClass = $arguments['printer'];
278
+					}
279
+				}
280
+
281
+				$this->printer = new $printerClass(
282
+					(isset($arguments['stderr']) && $arguments['stderr'] === true) ? 'php://stderr' : null,
283
+					$arguments['verbose'],
284
+					$arguments['colors'],
285
+					$arguments['debug'],
286
+					$arguments['columns'],
287
+					$arguments['reverseList']
288
+				);
289
+			}
290
+		}
291
+
292
+		$this->printer->write(
293
+			Version::getVersionString() . "\n"
294
+		);
295
+
296
+		self::$versionStringPrinted = true;
297
+
298
+		if ($arguments['verbose']) {
299
+			$runtime = $this->runtime->getNameWithVersion();
300
+
301
+			if ($this->runtime->hasXdebug()) {
302
+				$runtime .= \sprintf(
303
+					' with Xdebug %s',
304
+					\phpversion('xdebug')
305
+				);
306
+			}
307
+
308
+			$this->writeMessage('Runtime', $runtime);
309
+
310
+			if (isset($arguments['configuration'])) {
311
+				$this->writeMessage(
312
+					'Configuration',
313
+					$arguments['configuration']->getFilename()
314
+				);
315
+			}
316
+
317
+			foreach ($arguments['loadedExtensions'] as $extension) {
318
+				$this->writeMessage(
319
+					'Extension',
320
+					$extension
321
+				);
322
+			}
323
+
324
+			foreach ($arguments['notLoadedExtensions'] as $extension) {
325
+				$this->writeMessage(
326
+					'Extension',
327
+					$extension
328
+				);
329
+			}
330
+		}
331
+
332
+		if ($this->runtime->discardsComments()) {
333
+			$this->writeMessage('Warning', 'opcache.save_comments=0 set; annotations will not work');
334
+		}
335
+
336
+		foreach ($arguments['listeners'] as $listener) {
337
+			$result->addListener($listener);
338
+		}
339
+
340
+		$result->addListener($this->printer);
341
+
342
+		$codeCoverageReports = 0;
343
+
344
+		if (!isset($arguments['noLogging'])) {
345
+			if (isset($arguments['testdoxHTMLFile'])) {
346
+				$result->addListener(
347
+					new HtmlResultPrinter(
348
+						$arguments['testdoxHTMLFile'],
349
+						$arguments['testdoxGroups'],
350
+						$arguments['testdoxExcludeGroups']
351
+					)
352
+				);
353
+			}
354
+
355
+			if (isset($arguments['testdoxTextFile'])) {
356
+				$result->addListener(
357
+					new TextResultPrinter(
358
+						$arguments['testdoxTextFile'],
359
+						$arguments['testdoxGroups'],
360
+						$arguments['testdoxExcludeGroups']
361
+					)
362
+				);
363
+			}
364
+
365
+			if (isset($arguments['testdoxXMLFile'])) {
366
+				$result->addListener(
367
+					new XmlResultPrinter(
368
+						$arguments['testdoxXMLFile']
369
+					)
370
+				);
371
+			}
372
+
373
+			if (isset($arguments['teamcityLogfile'])) {
374
+				$result->addListener(
375
+					new TeamCity($arguments['teamcityLogfile'])
376
+				);
377
+			}
378
+
379
+			if (isset($arguments['junitLogfile'])) {
380
+				$result->addListener(
381
+					new JUnit(
382
+						$arguments['junitLogfile'],
383
+						$arguments['reportUselessTests']
384
+					)
385
+				);
386
+			}
387
+
388
+			if (isset($arguments['coverageClover'])) {
389
+				$codeCoverageReports++;
390
+			}
391
+
392
+			if (isset($arguments['coverageCrap4J'])) {
393
+				$codeCoverageReports++;
394
+			}
395
+
396
+			if (isset($arguments['coverageHtml'])) {
397
+				$codeCoverageReports++;
398
+			}
399
+
400
+			if (isset($arguments['coveragePHP'])) {
401
+				$codeCoverageReports++;
402
+			}
403
+
404
+			if (isset($arguments['coverageText'])) {
405
+				$codeCoverageReports++;
406
+			}
407
+
408
+			if (isset($arguments['coverageXml'])) {
409
+				$codeCoverageReports++;
410
+			}
411
+		}
412
+
413
+		if (isset($arguments['noCoverage'])) {
414
+			$codeCoverageReports = 0;
415
+		}
416
+
417
+		if ($codeCoverageReports > 0 && !$this->runtime->canCollectCodeCoverage()) {
418
+			$this->writeMessage('Error', 'No code coverage driver is available');
419
+
420
+			$codeCoverageReports = 0;
421
+		}
422
+
423
+		if ($codeCoverageReports > 0) {
424
+			$codeCoverage = new CodeCoverage(
425
+				null,
426
+				$this->codeCoverageFilter
427
+			);
428
+
429
+			$codeCoverage->setUnintentionallyCoveredSubclassesWhitelist(
430
+				[SebastianBergmann\Comparator\Comparator::class]
431
+			);
432
+
433
+			$codeCoverage->setCheckForUnintentionallyCoveredCode(
434
+				$arguments['strictCoverage']
435
+			);
436
+
437
+			$codeCoverage->setCheckForMissingCoversAnnotation(
438
+				$arguments['strictCoverage']
439
+			);
440
+
441
+			if (isset($arguments['forceCoversAnnotation'])) {
442
+				$codeCoverage->setForceCoversAnnotation(
443
+					$arguments['forceCoversAnnotation']
444
+				);
445
+			}
446
+
447
+			if (isset($arguments['ignoreDeprecatedCodeUnitsFromCodeCoverage'])) {
448
+				$codeCoverage->setIgnoreDeprecatedCode(
449
+					$arguments['ignoreDeprecatedCodeUnitsFromCodeCoverage']
450
+				);
451
+			}
452
+
453
+			if (isset($arguments['disableCodeCoverageIgnore'])) {
454
+				$codeCoverage->setDisableIgnoredLines(true);
455
+			}
456
+
457
+			if (isset($arguments['whitelist'])) {
458
+				$this->codeCoverageFilter->addDirectoryToWhitelist($arguments['whitelist']);
459
+			}
460
+
461
+			if (isset($arguments['configuration'])) {
462
+				$filterConfiguration = $arguments['configuration']->getFilterConfiguration();
463
+
464
+				if (empty($filterConfiguration['whitelist']) && !isset($arguments['whitelist'])) {
465
+					$this->writeMessage('Error', 'No whitelist is configured, no code coverage will be generated.');
466
+
467
+					$codeCoverageReports = 0;
468
+
469
+					unset($codeCoverage);
470
+				} else {
471
+					$codeCoverage->setAddUncoveredFilesFromWhitelist(
472
+						$filterConfiguration['whitelist']['addUncoveredFilesFromWhitelist']
473
+					);
474
+
475
+					$codeCoverage->setProcessUncoveredFilesFromWhitelist(
476
+						$filterConfiguration['whitelist']['processUncoveredFilesFromWhitelist']
477
+					);
478
+
479
+					foreach ($filterConfiguration['whitelist']['include']['directory'] as $dir) {
480
+						$this->codeCoverageFilter->addDirectoryToWhitelist(
481
+							$dir['path'],
482
+							$dir['suffix'],
483
+							$dir['prefix']
484
+						);
485
+					}
486
+
487
+					foreach ($filterConfiguration['whitelist']['include']['file'] as $file) {
488
+						$this->codeCoverageFilter->addFileToWhitelist($file);
489
+					}
490
+
491
+					foreach ($filterConfiguration['whitelist']['exclude']['directory'] as $dir) {
492
+						$this->codeCoverageFilter->removeDirectoryFromWhitelist(
493
+							$dir['path'],
494
+							$dir['suffix'],
495
+							$dir['prefix']
496
+						);
497
+					}
498
+
499
+					foreach ($filterConfiguration['whitelist']['exclude']['file'] as $file) {
500
+						$this->codeCoverageFilter->removeFileFromWhitelist($file);
501
+					}
502
+				}
503
+			}
504
+
505
+			if (isset($codeCoverage) && !$this->codeCoverageFilter->hasWhitelist()) {
506
+				$this->writeMessage('Error', 'Incorrect whitelist config, no code coverage will be generated.');
507
+
508
+				$codeCoverageReports = 0;
509
+
510
+				unset($codeCoverage);
511
+			}
512
+		}
513
+
514
+		$this->printer->write("\n");
515
+
516
+		if (isset($codeCoverage)) {
517
+			$result->setCodeCoverage($codeCoverage);
518
+
519
+			if ($codeCoverageReports > 1 && isset($arguments['cacheTokens'])) {
520
+				$codeCoverage->setCacheTokens($arguments['cacheTokens']);
521
+			}
522
+		}
523
+
524
+		$result->beStrictAboutTestsThatDoNotTestAnything($arguments['reportUselessTests']);
525
+		$result->beStrictAboutOutputDuringTests($arguments['disallowTestOutput']);
526
+		$result->beStrictAboutTodoAnnotatedTests($arguments['disallowTodoAnnotatedTests']);
527
+		$result->beStrictAboutResourceUsageDuringSmallTests($arguments['beStrictAboutResourceUsageDuringSmallTests']);
528
+		$result->enforceTimeLimit($arguments['enforceTimeLimit']);
529
+		$result->setTimeoutForSmallTests($arguments['timeoutForSmallTests']);
530
+		$result->setTimeoutForMediumTests($arguments['timeoutForMediumTests']);
531
+		$result->setTimeoutForLargeTests($arguments['timeoutForLargeTests']);
532
+
533
+		if ($suite instanceof TestSuite) {
534
+			$suite->setRunTestInSeparateProcess($arguments['processIsolation']);
535
+		}
536
+
537
+		$suite->run($result);
538
+
539
+		unset($suite);
540
+		$result->flushListeners();
541
+
542
+		if ($this->printer instanceof ResultPrinter) {
543
+			$this->printer->printResult($result);
544
+		}
545
+
546
+		if (isset($codeCoverage)) {
547
+			if (isset($arguments['coverageClover'])) {
548
+				$this->printer->write(
549
+					"\nGenerating code coverage report in Clover XML format ..."
550
+				);
551
+
552
+				try {
553
+					$writer = new CloverReport;
554
+					$writer->process($codeCoverage, $arguments['coverageClover']);
555
+
556
+					$this->printer->write(" done\n");
557
+					unset($writer);
558
+				} catch (CodeCoverageException $e) {
559
+					$this->printer->write(
560
+						" failed\n" . $e->getMessage() . "\n"
561
+					);
562
+				}
563
+			}
564
+
565
+			if (isset($arguments['coverageCrap4J'])) {
566
+				$this->printer->write(
567
+					"\nGenerating Crap4J report XML file ..."
568
+				);
569
+
570
+				try {
571
+					$writer = new Crap4jReport($arguments['crap4jThreshold']);
572
+					$writer->process($codeCoverage, $arguments['coverageCrap4J']);
573
+
574
+					$this->printer->write(" done\n");
575
+					unset($writer);
576
+				} catch (CodeCoverageException $e) {
577
+					$this->printer->write(
578
+						" failed\n" . $e->getMessage() . "\n"
579
+					);
580
+				}
581
+			}
582
+
583
+			if (isset($arguments['coverageHtml'])) {
584
+				$this->printer->write(
585
+					"\nGenerating code coverage report in HTML format ..."
586
+				);
587
+
588
+				try {
589
+					$writer = new HtmlReport(
590
+						$arguments['reportLowUpperBound'],
591
+						$arguments['reportHighLowerBound'],
592
+						\sprintf(
593
+							' and <a href="https://phpunit.de/">PHPUnit %s</a>',
594
+							Version::id()
595
+						)
596
+					);
597
+
598
+					$writer->process($codeCoverage, $arguments['coverageHtml']);
599
+
600
+					$this->printer->write(" done\n");
601
+					unset($writer);
602
+				} catch (CodeCoverageException $e) {
603
+					$this->printer->write(
604
+						" failed\n" . $e->getMessage() . "\n"
605
+					);
606
+				}
607
+			}
608
+
609
+			if (isset($arguments['coveragePHP'])) {
610
+				$this->printer->write(
611
+					"\nGenerating code coverage report in PHP format ..."
612
+				);
613
+
614
+				try {
615
+					$writer = new PhpReport;
616
+					$writer->process($codeCoverage, $arguments['coveragePHP']);
617
+
618
+					$this->printer->write(" done\n");
619
+					unset($writer);
620
+				} catch (CodeCoverageException $e) {
621
+					$this->printer->write(
622
+						" failed\n" . $e->getMessage() . "\n"
623
+					);
624
+				}
625
+			}
626
+
627
+			if (isset($arguments['coverageText'])) {
628
+				if ($arguments['coverageText'] == 'php://stdout') {
629
+					$outputStream = $this->printer;
630
+					$colors       = $arguments['colors'] && $arguments['colors'] != ResultPrinter::COLOR_NEVER;
631
+				} else {
632
+					$outputStream = new Printer($arguments['coverageText']);
633
+					$colors       = false;
634
+				}
635
+
636
+				$processor = new TextReport(
637
+					$arguments['reportLowUpperBound'],
638
+					$arguments['reportHighLowerBound'],
639
+					$arguments['coverageTextShowUncoveredFiles'],
640
+					$arguments['coverageTextShowOnlySummary']
641
+				);
642
+
643
+				$outputStream->write(
644
+					$processor->process($codeCoverage, $colors)
645
+				);
646
+			}
647
+
648
+			if (isset($arguments['coverageXml'])) {
649
+				$this->printer->write(
650
+					"\nGenerating code coverage report in PHPUnit XML format ..."
651
+				);
652
+
653
+				try {
654
+					$writer = new XmlReport(Version::id());
655
+					$writer->process($codeCoverage, $arguments['coverageXml']);
656
+
657
+					$this->printer->write(" done\n");
658
+					unset($writer);
659
+				} catch (CodeCoverageException $e) {
660
+					$this->printer->write(
661
+						" failed\n" . $e->getMessage() . "\n"
662
+					);
663
+				}
664
+			}
665
+		}
666
+
667
+		if ($exit) {
668
+			if ($result->wasSuccessful()) {
669
+				if ($arguments['failOnRisky'] && !$result->allHarmless()) {
670
+					exit(self::FAILURE_EXIT);
671
+				}
672
+
673
+				if ($arguments['failOnWarning'] && $result->warningCount() > 0) {
674
+					exit(self::FAILURE_EXIT);
675
+				}
676
+
677
+				exit(self::SUCCESS_EXIT);
678
+			}
679
+
680
+			if ($result->errorCount() > 0) {
681
+				exit(self::EXCEPTION_EXIT);
682
+			}
683
+
684
+			if ($result->failureCount() > 0) {
685
+				exit(self::FAILURE_EXIT);
686
+			}
687
+		}
688
+
689
+		return $result;
690
+	}
691
+
692
+	/**
693
+	 * @param ResultPrinter $resultPrinter
694
+	 */
695
+	public function setPrinter(ResultPrinter $resultPrinter)
696
+	{
697
+		$this->printer = $resultPrinter;
698
+	}
699
+
700
+	/**
701
+	 * Override to define how to handle a failed loading of
702
+	 * a test suite.
703
+	 *
704
+	 * @param string $message
705
+	 */
706
+	protected function runFailed($message)
707
+	{
708
+		$this->write($message . PHP_EOL);
709
+		exit(self::FAILURE_EXIT);
710
+	}
711
+
712
+	/**
713
+	 * @param string $buffer
714
+	 */
715
+	protected function write($buffer)
716
+	{
717
+		if (PHP_SAPI != 'cli' && PHP_SAPI != 'phpdbg') {
718
+			$buffer = \htmlspecialchars($buffer);
719
+		}
720
+
721
+		if ($this->printer !== null) {
722
+			$this->printer->write($buffer);
723
+		} else {
724
+			print $buffer;
725
+		}
726
+	}
727
+
728
+	/**
729
+	 * Returns the loader to be used.
730
+	 *
731
+	 * @return TestSuiteLoader
732
+	 */
733
+	public function getLoader()
734
+	{
735
+		if ($this->loader === null) {
736
+			$this->loader = new StandardTestSuiteLoader;
737
+		}
738
+
739
+		return $this->loader;
740
+	}
741
+
742
+	/**
743
+	 * @param array $arguments
744
+	 */
745
+	protected function handleConfiguration(array &$arguments)
746
+	{
747
+		if (isset($arguments['configuration']) &&
748
+			!$arguments['configuration'] instanceof Configuration) {
749
+			$arguments['configuration'] = Configuration::getInstance(
750
+				$arguments['configuration']
751
+			);
752
+		}
753
+
754
+		$arguments['debug']     = $arguments['debug'] ?? false;
755
+		$arguments['filter']    = $arguments['filter'] ?? false;
756
+		$arguments['listeners'] = $arguments['listeners'] ?? [];
757
+
758
+		if (isset($arguments['configuration'])) {
759
+			$arguments['configuration']->handlePHPConfiguration();
760
+
761
+			$phpunitConfiguration = $arguments['configuration']->getPHPUnitConfiguration();
762
+
763
+			if (isset($phpunitConfiguration['backupGlobals']) && !isset($arguments['backupGlobals'])) {
764
+				$arguments['backupGlobals'] = $phpunitConfiguration['backupGlobals'];
765
+			}
766
+
767
+			if (isset($phpunitConfiguration['backupStaticAttributes']) && !isset($arguments['backupStaticAttributes'])) {
768
+				$arguments['backupStaticAttributes'] = $phpunitConfiguration['backupStaticAttributes'];
769
+			}
770
+
771
+			if (isset($phpunitConfiguration['beStrictAboutChangesToGlobalState']) && !isset($arguments['beStrictAboutChangesToGlobalState'])) {
772
+				$arguments['beStrictAboutChangesToGlobalState'] = $phpunitConfiguration['beStrictAboutChangesToGlobalState'];
773
+			}
774
+
775
+			if (isset($phpunitConfiguration['bootstrap']) && !isset($arguments['bootstrap'])) {
776
+				$arguments['bootstrap'] = $phpunitConfiguration['bootstrap'];
777
+			}
778
+
779
+			if (isset($phpunitConfiguration['cacheTokens']) && !isset($arguments['cacheTokens'])) {
780
+				$arguments['cacheTokens'] = $phpunitConfiguration['cacheTokens'];
781
+			}
782
+
783
+			if (isset($phpunitConfiguration['colors']) && !isset($arguments['colors'])) {
784
+				$arguments['colors'] = $phpunitConfiguration['colors'];
785
+			}
786
+
787
+			if (isset($phpunitConfiguration['convertDeprecationsToExceptions']) && !isset($arguments['convertDeprecationsToExceptions'])) {
788
+				$arguments['convertDeprecationsToExceptions'] = $phpunitConfiguration['convertDeprecationsToExceptions'];
789
+			}
790
+
791
+			if (isset($phpunitConfiguration['convertErrorsToExceptions']) && !isset($arguments['convertErrorsToExceptions'])) {
792
+				$arguments['convertErrorsToExceptions'] = $phpunitConfiguration['convertErrorsToExceptions'];
793
+			}
794
+
795
+			if (isset($phpunitConfiguration['convertNoticesToExceptions']) && !isset($arguments['convertNoticesToExceptions'])) {
796
+				$arguments['convertNoticesToExceptions'] = $phpunitConfiguration['convertNoticesToExceptions'];
797
+			}
798
+
799
+			if (isset($phpunitConfiguration['convertWarningsToExceptions']) && !isset($arguments['convertWarningsToExceptions'])) {
800
+				$arguments['convertWarningsToExceptions'] = $phpunitConfiguration['convertWarningsToExceptions'];
801
+			}
802
+
803
+			if (isset($phpunitConfiguration['processIsolation']) && !isset($arguments['processIsolation'])) {
804
+				$arguments['processIsolation'] = $phpunitConfiguration['processIsolation'];
805
+			}
806
+
807
+			if (isset($phpunitConfiguration['stopOnError']) && !isset($arguments['stopOnError'])) {
808
+				$arguments['stopOnError'] = $phpunitConfiguration['stopOnError'];
809
+			}
810
+
811
+			if (isset($phpunitConfiguration['stopOnFailure']) && !isset($arguments['stopOnFailure'])) {
812
+				$arguments['stopOnFailure'] = $phpunitConfiguration['stopOnFailure'];
813
+			}
814
+
815
+			if (isset($phpunitConfiguration['stopOnWarning']) && !isset($arguments['stopOnWarning'])) {
816
+				$arguments['stopOnWarning'] = $phpunitConfiguration['stopOnWarning'];
817
+			}
818
+
819
+			if (isset($phpunitConfiguration['stopOnIncomplete']) && !isset($arguments['stopOnIncomplete'])) {
820
+				$arguments['stopOnIncomplete'] = $phpunitConfiguration['stopOnIncomplete'];
821
+			}
822
+
823
+			if (isset($phpunitConfiguration['stopOnRisky']) && !isset($arguments['stopOnRisky'])) {
824
+				$arguments['stopOnRisky'] = $phpunitConfiguration['stopOnRisky'];
825
+			}
826
+
827
+			if (isset($phpunitConfiguration['stopOnSkipped']) && !isset($arguments['stopOnSkipped'])) {
828
+				$arguments['stopOnSkipped'] = $phpunitConfiguration['stopOnSkipped'];
829
+			}
830
+
831
+			if (isset($phpunitConfiguration['failOnWarning']) && !isset($arguments['failOnWarning'])) {
832
+				$arguments['failOnWarning'] = $phpunitConfiguration['failOnWarning'];
833
+			}
834
+
835
+			if (isset($phpunitConfiguration['failOnRisky']) && !isset($arguments['failOnRisky'])) {
836
+				$arguments['failOnRisky'] = $phpunitConfiguration['failOnRisky'];
837
+			}
838
+
839
+			if (isset($phpunitConfiguration['timeoutForSmallTests']) && !isset($arguments['timeoutForSmallTests'])) {
840
+				$arguments['timeoutForSmallTests'] = $phpunitConfiguration['timeoutForSmallTests'];
841
+			}
842
+
843
+			if (isset($phpunitConfiguration['timeoutForMediumTests']) && !isset($arguments['timeoutForMediumTests'])) {
844
+				$arguments['timeoutForMediumTests'] = $phpunitConfiguration['timeoutForMediumTests'];
845
+			}
846
+
847
+			if (isset($phpunitConfiguration['timeoutForLargeTests']) && !isset($arguments['timeoutForLargeTests'])) {
848
+				$arguments['timeoutForLargeTests'] = $phpunitConfiguration['timeoutForLargeTests'];
849
+			}
850
+
851
+			if (isset($phpunitConfiguration['reportUselessTests']) && !isset($arguments['reportUselessTests'])) {
852
+				$arguments['reportUselessTests'] = $phpunitConfiguration['reportUselessTests'];
853
+			}
854
+
855
+			if (isset($phpunitConfiguration['strictCoverage']) && !isset($arguments['strictCoverage'])) {
856
+				$arguments['strictCoverage'] = $phpunitConfiguration['strictCoverage'];
857
+			}
858
+
859
+			if (isset($phpunitConfiguration['ignoreDeprecatedCodeUnitsFromCodeCoverage']) && !isset($arguments['ignoreDeprecatedCodeUnitsFromCodeCoverage'])) {
860
+				$arguments['ignoreDeprecatedCodeUnitsFromCodeCoverage'] = $phpunitConfiguration['ignoreDeprecatedCodeUnitsFromCodeCoverage'];
861
+			}
862
+
863
+			if (isset($phpunitConfiguration['disallowTestOutput']) && !isset($arguments['disallowTestOutput'])) {
864
+				$arguments['disallowTestOutput'] = $phpunitConfiguration['disallowTestOutput'];
865
+			}
866
+
867
+			if (isset($phpunitConfiguration['enforceTimeLimit']) && !isset($arguments['enforceTimeLimit'])) {
868
+				$arguments['enforceTimeLimit'] = $phpunitConfiguration['enforceTimeLimit'];
869
+			}
870
+
871
+			if (isset($phpunitConfiguration['disallowTodoAnnotatedTests']) && !isset($arguments['disallowTodoAnnotatedTests'])) {
872
+				$arguments['disallowTodoAnnotatedTests'] = $phpunitConfiguration['disallowTodoAnnotatedTests'];
873
+			}
874
+
875
+			if (isset($phpunitConfiguration['beStrictAboutResourceUsageDuringSmallTests']) && !isset($arguments['beStrictAboutResourceUsageDuringSmallTests'])) {
876
+				$arguments['beStrictAboutResourceUsageDuringSmallTests'] = $phpunitConfiguration['beStrictAboutResourceUsageDuringSmallTests'];
877
+			}
878
+
879
+			if (isset($phpunitConfiguration['verbose']) && !isset($arguments['verbose'])) {
880
+				$arguments['verbose'] = $phpunitConfiguration['verbose'];
881
+			}
882
+
883
+			if (isset($phpunitConfiguration['reverseDefectList']) && !isset($arguments['reverseList'])) {
884
+				$arguments['reverseList'] = $phpunitConfiguration['reverseDefectList'];
885
+			}
886
+
887
+			if (isset($phpunitConfiguration['forceCoversAnnotation']) && !isset($arguments['forceCoversAnnotation'])) {
888
+				$arguments['forceCoversAnnotation'] = $phpunitConfiguration['forceCoversAnnotation'];
889
+			}
890
+
891
+			if (isset($phpunitConfiguration['disableCodeCoverageIgnore']) && !isset($arguments['disableCodeCoverageIgnore'])) {
892
+				$arguments['disableCodeCoverageIgnore'] = $phpunitConfiguration['disableCodeCoverageIgnore'];
893
+			}
894
+
895
+			if (isset($phpunitConfiguration['registerMockObjectsFromTestArgumentsRecursively']) && !isset($arguments['registerMockObjectsFromTestArgumentsRecursively'])) {
896
+				$arguments['registerMockObjectsFromTestArgumentsRecursively'] = $phpunitConfiguration['registerMockObjectsFromTestArgumentsRecursively'];
897
+			}
898
+
899
+			$groupCliArgs = [];
900
+
901
+			if (!empty($arguments['groups'])) {
902
+				$groupCliArgs = $arguments['groups'];
903
+			}
904
+
905
+			$groupConfiguration = $arguments['configuration']->getGroupConfiguration();
906
+
907
+			if (!empty($groupConfiguration['include']) && !isset($arguments['groups'])) {
908
+				$arguments['groups'] = $groupConfiguration['include'];
909
+			}
910
+
911
+			if (!empty($groupConfiguration['exclude']) && !isset($arguments['excludeGroups'])) {
912
+				$arguments['excludeGroups'] = \array_diff($groupConfiguration['exclude'], $groupCliArgs);
913
+			}
914
+
915
+			foreach ($arguments['configuration']->getListenerConfiguration() as $listener) {
916
+				if (!\class_exists($listener['class'], false) &&
917
+					$listener['file'] !== '') {
918
+					require_once $listener['file'];
919
+				}
920
+
921
+				if (!\class_exists($listener['class'])) {
922
+					throw new Exception(
923
+						\sprintf(
924
+							'Class "%s" does not exist',
925
+							$listener['class']
926
+						)
927
+					);
928
+				}
929
+
930
+				$listenerClass = new ReflectionClass($listener['class']);
931
+
932
+				if (!$listenerClass->implementsInterface(TestListener::class)) {
933
+					throw new Exception(
934
+						\sprintf(
935
+							'Class "%s" does not implement the PHPUnit\Framework\TestListener interface',
936
+							$listener['class']
937
+						)
938
+					);
939
+				}
940
+
941
+				if (\count($listener['arguments']) == 0) {
942
+					$listener = new $listener['class'];
943
+				} else {
944
+					$listener = $listenerClass->newInstanceArgs(
945
+						$listener['arguments']
946
+					);
947
+				}
948
+
949
+				$arguments['listeners'][] = $listener;
950
+			}
951
+
952
+			$loggingConfiguration = $arguments['configuration']->getLoggingConfiguration();
953
+
954
+			if (isset($loggingConfiguration['coverage-clover']) && !isset($arguments['coverageClover'])) {
955
+				$arguments['coverageClover'] = $loggingConfiguration['coverage-clover'];
956
+			}
957
+
958
+			if (isset($loggingConfiguration['coverage-crap4j']) && !isset($arguments['coverageCrap4J'])) {
959
+				$arguments['coverageCrap4J'] = $loggingConfiguration['coverage-crap4j'];
960
+
961
+				if (isset($loggingConfiguration['crap4jThreshold']) && !isset($arguments['crap4jThreshold'])) {
962
+					$arguments['crap4jThreshold'] = $loggingConfiguration['crap4jThreshold'];
963
+				}
964
+			}
965
+
966
+			if (isset($loggingConfiguration['coverage-html']) && !isset($arguments['coverageHtml'])) {
967
+				if (isset($loggingConfiguration['lowUpperBound']) && !isset($arguments['reportLowUpperBound'])) {
968
+					$arguments['reportLowUpperBound'] = $loggingConfiguration['lowUpperBound'];
969
+				}
970
+
971
+				if (isset($loggingConfiguration['highLowerBound']) && !isset($arguments['reportHighLowerBound'])) {
972
+					$arguments['reportHighLowerBound'] = $loggingConfiguration['highLowerBound'];
973
+				}
974
+
975
+				$arguments['coverageHtml'] = $loggingConfiguration['coverage-html'];
976
+			}
977
+
978
+			if (isset($loggingConfiguration['coverage-php']) && !isset($arguments['coveragePHP'])) {
979
+				$arguments['coveragePHP'] = $loggingConfiguration['coverage-php'];
980
+			}
981
+
982
+			if (isset($loggingConfiguration['coverage-text']) && !isset($arguments['coverageText'])) {
983
+				$arguments['coverageText'] = $loggingConfiguration['coverage-text'];
984
+
985
+				if (isset($loggingConfiguration['coverageTextShowUncoveredFiles'])) {
986
+					$arguments['coverageTextShowUncoveredFiles'] = $loggingConfiguration['coverageTextShowUncoveredFiles'];
987
+				} else {
988
+					$arguments['coverageTextShowUncoveredFiles'] = false;
989
+				}
990
+
991
+				if (isset($loggingConfiguration['coverageTextShowOnlySummary'])) {
992
+					$arguments['coverageTextShowOnlySummary'] = $loggingConfiguration['coverageTextShowOnlySummary'];
993
+				} else {
994
+					$arguments['coverageTextShowOnlySummary'] = false;
995
+				}
996
+			}
997
+
998
+			if (isset($loggingConfiguration['coverage-xml']) && !isset($arguments['coverageXml'])) {
999
+				$arguments['coverageXml'] = $loggingConfiguration['coverage-xml'];
1000
+			}
1001
+
1002
+			if (isset($loggingConfiguration['plain'])) {
1003
+				$arguments['listeners'][] = new ResultPrinter(
1004
+					$loggingConfiguration['plain'],
1005
+					true
1006
+				);
1007
+			}
1008
+
1009
+			if (isset($loggingConfiguration['teamcity']) && !isset($arguments['teamcityLogfile'])) {
1010
+				$arguments['teamcityLogfile'] = $loggingConfiguration['teamcity'];
1011
+			}
1012
+
1013
+			if (isset($loggingConfiguration['junit']) && !isset($arguments['junitLogfile'])) {
1014
+				$arguments['junitLogfile'] = $loggingConfiguration['junit'];
1015
+			}
1016
+
1017
+			if (isset($loggingConfiguration['testdox-html']) && !isset($arguments['testdoxHTMLFile'])) {
1018
+				$arguments['testdoxHTMLFile'] = $loggingConfiguration['testdox-html'];
1019
+			}
1020
+
1021
+			if (isset($loggingConfiguration['testdox-text']) && !isset($arguments['testdoxTextFile'])) {
1022
+				$arguments['testdoxTextFile'] = $loggingConfiguration['testdox-text'];
1023
+			}
1024
+
1025
+			if (isset($loggingConfiguration['testdox-xml']) && !isset($arguments['testdoxXMLFile'])) {
1026
+				$arguments['testdoxXMLFile'] = $loggingConfiguration['testdox-xml'];
1027
+			}
1028
+
1029
+			$testdoxGroupConfiguration = $arguments['configuration']->getTestdoxGroupConfiguration();
1030
+
1031
+			if (isset($testdoxGroupConfiguration['include']) &&
1032
+				!isset($arguments['testdoxGroups'])) {
1033
+				$arguments['testdoxGroups'] = $testdoxGroupConfiguration['include'];
1034
+			}
1035
+
1036
+			if (isset($testdoxGroupConfiguration['exclude']) &&
1037
+				!isset($arguments['testdoxExcludeGroups'])) {
1038
+				$arguments['testdoxExcludeGroups'] = $testdoxGroupConfiguration['exclude'];
1039
+			}
1040
+		}
1041
+
1042
+		$arguments['addUncoveredFilesFromWhitelist']                  = $arguments['addUncoveredFilesFromWhitelist'] ?? true;
1043
+		$arguments['backupGlobals']                                   = $arguments['backupGlobals'] ?? null;
1044
+		$arguments['backupStaticAttributes']                          = $arguments['backupStaticAttributes'] ?? null;
1045
+		$arguments['beStrictAboutChangesToGlobalState']               = $arguments['beStrictAboutChangesToGlobalState'] ?? null;
1046
+		$arguments['beStrictAboutResourceUsageDuringSmallTests']      = $arguments['beStrictAboutResourceUsageDuringSmallTests'] ?? false;
1047
+		$arguments['cacheTokens']                                     = $arguments['cacheTokens'] ?? false;
1048
+		$arguments['colors']                                          = $arguments['colors'] ?? ResultPrinter::COLOR_DEFAULT;
1049
+		$arguments['columns']                                         = $arguments['columns'] ?? 80;
1050
+		$arguments['convertDeprecationsToExceptions']                 = $arguments['convertDeprecationsToExceptions'] ?? true;
1051
+		$arguments['convertErrorsToExceptions']                       = $arguments['convertErrorsToExceptions'] ?? true;
1052
+		$arguments['convertNoticesToExceptions']                      = $arguments['convertNoticesToExceptions'] ?? true;
1053
+		$arguments['convertWarningsToExceptions']                     = $arguments['convertWarningsToExceptions'] ?? true;
1054
+		$arguments['crap4jThreshold']                                 = $arguments['crap4jThreshold'] ?? 30;
1055
+		$arguments['disallowTestOutput']                              = $arguments['disallowTestOutput'] ?? false;
1056
+		$arguments['disallowTodoAnnotatedTests']                      = $arguments['disallowTodoAnnotatedTests'] ?? false;
1057
+		$arguments['enforceTimeLimit']                                = $arguments['enforceTimeLimit'] ?? false;
1058
+		$arguments['excludeGroups']                                   = $arguments['excludeGroups'] ?? [];
1059
+		$arguments['failOnRisky']                                     = $arguments['failOnRisky'] ?? false;
1060
+		$arguments['failOnWarning']                                   = $arguments['failOnWarning'] ?? false;
1061
+		$arguments['groups']                                          = $arguments['groups'] ?? [];
1062
+		$arguments['processIsolation']                                = $arguments['processIsolation'] ?? false;
1063
+		$arguments['processUncoveredFilesFromWhitelist']              = $arguments['processUncoveredFilesFromWhitelist'] ?? false;
1064
+		$arguments['registerMockObjectsFromTestArgumentsRecursively'] = $arguments['registerMockObjectsFromTestArgumentsRecursively'] ?? false;
1065
+		$arguments['repeat']                                          = $arguments['repeat'] ?? false;
1066
+		$arguments['reportHighLowerBound']                            = $arguments['reportHighLowerBound'] ?? 90;
1067
+		$arguments['reportLowUpperBound']                             = $arguments['reportLowUpperBound'] ?? 50;
1068
+		$arguments['reportUselessTests']                              = $arguments['reportUselessTests'] ?? true;
1069
+		$arguments['reverseList']                                     = $arguments['reverseList'] ?? false;
1070
+		$arguments['stopOnError']                                     = $arguments['stopOnError'] ?? false;
1071
+		$arguments['stopOnFailure']                                   = $arguments['stopOnFailure'] ?? false;
1072
+		$arguments['stopOnIncomplete']                                = $arguments['stopOnIncomplete'] ?? false;
1073
+		$arguments['stopOnRisky']                                     = $arguments['stopOnRisky'] ?? false;
1074
+		$arguments['stopOnSkipped']                                   = $arguments['stopOnSkipped'] ?? false;
1075
+		$arguments['stopOnWarning']                                   = $arguments['stopOnWarning'] ?? false;
1076
+		$arguments['strictCoverage']                                  = $arguments['strictCoverage'] ?? false;
1077
+		$arguments['testdoxExcludeGroups']                            = $arguments['testdoxExcludeGroups'] ?? [];
1078
+		$arguments['testdoxGroups']                                   = $arguments['testdoxGroups'] ?? [];
1079
+		$arguments['timeoutForLargeTests']                            = $arguments['timeoutForLargeTests'] ?? 60;
1080
+		$arguments['timeoutForMediumTests']                           = $arguments['timeoutForMediumTests'] ?? 10;
1081
+		$arguments['timeoutForSmallTests']                            = $arguments['timeoutForSmallTests'] ?? 1;
1082
+		$arguments['verbose']                                         = $arguments['verbose'] ?? false;
1083
+	}
1084
+
1085
+	/**
1086
+	 * @param string $type
1087
+	 * @param string $message
1088
+	 */
1089
+	private function writeMessage($type, $message)
1090
+	{
1091
+		if (!$this->messagePrinted) {
1092
+			$this->write("\n");
1093
+		}
1094
+
1095
+		$this->write(
1096
+			\sprintf(
1097
+				"%-15s%s\n",
1098
+				$type . ':',
1099
+				$message
1100
+			)
1101
+		);
1102
+
1103
+		$this->messagePrinted = true;
1104
+	}
1105 1105
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
         }
291 291
 
292 292
         $this->printer->write(
293
-            Version::getVersionString() . "\n"
293
+            Version::getVersionString()."\n"
294 294
         );
295 295
 
296 296
         self::$versionStringPrinted = true;
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
                     unset($writer);
558 558
                 } catch (CodeCoverageException $e) {
559 559
                     $this->printer->write(
560
-                        " failed\n" . $e->getMessage() . "\n"
560
+                        " failed\n".$e->getMessage()."\n"
561 561
                     );
562 562
                 }
563 563
             }
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
                     unset($writer);
576 576
                 } catch (CodeCoverageException $e) {
577 577
                     $this->printer->write(
578
-                        " failed\n" . $e->getMessage() . "\n"
578
+                        " failed\n".$e->getMessage()."\n"
579 579
                     );
580 580
                 }
581 581
             }
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
                     unset($writer);
602 602
                 } catch (CodeCoverageException $e) {
603 603
                     $this->printer->write(
604
-                        " failed\n" . $e->getMessage() . "\n"
604
+                        " failed\n".$e->getMessage()."\n"
605 605
                     );
606 606
                 }
607 607
             }
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
                     unset($writer);
620 620
                 } catch (CodeCoverageException $e) {
621 621
                     $this->printer->write(
622
-                        " failed\n" . $e->getMessage() . "\n"
622
+                        " failed\n".$e->getMessage()."\n"
623 623
                     );
624 624
                 }
625 625
             }
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
                     unset($writer);
659 659
                 } catch (CodeCoverageException $e) {
660 660
                     $this->printer->write(
661
-                        " failed\n" . $e->getMessage() . "\n"
661
+                        " failed\n".$e->getMessage()."\n"
662 662
                     );
663 663
                 }
664 664
             }
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
      */
706 706
     protected function runFailed($message)
707 707
     {
708
-        $this->write($message . PHP_EOL);
708
+        $this->write($message.PHP_EOL);
709 709
         exit(self::FAILURE_EXIT);
710 710
     }
711 711
 
@@ -1095,7 +1095,7 @@  discard block
 block discarded – undo
1095 1095
         $this->write(
1096 1096
             \sprintf(
1097 1097
                 "%-15s%s\n",
1098
-                $type . ':',
1098
+                $type.':',
1099 1099
                 $message
1100 1100
             )
1101 1101
         );
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/TextUI/Command.php 2 patches
Indentation   +950 added lines, -950 removed lines patch added patch discarded remove patch
@@ -43,985 +43,985 @@  discard block
 block discarded – undo
43 43
  */
44 44
 class Command
45 45
 {
46
-    /**
47
-     * @var array
48
-     */
49
-    protected $arguments = [
50
-        'listGroups'              => false,
51
-        'listSuites'              => false,
52
-        'listTests'               => false,
53
-        'listTestsXml'            => false,
54
-        'loader'                  => null,
55
-        'useDefaultConfiguration' => true,
56
-        'loadedExtensions'        => [],
57
-        'notLoadedExtensions'     => []
58
-    ];
59
-
60
-    /**
61
-     * @var array
62
-     */
63
-    protected $options = [];
64
-
65
-    /**
66
-     * @var array
67
-     */
68
-    protected $longOptions = [
69
-        'atleast-version='          => null,
70
-        'bootstrap='                => null,
71
-        'check-version'             => null,
72
-        'colors=='                  => null,
73
-        'columns='                  => null,
74
-        'configuration='            => null,
75
-        'coverage-clover='          => null,
76
-        'coverage-crap4j='          => null,
77
-        'coverage-html='            => null,
78
-        'coverage-php='             => null,
79
-        'coverage-text=='           => null,
80
-        'coverage-xml='             => null,
81
-        'debug'                     => null,
82
-        'disallow-test-output'      => null,
83
-        'disallow-resource-usage'   => null,
84
-        'disallow-todo-tests'       => null,
85
-        'enforce-time-limit'        => null,
86
-        'exclude-group='            => null,
87
-        'filter='                   => null,
88
-        'generate-configuration'    => null,
89
-        'globals-backup'            => null,
90
-        'group='                    => null,
91
-        'help'                      => null,
92
-        'include-path='             => null,
93
-        'list-groups'               => null,
94
-        'list-suites'               => null,
95
-        'list-tests'                => null,
96
-        'list-tests-xml='           => null,
97
-        'loader='                   => null,
98
-        'log-junit='                => null,
99
-        'log-teamcity='             => null,
100
-        'no-configuration'          => null,
101
-        'no-coverage'               => null,
102
-        'no-logging'                => null,
103
-        'no-extensions'             => null,
104
-        'printer='                  => null,
105
-        'process-isolation'         => null,
106
-        'repeat='                   => null,
107
-        'dont-report-useless-tests' => null,
108
-        'reverse-list'              => null,
109
-        'static-backup'             => null,
110
-        'stderr'                    => null,
111
-        'stop-on-error'             => null,
112
-        'stop-on-failure'           => null,
113
-        'stop-on-warning'           => null,
114
-        'stop-on-incomplete'        => null,
115
-        'stop-on-risky'             => null,
116
-        'stop-on-skipped'           => null,
117
-        'fail-on-warning'           => null,
118
-        'fail-on-risky'             => null,
119
-        'strict-coverage'           => null,
120
-        'disable-coverage-ignore'   => null,
121
-        'strict-global-state'       => null,
122
-        'teamcity'                  => null,
123
-        'testdox'                   => null,
124
-        'testdox-group='            => null,
125
-        'testdox-exclude-group='    => null,
126
-        'testdox-html='             => null,
127
-        'testdox-text='             => null,
128
-        'testdox-xml='              => null,
129
-        'test-suffix='              => null,
130
-        'testsuite='                => null,
131
-        'verbose'                   => null,
132
-        'version'                   => null,
133
-        'whitelist='                => null
134
-    ];
135
-
136
-    /**
137
-     * @var bool
138
-     */
139
-    private $versionStringPrinted = false;
140
-
141
-    /**
142
-     * @param bool $exit
143
-     */
144
-    public static function main($exit = true)
145
-    {
146
-        $command = new static;
147
-
148
-        return $command->run($_SERVER['argv'], $exit);
149
-    }
150
-
151
-    /**
152
-     * @param array $argv
153
-     * @param bool  $exit
154
-     *
155
-     * @return int
156
-     */
157
-    public function run(array $argv, $exit = true)
158
-    {
159
-        $this->handleArguments($argv);
160
-
161
-        $runner = $this->createRunner();
162
-
163
-        if ($this->arguments['test'] instanceof Test) {
164
-            $suite = $this->arguments['test'];
165
-        } else {
166
-            $suite = $runner->getTest(
167
-                $this->arguments['test'],
168
-                $this->arguments['testFile'],
169
-                $this->arguments['testSuffixes']
170
-            );
171
-        }
172
-
173
-        if ($this->arguments['listGroups']) {
174
-            return $this->handleListGroups($suite, $exit);
175
-        }
176
-
177
-        if ($this->arguments['listSuites']) {
178
-            return $this->handleListSuites($exit);
179
-        }
180
-
181
-        if ($this->arguments['listTests']) {
182
-            return $this->handleListTests($suite, $exit);
183
-        }
184
-
185
-        if ($this->arguments['listTestsXml']) {
186
-            return $this->handleListTestsXml($suite, $this->arguments['listTestsXml'], $exit);
187
-        }
188
-
189
-        unset(
190
-            $this->arguments['test'],
191
-            $this->arguments['testFile']
192
-        );
193
-
194
-        try {
195
-            $result = $runner->doRun($suite, $this->arguments, $exit);
196
-        } catch (Exception $e) {
197
-            print $e->getMessage() . PHP_EOL;
198
-        }
199
-
200
-        $return = TestRunner::FAILURE_EXIT;
201
-
202
-        if (isset($result) && $result->wasSuccessful()) {
203
-            $return = TestRunner::SUCCESS_EXIT;
204
-        } elseif (!isset($result) || $result->errorCount() > 0) {
205
-            $return = TestRunner::EXCEPTION_EXIT;
206
-        }
207
-
208
-        if ($exit) {
209
-            exit($return);
210
-        }
211
-
212
-        return $return;
213
-    }
214
-
215
-    /**
216
-     * Create a TestRunner, override in subclasses.
217
-     *
218
-     * @return TestRunner
219
-     */
220
-    protected function createRunner()
221
-    {
222
-        return new TestRunner($this->arguments['loader']);
223
-    }
224
-
225
-    /**
226
-     * Handles the command-line arguments.
227
-     *
228
-     * A child class of PHPUnit\TextUI\Command can hook into the argument
229
-     * parsing by adding the switch(es) to the $longOptions array and point to a
230
-     * callback method that handles the switch(es) in the child class like this
231
-     *
232
-     * <code>
233
-     * <?php
234
-     * class MyCommand extends PHPUnit\TextUI\Command
235
-     * {
236
-     *     public function __construct()
237
-     *     {
238
-     *         // my-switch won't accept a value, it's an on/off
239
-     *         $this->longOptions['my-switch'] = 'myHandler';
240
-     *         // my-secondswitch will accept a value - note the equals sign
241
-     *         $this->longOptions['my-secondswitch='] = 'myOtherHandler';
242
-     *     }
243
-     *
244
-     *     // --my-switch  -> myHandler()
245
-     *     protected function myHandler()
246
-     *     {
247
-     *     }
248
-     *
249
-     *     // --my-secondswitch foo -> myOtherHandler('foo')
250
-     *     protected function myOtherHandler ($value)
251
-     *     {
252
-     *     }
253
-     *
254
-     *     // You will also need this - the static keyword in the
255
-     *     // PHPUnit\TextUI\Command will mean that it'll be
256
-     *     // PHPUnit\TextUI\Command that gets instantiated,
257
-     *     // not MyCommand
258
-     *     public static function main($exit = true)
259
-     *     {
260
-     *         $command = new static;
261
-     *
262
-     *         return $command->run($_SERVER['argv'], $exit);
263
-     *     }
264
-     *
265
-     * }
266
-     * </code>
267
-     *
268
-     * @param array $argv
269
-     */
270
-    protected function handleArguments(array $argv)
271
-    {
272
-        try {
273
-            $this->options = Getopt::getopt(
274
-                $argv,
275
-                'd:c:hv',
276
-                \array_keys($this->longOptions)
277
-            );
278
-        } catch (Exception $t) {
279
-            $this->exitWithErrorMessage($t->getMessage());
280
-        }
281
-
282
-        foreach ($this->options[0] as $option) {
283
-            switch ($option[0]) {
284
-                case '--colors':
285
-                    $this->arguments['colors'] = $option[1] ?: ResultPrinter::COLOR_AUTO;
286
-
287
-                    break;
288
-
289
-                case '--bootstrap':
290
-                    $this->arguments['bootstrap'] = $option[1];
291
-
292
-                    break;
293
-
294
-                case '--columns':
295
-                    if (\is_numeric($option[1])) {
296
-                        $this->arguments['columns'] = (int) $option[1];
297
-                    } elseif ($option[1] === 'max') {
298
-                        $this->arguments['columns'] = 'max';
299
-                    }
300
-
301
-                    break;
302
-
303
-                case 'c':
304
-                case '--configuration':
305
-                    $this->arguments['configuration'] = $option[1];
306
-
307
-                    break;
308
-
309
-                case '--coverage-clover':
310
-                    $this->arguments['coverageClover'] = $option[1];
311
-
312
-                    break;
313
-
314
-                case '--coverage-crap4j':
315
-                    $this->arguments['coverageCrap4J'] = $option[1];
316
-
317
-                    break;
318
-
319
-                case '--coverage-html':
320
-                    $this->arguments['coverageHtml'] = $option[1];
321
-
322
-                    break;
323
-
324
-                case '--coverage-php':
325
-                    $this->arguments['coveragePHP'] = $option[1];
326
-
327
-                    break;
328
-
329
-                case '--coverage-text':
330
-                    if ($option[1] === null) {
331
-                        $option[1] = 'php://stdout';
332
-                    }
333
-
334
-                    $this->arguments['coverageText']                   = $option[1];
335
-                    $this->arguments['coverageTextShowUncoveredFiles'] = false;
336
-                    $this->arguments['coverageTextShowOnlySummary']    = false;
46
+	/**
47
+	 * @var array
48
+	 */
49
+	protected $arguments = [
50
+		'listGroups'              => false,
51
+		'listSuites'              => false,
52
+		'listTests'               => false,
53
+		'listTestsXml'            => false,
54
+		'loader'                  => null,
55
+		'useDefaultConfiguration' => true,
56
+		'loadedExtensions'        => [],
57
+		'notLoadedExtensions'     => []
58
+	];
59
+
60
+	/**
61
+	 * @var array
62
+	 */
63
+	protected $options = [];
64
+
65
+	/**
66
+	 * @var array
67
+	 */
68
+	protected $longOptions = [
69
+		'atleast-version='          => null,
70
+		'bootstrap='                => null,
71
+		'check-version'             => null,
72
+		'colors=='                  => null,
73
+		'columns='                  => null,
74
+		'configuration='            => null,
75
+		'coverage-clover='          => null,
76
+		'coverage-crap4j='          => null,
77
+		'coverage-html='            => null,
78
+		'coverage-php='             => null,
79
+		'coverage-text=='           => null,
80
+		'coverage-xml='             => null,
81
+		'debug'                     => null,
82
+		'disallow-test-output'      => null,
83
+		'disallow-resource-usage'   => null,
84
+		'disallow-todo-tests'       => null,
85
+		'enforce-time-limit'        => null,
86
+		'exclude-group='            => null,
87
+		'filter='                   => null,
88
+		'generate-configuration'    => null,
89
+		'globals-backup'            => null,
90
+		'group='                    => null,
91
+		'help'                      => null,
92
+		'include-path='             => null,
93
+		'list-groups'               => null,
94
+		'list-suites'               => null,
95
+		'list-tests'                => null,
96
+		'list-tests-xml='           => null,
97
+		'loader='                   => null,
98
+		'log-junit='                => null,
99
+		'log-teamcity='             => null,
100
+		'no-configuration'          => null,
101
+		'no-coverage'               => null,
102
+		'no-logging'                => null,
103
+		'no-extensions'             => null,
104
+		'printer='                  => null,
105
+		'process-isolation'         => null,
106
+		'repeat='                   => null,
107
+		'dont-report-useless-tests' => null,
108
+		'reverse-list'              => null,
109
+		'static-backup'             => null,
110
+		'stderr'                    => null,
111
+		'stop-on-error'             => null,
112
+		'stop-on-failure'           => null,
113
+		'stop-on-warning'           => null,
114
+		'stop-on-incomplete'        => null,
115
+		'stop-on-risky'             => null,
116
+		'stop-on-skipped'           => null,
117
+		'fail-on-warning'           => null,
118
+		'fail-on-risky'             => null,
119
+		'strict-coverage'           => null,
120
+		'disable-coverage-ignore'   => null,
121
+		'strict-global-state'       => null,
122
+		'teamcity'                  => null,
123
+		'testdox'                   => null,
124
+		'testdox-group='            => null,
125
+		'testdox-exclude-group='    => null,
126
+		'testdox-html='             => null,
127
+		'testdox-text='             => null,
128
+		'testdox-xml='              => null,
129
+		'test-suffix='              => null,
130
+		'testsuite='                => null,
131
+		'verbose'                   => null,
132
+		'version'                   => null,
133
+		'whitelist='                => null
134
+	];
135
+
136
+	/**
137
+	 * @var bool
138
+	 */
139
+	private $versionStringPrinted = false;
140
+
141
+	/**
142
+	 * @param bool $exit
143
+	 */
144
+	public static function main($exit = true)
145
+	{
146
+		$command = new static;
147
+
148
+		return $command->run($_SERVER['argv'], $exit);
149
+	}
150
+
151
+	/**
152
+	 * @param array $argv
153
+	 * @param bool  $exit
154
+	 *
155
+	 * @return int
156
+	 */
157
+	public function run(array $argv, $exit = true)
158
+	{
159
+		$this->handleArguments($argv);
160
+
161
+		$runner = $this->createRunner();
162
+
163
+		if ($this->arguments['test'] instanceof Test) {
164
+			$suite = $this->arguments['test'];
165
+		} else {
166
+			$suite = $runner->getTest(
167
+				$this->arguments['test'],
168
+				$this->arguments['testFile'],
169
+				$this->arguments['testSuffixes']
170
+			);
171
+		}
172
+
173
+		if ($this->arguments['listGroups']) {
174
+			return $this->handleListGroups($suite, $exit);
175
+		}
176
+
177
+		if ($this->arguments['listSuites']) {
178
+			return $this->handleListSuites($exit);
179
+		}
180
+
181
+		if ($this->arguments['listTests']) {
182
+			return $this->handleListTests($suite, $exit);
183
+		}
184
+
185
+		if ($this->arguments['listTestsXml']) {
186
+			return $this->handleListTestsXml($suite, $this->arguments['listTestsXml'], $exit);
187
+		}
188
+
189
+		unset(
190
+			$this->arguments['test'],
191
+			$this->arguments['testFile']
192
+		);
193
+
194
+		try {
195
+			$result = $runner->doRun($suite, $this->arguments, $exit);
196
+		} catch (Exception $e) {
197
+			print $e->getMessage() . PHP_EOL;
198
+		}
199
+
200
+		$return = TestRunner::FAILURE_EXIT;
201
+
202
+		if (isset($result) && $result->wasSuccessful()) {
203
+			$return = TestRunner::SUCCESS_EXIT;
204
+		} elseif (!isset($result) || $result->errorCount() > 0) {
205
+			$return = TestRunner::EXCEPTION_EXIT;
206
+		}
207
+
208
+		if ($exit) {
209
+			exit($return);
210
+		}
211
+
212
+		return $return;
213
+	}
214
+
215
+	/**
216
+	 * Create a TestRunner, override in subclasses.
217
+	 *
218
+	 * @return TestRunner
219
+	 */
220
+	protected function createRunner()
221
+	{
222
+		return new TestRunner($this->arguments['loader']);
223
+	}
224
+
225
+	/**
226
+	 * Handles the command-line arguments.
227
+	 *
228
+	 * A child class of PHPUnit\TextUI\Command can hook into the argument
229
+	 * parsing by adding the switch(es) to the $longOptions array and point to a
230
+	 * callback method that handles the switch(es) in the child class like this
231
+	 *
232
+	 * <code>
233
+	 * <?php
234
+	 * class MyCommand extends PHPUnit\TextUI\Command
235
+	 * {
236
+	 *     public function __construct()
237
+	 *     {
238
+	 *         // my-switch won't accept a value, it's an on/off
239
+	 *         $this->longOptions['my-switch'] = 'myHandler';
240
+	 *         // my-secondswitch will accept a value - note the equals sign
241
+	 *         $this->longOptions['my-secondswitch='] = 'myOtherHandler';
242
+	 *     }
243
+	 *
244
+	 *     // --my-switch  -> myHandler()
245
+	 *     protected function myHandler()
246
+	 *     {
247
+	 *     }
248
+	 *
249
+	 *     // --my-secondswitch foo -> myOtherHandler('foo')
250
+	 *     protected function myOtherHandler ($value)
251
+	 *     {
252
+	 *     }
253
+	 *
254
+	 *     // You will also need this - the static keyword in the
255
+	 *     // PHPUnit\TextUI\Command will mean that it'll be
256
+	 *     // PHPUnit\TextUI\Command that gets instantiated,
257
+	 *     // not MyCommand
258
+	 *     public static function main($exit = true)
259
+	 *     {
260
+	 *         $command = new static;
261
+	 *
262
+	 *         return $command->run($_SERVER['argv'], $exit);
263
+	 *     }
264
+	 *
265
+	 * }
266
+	 * </code>
267
+	 *
268
+	 * @param array $argv
269
+	 */
270
+	protected function handleArguments(array $argv)
271
+	{
272
+		try {
273
+			$this->options = Getopt::getopt(
274
+				$argv,
275
+				'd:c:hv',
276
+				\array_keys($this->longOptions)
277
+			);
278
+		} catch (Exception $t) {
279
+			$this->exitWithErrorMessage($t->getMessage());
280
+		}
281
+
282
+		foreach ($this->options[0] as $option) {
283
+			switch ($option[0]) {
284
+				case '--colors':
285
+					$this->arguments['colors'] = $option[1] ?: ResultPrinter::COLOR_AUTO;
286
+
287
+					break;
288
+
289
+				case '--bootstrap':
290
+					$this->arguments['bootstrap'] = $option[1];
291
+
292
+					break;
293
+
294
+				case '--columns':
295
+					if (\is_numeric($option[1])) {
296
+						$this->arguments['columns'] = (int) $option[1];
297
+					} elseif ($option[1] === 'max') {
298
+						$this->arguments['columns'] = 'max';
299
+					}
300
+
301
+					break;
302
+
303
+				case 'c':
304
+				case '--configuration':
305
+					$this->arguments['configuration'] = $option[1];
306
+
307
+					break;
308
+
309
+				case '--coverage-clover':
310
+					$this->arguments['coverageClover'] = $option[1];
311
+
312
+					break;
313
+
314
+				case '--coverage-crap4j':
315
+					$this->arguments['coverageCrap4J'] = $option[1];
316
+
317
+					break;
318
+
319
+				case '--coverage-html':
320
+					$this->arguments['coverageHtml'] = $option[1];
321
+
322
+					break;
323
+
324
+				case '--coverage-php':
325
+					$this->arguments['coveragePHP'] = $option[1];
326
+
327
+					break;
328
+
329
+				case '--coverage-text':
330
+					if ($option[1] === null) {
331
+						$option[1] = 'php://stdout';
332
+					}
333
+
334
+					$this->arguments['coverageText']                   = $option[1];
335
+					$this->arguments['coverageTextShowUncoveredFiles'] = false;
336
+					$this->arguments['coverageTextShowOnlySummary']    = false;
337 337
 
338
-                    break;
338
+					break;
339 339
 
340
-                case '--coverage-xml':
341
-                    $this->arguments['coverageXml'] = $option[1];
340
+				case '--coverage-xml':
341
+					$this->arguments['coverageXml'] = $option[1];
342 342
 
343
-                    break;
343
+					break;
344 344
 
345
-                case 'd':
346
-                    $ini = \explode('=', $option[1]);
345
+				case 'd':
346
+					$ini = \explode('=', $option[1]);
347 347
 
348
-                    if (isset($ini[0])) {
349
-                        if (isset($ini[1])) {
350
-                            \ini_set($ini[0], $ini[1]);
351
-                        } else {
352
-                            \ini_set($ini[0], true);
353
-                        }
354
-                    }
348
+					if (isset($ini[0])) {
349
+						if (isset($ini[1])) {
350
+							\ini_set($ini[0], $ini[1]);
351
+						} else {
352
+							\ini_set($ini[0], true);
353
+						}
354
+					}
355 355
 
356
-                    break;
356
+					break;
357 357
 
358
-                case '--debug':
359
-                    $this->arguments['debug'] = true;
358
+				case '--debug':
359
+					$this->arguments['debug'] = true;
360 360
 
361
-                    break;
361
+					break;
362 362
 
363
-                case 'h':
364
-                case '--help':
365
-                    $this->showHelp();
366
-                    exit(TestRunner::SUCCESS_EXIT);
363
+				case 'h':
364
+				case '--help':
365
+					$this->showHelp();
366
+					exit(TestRunner::SUCCESS_EXIT);
367 367
 
368
-                    break;
368
+					break;
369 369
 
370
-                case '--filter':
371
-                    $this->arguments['filter'] = $option[1];
370
+				case '--filter':
371
+					$this->arguments['filter'] = $option[1];
372 372
 
373
-                    break;
373
+					break;
374 374
 
375
-                case '--testsuite':
376
-                    $this->arguments['testsuite'] = $option[1];
375
+				case '--testsuite':
376
+					$this->arguments['testsuite'] = $option[1];
377 377
 
378
-                    break;
378
+					break;
379 379
 
380
-                case '--generate-configuration':
381
-                    $this->printVersionString();
380
+				case '--generate-configuration':
381
+					$this->printVersionString();
382 382
 
383
-                    print 'Generating phpunit.xml in ' . \getcwd() . PHP_EOL . PHP_EOL;
383
+					print 'Generating phpunit.xml in ' . \getcwd() . PHP_EOL . PHP_EOL;
384 384
 
385
-                    print 'Bootstrap script (relative to path shown above; default: vendor/autoload.php): ';
386
-                    $bootstrapScript = \trim(\fgets(STDIN));
385
+					print 'Bootstrap script (relative to path shown above; default: vendor/autoload.php): ';
386
+					$bootstrapScript = \trim(\fgets(STDIN));
387 387
 
388
-                    print 'Tests directory (relative to path shown above; default: tests): ';
389
-                    $testsDirectory = \trim(\fgets(STDIN));
388
+					print 'Tests directory (relative to path shown above; default: tests): ';
389
+					$testsDirectory = \trim(\fgets(STDIN));
390 390
 
391
-                    print 'Source directory (relative to path shown above; default: src): ';
392
-                    $src = \trim(\fgets(STDIN));
391
+					print 'Source directory (relative to path shown above; default: src): ';
392
+					$src = \trim(\fgets(STDIN));
393 393
 
394
-                    if ($bootstrapScript === '') {
395
-                        $bootstrapScript = 'vendor/autoload.php';
396
-                    }
394
+					if ($bootstrapScript === '') {
395
+						$bootstrapScript = 'vendor/autoload.php';
396
+					}
397 397
 
398
-                    if ($testsDirectory === '') {
399
-                        $testsDirectory = 'tests';
400
-                    }
398
+					if ($testsDirectory === '') {
399
+						$testsDirectory = 'tests';
400
+					}
401 401
 
402
-                    if ($src === '') {
403
-                        $src = 'src';
404
-                    }
402
+					if ($src === '') {
403
+						$src = 'src';
404
+					}
405 405
 
406
-                    $generator = new ConfigurationGenerator;
406
+					$generator = new ConfigurationGenerator;
407 407
 
408
-                    \file_put_contents(
409
-                        'phpunit.xml',
410
-                        $generator->generateDefaultConfiguration(
411
-                            Version::series(),
412
-                            $bootstrapScript,
413
-                            $testsDirectory,
414
-                            $src
415
-                        )
416
-                    );
408
+					\file_put_contents(
409
+						'phpunit.xml',
410
+						$generator->generateDefaultConfiguration(
411
+							Version::series(),
412
+							$bootstrapScript,
413
+							$testsDirectory,
414
+							$src
415
+						)
416
+					);
417 417
 
418
-                    print PHP_EOL . 'Generated phpunit.xml in ' . \getcwd() . PHP_EOL;
418
+					print PHP_EOL . 'Generated phpunit.xml in ' . \getcwd() . PHP_EOL;
419 419
 
420
-                    exit(TestRunner::SUCCESS_EXIT);
420
+					exit(TestRunner::SUCCESS_EXIT);
421 421
 
422
-                    break;
422
+					break;
423 423
 
424
-                case '--group':
425
-                    $this->arguments['groups'] = \explode(',', $option[1]);
424
+				case '--group':
425
+					$this->arguments['groups'] = \explode(',', $option[1]);
426 426
 
427
-                    break;
427
+					break;
428 428
 
429
-                case '--exclude-group':
430
-                    $this->arguments['excludeGroups'] = \explode(
431
-                        ',',
432
-                        $option[1]
433
-                    );
429
+				case '--exclude-group':
430
+					$this->arguments['excludeGroups'] = \explode(
431
+						',',
432
+						$option[1]
433
+					);
434 434
 
435
-                    break;
435
+					break;
436 436
 
437
-                case '--test-suffix':
438
-                    $this->arguments['testSuffixes'] = \explode(
439
-                        ',',
440
-                        $option[1]
441
-                    );
437
+				case '--test-suffix':
438
+					$this->arguments['testSuffixes'] = \explode(
439
+						',',
440
+						$option[1]
441
+					);
442 442
 
443
-                    break;
443
+					break;
444 444
 
445
-                case '--include-path':
446
-                    $includePath = $option[1];
445
+				case '--include-path':
446
+					$includePath = $option[1];
447 447
 
448
-                    break;
448
+					break;
449 449
 
450
-                case '--list-groups':
451
-                    $this->arguments['listGroups'] = true;
450
+				case '--list-groups':
451
+					$this->arguments['listGroups'] = true;
452 452
 
453
-                    break;
453
+					break;
454 454
 
455
-                case '--list-suites':
456
-                    $this->arguments['listSuites'] = true;
455
+				case '--list-suites':
456
+					$this->arguments['listSuites'] = true;
457 457
 
458
-                    break;
458
+					break;
459 459
 
460
-                case '--list-tests':
461
-                    $this->arguments['listTests'] = true;
460
+				case '--list-tests':
461
+					$this->arguments['listTests'] = true;
462 462
 
463
-                    break;
463
+					break;
464 464
 
465
-                case '--list-tests-xml':
466
-                    $this->arguments['listTestsXml'] = $option[1];
465
+				case '--list-tests-xml':
466
+					$this->arguments['listTestsXml'] = $option[1];
467 467
 
468
-                    break;
468
+					break;
469 469
 
470
-                case '--printer':
471
-                    $this->arguments['printer'] = $option[1];
470
+				case '--printer':
471
+					$this->arguments['printer'] = $option[1];
472 472
 
473
-                    break;
473
+					break;
474 474
 
475
-                case '--loader':
476
-                    $this->arguments['loader'] = $option[1];
475
+				case '--loader':
476
+					$this->arguments['loader'] = $option[1];
477 477
 
478
-                    break;
478
+					break;
479 479
 
480
-                case '--log-junit':
481
-                    $this->arguments['junitLogfile'] = $option[1];
480
+				case '--log-junit':
481
+					$this->arguments['junitLogfile'] = $option[1];
482 482
 
483
-                    break;
483
+					break;
484 484
 
485
-                case '--log-teamcity':
486
-                    $this->arguments['teamcityLogfile'] = $option[1];
485
+				case '--log-teamcity':
486
+					$this->arguments['teamcityLogfile'] = $option[1];
487 487
 
488
-                    break;
488
+					break;
489 489
 
490
-                case '--process-isolation':
491
-                    $this->arguments['processIsolation'] = true;
490
+				case '--process-isolation':
491
+					$this->arguments['processIsolation'] = true;
492 492
 
493
-                    break;
493
+					break;
494 494
 
495
-                case '--repeat':
496
-                    $this->arguments['repeat'] = (int) $option[1];
495
+				case '--repeat':
496
+					$this->arguments['repeat'] = (int) $option[1];
497 497
 
498
-                    break;
498
+					break;
499 499
 
500
-                case '--stderr':
501
-                    $this->arguments['stderr'] = true;
500
+				case '--stderr':
501
+					$this->arguments['stderr'] = true;
502 502
 
503
-                    break;
503
+					break;
504 504
 
505
-                case '--stop-on-error':
506
-                    $this->arguments['stopOnError'] = true;
505
+				case '--stop-on-error':
506
+					$this->arguments['stopOnError'] = true;
507 507
 
508
-                    break;
508
+					break;
509 509
 
510
-                case '--stop-on-failure':
511
-                    $this->arguments['stopOnFailure'] = true;
510
+				case '--stop-on-failure':
511
+					$this->arguments['stopOnFailure'] = true;
512 512
 
513
-                    break;
513
+					break;
514 514
 
515
-                case '--stop-on-warning':
516
-                    $this->arguments['stopOnWarning'] = true;
515
+				case '--stop-on-warning':
516
+					$this->arguments['stopOnWarning'] = true;
517 517
 
518
-                    break;
518
+					break;
519 519
 
520
-                case '--stop-on-incomplete':
521
-                    $this->arguments['stopOnIncomplete'] = true;
520
+				case '--stop-on-incomplete':
521
+					$this->arguments['stopOnIncomplete'] = true;
522 522
 
523
-                    break;
523
+					break;
524 524
 
525
-                case '--stop-on-risky':
526
-                    $this->arguments['stopOnRisky'] = true;
525
+				case '--stop-on-risky':
526
+					$this->arguments['stopOnRisky'] = true;
527 527
 
528
-                    break;
528
+					break;
529 529
 
530
-                case '--stop-on-skipped':
531
-                    $this->arguments['stopOnSkipped'] = true;
530
+				case '--stop-on-skipped':
531
+					$this->arguments['stopOnSkipped'] = true;
532 532
 
533
-                    break;
533
+					break;
534 534
 
535
-                case '--fail-on-warning':
536
-                    $this->arguments['failOnWarning'] = true;
535
+				case '--fail-on-warning':
536
+					$this->arguments['failOnWarning'] = true;
537 537
 
538
-                    break;
538
+					break;
539 539
 
540
-                case '--fail-on-risky':
541
-                    $this->arguments['failOnRisky'] = true;
540
+				case '--fail-on-risky':
541
+					$this->arguments['failOnRisky'] = true;
542 542
 
543
-                    break;
543
+					break;
544 544
 
545
-                case '--teamcity':
546
-                    $this->arguments['printer'] = TeamCity::class;
545
+				case '--teamcity':
546
+					$this->arguments['printer'] = TeamCity::class;
547 547
 
548
-                    break;
548
+					break;
549 549
 
550
-                case '--testdox':
551
-                    $this->arguments['printer'] = TextResultPrinter::class;
550
+				case '--testdox':
551
+					$this->arguments['printer'] = TextResultPrinter::class;
552 552
 
553
-                    break;
553
+					break;
554 554
 
555
-                case '--testdox-group':
556
-                    $this->arguments['testdoxGroups'] = \explode(
557
-                        ',',
558
-                        $option[1]
559
-                    );
555
+				case '--testdox-group':
556
+					$this->arguments['testdoxGroups'] = \explode(
557
+						',',
558
+						$option[1]
559
+					);
560 560
 
561
-                    break;
561
+					break;
562 562
 
563
-                case '--testdox-exclude-group':
564
-                    $this->arguments['testdoxExcludeGroups'] = \explode(
565
-                        ',',
566
-                        $option[1]
567
-                    );
563
+				case '--testdox-exclude-group':
564
+					$this->arguments['testdoxExcludeGroups'] = \explode(
565
+						',',
566
+						$option[1]
567
+					);
568 568
 
569
-                    break;
569
+					break;
570 570
 
571
-                case '--testdox-html':
572
-                    $this->arguments['testdoxHTMLFile'] = $option[1];
571
+				case '--testdox-html':
572
+					$this->arguments['testdoxHTMLFile'] = $option[1];
573 573
 
574
-                    break;
574
+					break;
575 575
 
576
-                case '--testdox-text':
577
-                    $this->arguments['testdoxTextFile'] = $option[1];
576
+				case '--testdox-text':
577
+					$this->arguments['testdoxTextFile'] = $option[1];
578 578
 
579
-                    break;
579
+					break;
580 580
 
581
-                case '--testdox-xml':
582
-                    $this->arguments['testdoxXMLFile'] = $option[1];
581
+				case '--testdox-xml':
582
+					$this->arguments['testdoxXMLFile'] = $option[1];
583 583
 
584
-                    break;
584
+					break;
585 585
 
586
-                case '--no-configuration':
587
-                    $this->arguments['useDefaultConfiguration'] = false;
586
+				case '--no-configuration':
587
+					$this->arguments['useDefaultConfiguration'] = false;
588 588
 
589
-                    break;
589
+					break;
590 590
 
591
-                case '--no-extensions':
592
-                    $this->arguments['noExtensions'] = true;
591
+				case '--no-extensions':
592
+					$this->arguments['noExtensions'] = true;
593 593
 
594
-                    break;
594
+					break;
595 595
 
596
-                case '--no-coverage':
597
-                    $this->arguments['noCoverage'] = true;
596
+				case '--no-coverage':
597
+					$this->arguments['noCoverage'] = true;
598 598
 
599
-                    break;
599
+					break;
600 600
 
601
-                case '--no-logging':
602
-                    $this->arguments['noLogging'] = true;
601
+				case '--no-logging':
602
+					$this->arguments['noLogging'] = true;
603 603
 
604
-                    break;
604
+					break;
605 605
 
606
-                case '--globals-backup':
607
-                    $this->arguments['backupGlobals'] = true;
606
+				case '--globals-backup':
607
+					$this->arguments['backupGlobals'] = true;
608 608
 
609
-                    break;
609
+					break;
610 610
 
611
-                case '--static-backup':
612
-                    $this->arguments['backupStaticAttributes'] = true;
611
+				case '--static-backup':
612
+					$this->arguments['backupStaticAttributes'] = true;
613 613
 
614
-                    break;
614
+					break;
615 615
 
616
-                case 'v':
617
-                case '--verbose':
618
-                    $this->arguments['verbose'] = true;
616
+				case 'v':
617
+				case '--verbose':
618
+					$this->arguments['verbose'] = true;
619 619
 
620
-                    break;
620
+					break;
621 621
 
622
-                case '--atleast-version':
623
-                    if (\version_compare(Version::id(), $option[1], '>=')) {
624
-                        exit(TestRunner::SUCCESS_EXIT);
625
-                    }
622
+				case '--atleast-version':
623
+					if (\version_compare(Version::id(), $option[1], '>=')) {
624
+						exit(TestRunner::SUCCESS_EXIT);
625
+					}
626 626
 
627
-                    exit(TestRunner::FAILURE_EXIT);
627
+					exit(TestRunner::FAILURE_EXIT);
628 628
 
629
-                    break;
629
+					break;
630 630
 
631
-                case '--version':
632
-                    $this->printVersionString();
633
-                    exit(TestRunner::SUCCESS_EXIT);
631
+				case '--version':
632
+					$this->printVersionString();
633
+					exit(TestRunner::SUCCESS_EXIT);
634 634
 
635
-                    break;
635
+					break;
636 636
 
637
-                case '--dont-report-useless-tests':
638
-                    $this->arguments['reportUselessTests'] = false;
637
+				case '--dont-report-useless-tests':
638
+					$this->arguments['reportUselessTests'] = false;
639 639
 
640
-                    break;
640
+					break;
641 641
 
642
-                case '--strict-coverage':
643
-                    $this->arguments['strictCoverage'] = true;
642
+				case '--strict-coverage':
643
+					$this->arguments['strictCoverage'] = true;
644 644
 
645
-                    break;
645
+					break;
646 646
 
647
-                case '--disable-coverage-ignore':
648
-                    $this->arguments['disableCodeCoverageIgnore'] = true;
647
+				case '--disable-coverage-ignore':
648
+					$this->arguments['disableCodeCoverageIgnore'] = true;
649 649
 
650
-                    break;
650
+					break;
651 651
 
652
-                case '--strict-global-state':
653
-                    $this->arguments['beStrictAboutChangesToGlobalState'] = true;
652
+				case '--strict-global-state':
653
+					$this->arguments['beStrictAboutChangesToGlobalState'] = true;
654 654
 
655
-                    break;
655
+					break;
656 656
 
657
-                case '--disallow-test-output':
658
-                    $this->arguments['disallowTestOutput'] = true;
657
+				case '--disallow-test-output':
658
+					$this->arguments['disallowTestOutput'] = true;
659 659
 
660
-                    break;
660
+					break;
661 661
 
662
-                case '--disallow-resource-usage':
663
-                    $this->arguments['beStrictAboutResourceUsageDuringSmallTests'] = true;
662
+				case '--disallow-resource-usage':
663
+					$this->arguments['beStrictAboutResourceUsageDuringSmallTests'] = true;
664 664
 
665
-                    break;
665
+					break;
666 666
 
667
-                case '--enforce-time-limit':
668
-                    $this->arguments['enforceTimeLimit'] = true;
667
+				case '--enforce-time-limit':
668
+					$this->arguments['enforceTimeLimit'] = true;
669 669
 
670
-                    break;
670
+					break;
671 671
 
672
-                case '--disallow-todo-tests':
673
-                    $this->arguments['disallowTodoAnnotatedTests'] = true;
672
+				case '--disallow-todo-tests':
673
+					$this->arguments['disallowTodoAnnotatedTests'] = true;
674 674
 
675
-                    break;
675
+					break;
676 676
 
677
-                case '--reverse-list':
678
-                    $this->arguments['reverseList'] = true;
677
+				case '--reverse-list':
678
+					$this->arguments['reverseList'] = true;
679 679
 
680
-                    break;
680
+					break;
681 681
 
682
-                case '--check-version':
683
-                    $this->handleVersionCheck();
682
+				case '--check-version':
683
+					$this->handleVersionCheck();
684 684
 
685
-                    break;
685
+					break;
686 686
 
687
-                case '--whitelist':
688
-                    $this->arguments['whitelist'] = $option[1];
687
+				case '--whitelist':
688
+					$this->arguments['whitelist'] = $option[1];
689 689
 
690
-                    break;
690
+					break;
691 691
 
692
-                default:
693
-                    $optionName = \str_replace('--', '', $option[0]);
692
+				default:
693
+					$optionName = \str_replace('--', '', $option[0]);
694 694
 
695
-                    $handler = null;
696
-                    if (isset($this->longOptions[$optionName])) {
697
-                        $handler = $this->longOptions[$optionName];
698
-                    } elseif (isset($this->longOptions[$optionName . '='])) {
699
-                        $handler = $this->longOptions[$optionName . '='];
700
-                    }
695
+					$handler = null;
696
+					if (isset($this->longOptions[$optionName])) {
697
+						$handler = $this->longOptions[$optionName];
698
+					} elseif (isset($this->longOptions[$optionName . '='])) {
699
+						$handler = $this->longOptions[$optionName . '='];
700
+					}
701 701
 
702
-                    if (isset($handler) && \is_callable([$this, $handler])) {
703
-                        $this->$handler($option[1]);
704
-                    }
705
-            }
706
-        }
702
+					if (isset($handler) && \is_callable([$this, $handler])) {
703
+						$this->$handler($option[1]);
704
+					}
705
+			}
706
+		}
707 707
 
708
-        $this->handleCustomTestSuite();
708
+		$this->handleCustomTestSuite();
709 709
 
710
-        if (!isset($this->arguments['test'])) {
711
-            if (isset($this->options[1][0])) {
712
-                $this->arguments['test'] = $this->options[1][0];
713
-            }
710
+		if (!isset($this->arguments['test'])) {
711
+			if (isset($this->options[1][0])) {
712
+				$this->arguments['test'] = $this->options[1][0];
713
+			}
714 714
 
715
-            if (isset($this->options[1][1])) {
716
-                $this->arguments['testFile'] = \realpath($this->options[1][1]);
717
-            } else {
718
-                $this->arguments['testFile'] = '';
719
-            }
715
+			if (isset($this->options[1][1])) {
716
+				$this->arguments['testFile'] = \realpath($this->options[1][1]);
717
+			} else {
718
+				$this->arguments['testFile'] = '';
719
+			}
720 720
 
721
-            if (isset($this->arguments['test']) &&
722
-                \is_file($this->arguments['test']) &&
723
-                \substr($this->arguments['test'], -5, 5) != '.phpt') {
724
-                $this->arguments['testFile'] = \realpath($this->arguments['test']);
725
-                $this->arguments['test']     = \substr($this->arguments['test'], 0, \strrpos($this->arguments['test'], '.'));
726
-            }
727
-        }
721
+			if (isset($this->arguments['test']) &&
722
+				\is_file($this->arguments['test']) &&
723
+				\substr($this->arguments['test'], -5, 5) != '.phpt') {
724
+				$this->arguments['testFile'] = \realpath($this->arguments['test']);
725
+				$this->arguments['test']     = \substr($this->arguments['test'], 0, \strrpos($this->arguments['test'], '.'));
726
+			}
727
+		}
728 728
 
729
-        if (!isset($this->arguments['testSuffixes'])) {
730
-            $this->arguments['testSuffixes'] = ['Test.php', '.phpt'];
731
-        }
729
+		if (!isset($this->arguments['testSuffixes'])) {
730
+			$this->arguments['testSuffixes'] = ['Test.php', '.phpt'];
731
+		}
732 732
 
733
-        if (isset($includePath)) {
734
-            \ini_set(
735
-                'include_path',
736
-                $includePath . PATH_SEPARATOR . \ini_get('include_path')
737
-            );
738
-        }
733
+		if (isset($includePath)) {
734
+			\ini_set(
735
+				'include_path',
736
+				$includePath . PATH_SEPARATOR . \ini_get('include_path')
737
+			);
738
+		}
739 739
 
740
-        if ($this->arguments['loader'] !== null) {
741
-            $this->arguments['loader'] = $this->handleLoader($this->arguments['loader']);
742
-        }
740
+		if ($this->arguments['loader'] !== null) {
741
+			$this->arguments['loader'] = $this->handleLoader($this->arguments['loader']);
742
+		}
743 743
 
744
-        if (isset($this->arguments['configuration']) &&
745
-            \is_dir($this->arguments['configuration'])) {
746
-            $configurationFile = $this->arguments['configuration'] . '/phpunit.xml';
747
-
748
-            if (\file_exists($configurationFile)) {
749
-                $this->arguments['configuration'] = \realpath(
750
-                    $configurationFile
751
-                );
752
-            } elseif (\file_exists($configurationFile . '.dist')) {
753
-                $this->arguments['configuration'] = \realpath(
754
-                    $configurationFile . '.dist'
755
-                );
756
-            }
757
-        } elseif (!isset($this->arguments['configuration']) &&
758
-            $this->arguments['useDefaultConfiguration']) {
759
-            if (\file_exists('phpunit.xml')) {
760
-                $this->arguments['configuration'] = \realpath('phpunit.xml');
761
-            } elseif (\file_exists('phpunit.xml.dist')) {
762
-                $this->arguments['configuration'] = \realpath(
763
-                    'phpunit.xml.dist'
764
-                );
765
-            }
766
-        }
767
-
768
-        if (isset($this->arguments['configuration'])) {
769
-            try {
770
-                $configuration = Configuration::getInstance(
771
-                    $this->arguments['configuration']
772
-                );
773
-            } catch (Throwable $t) {
774
-                print $t->getMessage() . PHP_EOL;
775
-                exit(TestRunner::FAILURE_EXIT);
776
-            }
777
-
778
-            $phpunitConfiguration = $configuration->getPHPUnitConfiguration();
779
-
780
-            $configuration->handlePHPConfiguration();
781
-
782
-            /*
744
+		if (isset($this->arguments['configuration']) &&
745
+			\is_dir($this->arguments['configuration'])) {
746
+			$configurationFile = $this->arguments['configuration'] . '/phpunit.xml';
747
+
748
+			if (\file_exists($configurationFile)) {
749
+				$this->arguments['configuration'] = \realpath(
750
+					$configurationFile
751
+				);
752
+			} elseif (\file_exists($configurationFile . '.dist')) {
753
+				$this->arguments['configuration'] = \realpath(
754
+					$configurationFile . '.dist'
755
+				);
756
+			}
757
+		} elseif (!isset($this->arguments['configuration']) &&
758
+			$this->arguments['useDefaultConfiguration']) {
759
+			if (\file_exists('phpunit.xml')) {
760
+				$this->arguments['configuration'] = \realpath('phpunit.xml');
761
+			} elseif (\file_exists('phpunit.xml.dist')) {
762
+				$this->arguments['configuration'] = \realpath(
763
+					'phpunit.xml.dist'
764
+				);
765
+			}
766
+		}
767
+
768
+		if (isset($this->arguments['configuration'])) {
769
+			try {
770
+				$configuration = Configuration::getInstance(
771
+					$this->arguments['configuration']
772
+				);
773
+			} catch (Throwable $t) {
774
+				print $t->getMessage() . PHP_EOL;
775
+				exit(TestRunner::FAILURE_EXIT);
776
+			}
777
+
778
+			$phpunitConfiguration = $configuration->getPHPUnitConfiguration();
779
+
780
+			$configuration->handlePHPConfiguration();
781
+
782
+			/*
783 783
              * Issue #1216
784 784
              */
785
-            if (isset($this->arguments['bootstrap'])) {
786
-                $this->handleBootstrap($this->arguments['bootstrap']);
787
-            } elseif (isset($phpunitConfiguration['bootstrap'])) {
788
-                $this->handleBootstrap($phpunitConfiguration['bootstrap']);
789
-            }
785
+			if (isset($this->arguments['bootstrap'])) {
786
+				$this->handleBootstrap($this->arguments['bootstrap']);
787
+			} elseif (isset($phpunitConfiguration['bootstrap'])) {
788
+				$this->handleBootstrap($phpunitConfiguration['bootstrap']);
789
+			}
790 790
 
791
-            /*
791
+			/*
792 792
              * Issue #657
793 793
              */
794
-            if (isset($phpunitConfiguration['stderr']) && !isset($this->arguments['stderr'])) {
795
-                $this->arguments['stderr'] = $phpunitConfiguration['stderr'];
796
-            }
797
-
798
-            if (isset($phpunitConfiguration['extensionsDirectory']) && !isset($this->arguments['noExtensions']) && \extension_loaded('phar')) {
799
-                $this->handleExtensions($phpunitConfiguration['extensionsDirectory']);
800
-            }
801
-
802
-            if (isset($phpunitConfiguration['columns']) && !isset($this->arguments['columns'])) {
803
-                $this->arguments['columns'] = $phpunitConfiguration['columns'];
804
-            }
805
-
806
-            if (!isset($this->arguments['printer']) && isset($phpunitConfiguration['printerClass'])) {
807
-                if (isset($phpunitConfiguration['printerFile'])) {
808
-                    $file = $phpunitConfiguration['printerFile'];
809
-                } else {
810
-                    $file = '';
811
-                }
812
-
813
-                $this->arguments['printer'] = $this->handlePrinter(
814
-                    $phpunitConfiguration['printerClass'],
815
-                    $file
816
-                );
817
-            }
818
-
819
-            if (isset($phpunitConfiguration['testSuiteLoaderClass'])) {
820
-                if (isset($phpunitConfiguration['testSuiteLoaderFile'])) {
821
-                    $file = $phpunitConfiguration['testSuiteLoaderFile'];
822
-                } else {
823
-                    $file = '';
824
-                }
825
-
826
-                $this->arguments['loader'] = $this->handleLoader(
827
-                    $phpunitConfiguration['testSuiteLoaderClass'],
828
-                    $file
829
-                );
830
-            }
831
-
832
-            if (!isset($this->arguments['testsuite']) && isset($phpunitConfiguration['defaultTestSuite'])) {
833
-                $this->arguments['testsuite'] = $phpunitConfiguration['defaultTestSuite'];
834
-            }
835
-
836
-            if (!isset($this->arguments['test'])) {
837
-                $testSuite = $configuration->getTestSuiteConfiguration($this->arguments['testsuite'] ?? null);
838
-
839
-                if ($testSuite !== null) {
840
-                    $this->arguments['test'] = $testSuite;
841
-                }
842
-            }
843
-        } elseif (isset($this->arguments['bootstrap'])) {
844
-            $this->handleBootstrap($this->arguments['bootstrap']);
845
-        }
846
-
847
-        if (isset($this->arguments['printer']) &&
848
-            \is_string($this->arguments['printer'])) {
849
-            $this->arguments['printer'] = $this->handlePrinter($this->arguments['printer']);
850
-        }
851
-
852
-        if (isset($this->arguments['test']) && \is_string($this->arguments['test']) && \substr($this->arguments['test'], -5, 5) == '.phpt') {
853
-            $test = new PhptTestCase($this->arguments['test']);
854
-
855
-            $this->arguments['test'] = new TestSuite;
856
-            $this->arguments['test']->addTest($test);
857
-        }
858
-
859
-        if (!isset($this->arguments['test'])) {
860
-            $this->showHelp();
861
-            exit(TestRunner::EXCEPTION_EXIT);
862
-        }
863
-    }
864
-
865
-    /**
866
-     * Handles the loading of the PHPUnit\Runner\TestSuiteLoader implementation.
867
-     *
868
-     * @param string $loaderClass
869
-     * @param string $loaderFile
870
-     *
871
-     * @return TestSuiteLoader|null
872
-     */
873
-    protected function handleLoader($loaderClass, $loaderFile = '')
874
-    {
875
-        if (!\class_exists($loaderClass, false)) {
876
-            if ($loaderFile == '') {
877
-                $loaderFile = Filesystem::classNameToFilename(
878
-                    $loaderClass
879
-                );
880
-            }
881
-
882
-            $loaderFile = \stream_resolve_include_path($loaderFile);
883
-
884
-            if ($loaderFile) {
885
-                require $loaderFile;
886
-            }
887
-        }
888
-
889
-        if (\class_exists($loaderClass, false)) {
890
-            $class = new ReflectionClass($loaderClass);
891
-
892
-            if ($class->implementsInterface(TestSuiteLoader::class) &&
893
-                $class->isInstantiable()) {
894
-                return $class->newInstance();
895
-            }
896
-        }
897
-
898
-        if ($loaderClass == StandardTestSuiteLoader::class) {
899
-            return;
900
-        }
901
-
902
-        $this->exitWithErrorMessage(
903
-            \sprintf(
904
-                'Could not use "%s" as loader.',
905
-                $loaderClass
906
-            )
907
-        );
908
-    }
909
-
910
-    /**
911
-     * Handles the loading of the PHPUnit\Util\Printer implementation.
912
-     *
913
-     * @param string $printerClass
914
-     * @param string $printerFile
915
-     *
916
-     * @return Printer|string|null
917
-     */
918
-    protected function handlePrinter($printerClass, $printerFile = '')
919
-    {
920
-        if (!\class_exists($printerClass, false)) {
921
-            if ($printerFile == '') {
922
-                $printerFile = Filesystem::classNameToFilename(
923
-                    $printerClass
924
-                );
925
-            }
926
-
927
-            $printerFile = \stream_resolve_include_path($printerFile);
928
-
929
-            if ($printerFile) {
930
-                require $printerFile;
931
-            }
932
-        }
933
-
934
-        if (!\class_exists($printerClass)) {
935
-            $this->exitWithErrorMessage(
936
-                \sprintf(
937
-                    'Could not use "%s" as printer: class does not exist',
938
-                    $printerClass
939
-                )
940
-            );
941
-        }
942
-
943
-        $class = new ReflectionClass($printerClass);
944
-
945
-        if (!$class->implementsInterface(TestListener::class)) {
946
-            $this->exitWithErrorMessage(
947
-                \sprintf(
948
-                    'Could not use "%s" as printer: class does not implement %s',
949
-                    $printerClass,
950
-                    TestListener::class
951
-                )
952
-            );
953
-        }
954
-
955
-        if (!$class->isSubclassOf(Printer::class)) {
956
-            $this->exitWithErrorMessage(
957
-                \sprintf(
958
-                    'Could not use "%s" as printer: class does not extend %s',
959
-                    $printerClass,
960
-                    Printer::class
961
-                )
962
-            );
963
-        }
964
-
965
-        if (!$class->isInstantiable()) {
966
-            $this->exitWithErrorMessage(
967
-                \sprintf(
968
-                    'Could not use "%s" as printer: class cannot be instantiated',
969
-                    $printerClass
970
-                )
971
-            );
972
-        }
973
-
974
-        if ($class->isSubclassOf(ResultPrinter::class)) {
975
-            return $printerClass;
976
-        }
977
-
978
-        $outputStream = isset($this->arguments['stderr']) ? 'php://stderr' : null;
979
-
980
-        return $class->newInstance($outputStream);
981
-    }
982
-
983
-    /**
984
-     * Loads a bootstrap file.
985
-     *
986
-     * @param string $filename
987
-     */
988
-    protected function handleBootstrap($filename)
989
-    {
990
-        try {
991
-            Fileloader::checkAndLoad($filename);
992
-        } catch (Exception $e) {
993
-            $this->exitWithErrorMessage($e->getMessage());
994
-        }
995
-    }
996
-
997
-    protected function handleVersionCheck()
998
-    {
999
-        $this->printVersionString();
1000
-
1001
-        $latestVersion = \file_get_contents('https://phar.phpunit.de/latest-version-of/phpunit');
1002
-        $isOutdated    = \version_compare($latestVersion, Version::id(), '>');
1003
-
1004
-        if ($isOutdated) {
1005
-            \printf(
1006
-                'You are not using the latest version of PHPUnit.' . PHP_EOL .
1007
-                'The latest version is PHPUnit %s.' . PHP_EOL,
1008
-                $latestVersion
1009
-            );
1010
-        } else {
1011
-            print 'You are using the latest version of PHPUnit.' . PHP_EOL;
1012
-        }
1013
-
1014
-        exit(TestRunner::SUCCESS_EXIT);
1015
-    }
1016
-
1017
-    /**
1018
-     * Show the help message.
1019
-     */
1020
-    protected function showHelp()
1021
-    {
1022
-        $this->printVersionString();
1023
-
1024
-        print <<<EOT
794
+			if (isset($phpunitConfiguration['stderr']) && !isset($this->arguments['stderr'])) {
795
+				$this->arguments['stderr'] = $phpunitConfiguration['stderr'];
796
+			}
797
+
798
+			if (isset($phpunitConfiguration['extensionsDirectory']) && !isset($this->arguments['noExtensions']) && \extension_loaded('phar')) {
799
+				$this->handleExtensions($phpunitConfiguration['extensionsDirectory']);
800
+			}
801
+
802
+			if (isset($phpunitConfiguration['columns']) && !isset($this->arguments['columns'])) {
803
+				$this->arguments['columns'] = $phpunitConfiguration['columns'];
804
+			}
805
+
806
+			if (!isset($this->arguments['printer']) && isset($phpunitConfiguration['printerClass'])) {
807
+				if (isset($phpunitConfiguration['printerFile'])) {
808
+					$file = $phpunitConfiguration['printerFile'];
809
+				} else {
810
+					$file = '';
811
+				}
812
+
813
+				$this->arguments['printer'] = $this->handlePrinter(
814
+					$phpunitConfiguration['printerClass'],
815
+					$file
816
+				);
817
+			}
818
+
819
+			if (isset($phpunitConfiguration['testSuiteLoaderClass'])) {
820
+				if (isset($phpunitConfiguration['testSuiteLoaderFile'])) {
821
+					$file = $phpunitConfiguration['testSuiteLoaderFile'];
822
+				} else {
823
+					$file = '';
824
+				}
825
+
826
+				$this->arguments['loader'] = $this->handleLoader(
827
+					$phpunitConfiguration['testSuiteLoaderClass'],
828
+					$file
829
+				);
830
+			}
831
+
832
+			if (!isset($this->arguments['testsuite']) && isset($phpunitConfiguration['defaultTestSuite'])) {
833
+				$this->arguments['testsuite'] = $phpunitConfiguration['defaultTestSuite'];
834
+			}
835
+
836
+			if (!isset($this->arguments['test'])) {
837
+				$testSuite = $configuration->getTestSuiteConfiguration($this->arguments['testsuite'] ?? null);
838
+
839
+				if ($testSuite !== null) {
840
+					$this->arguments['test'] = $testSuite;
841
+				}
842
+			}
843
+		} elseif (isset($this->arguments['bootstrap'])) {
844
+			$this->handleBootstrap($this->arguments['bootstrap']);
845
+		}
846
+
847
+		if (isset($this->arguments['printer']) &&
848
+			\is_string($this->arguments['printer'])) {
849
+			$this->arguments['printer'] = $this->handlePrinter($this->arguments['printer']);
850
+		}
851
+
852
+		if (isset($this->arguments['test']) && \is_string($this->arguments['test']) && \substr($this->arguments['test'], -5, 5) == '.phpt') {
853
+			$test = new PhptTestCase($this->arguments['test']);
854
+
855
+			$this->arguments['test'] = new TestSuite;
856
+			$this->arguments['test']->addTest($test);
857
+		}
858
+
859
+		if (!isset($this->arguments['test'])) {
860
+			$this->showHelp();
861
+			exit(TestRunner::EXCEPTION_EXIT);
862
+		}
863
+	}
864
+
865
+	/**
866
+	 * Handles the loading of the PHPUnit\Runner\TestSuiteLoader implementation.
867
+	 *
868
+	 * @param string $loaderClass
869
+	 * @param string $loaderFile
870
+	 *
871
+	 * @return TestSuiteLoader|null
872
+	 */
873
+	protected function handleLoader($loaderClass, $loaderFile = '')
874
+	{
875
+		if (!\class_exists($loaderClass, false)) {
876
+			if ($loaderFile == '') {
877
+				$loaderFile = Filesystem::classNameToFilename(
878
+					$loaderClass
879
+				);
880
+			}
881
+
882
+			$loaderFile = \stream_resolve_include_path($loaderFile);
883
+
884
+			if ($loaderFile) {
885
+				require $loaderFile;
886
+			}
887
+		}
888
+
889
+		if (\class_exists($loaderClass, false)) {
890
+			$class = new ReflectionClass($loaderClass);
891
+
892
+			if ($class->implementsInterface(TestSuiteLoader::class) &&
893
+				$class->isInstantiable()) {
894
+				return $class->newInstance();
895
+			}
896
+		}
897
+
898
+		if ($loaderClass == StandardTestSuiteLoader::class) {
899
+			return;
900
+		}
901
+
902
+		$this->exitWithErrorMessage(
903
+			\sprintf(
904
+				'Could not use "%s" as loader.',
905
+				$loaderClass
906
+			)
907
+		);
908
+	}
909
+
910
+	/**
911
+	 * Handles the loading of the PHPUnit\Util\Printer implementation.
912
+	 *
913
+	 * @param string $printerClass
914
+	 * @param string $printerFile
915
+	 *
916
+	 * @return Printer|string|null
917
+	 */
918
+	protected function handlePrinter($printerClass, $printerFile = '')
919
+	{
920
+		if (!\class_exists($printerClass, false)) {
921
+			if ($printerFile == '') {
922
+				$printerFile = Filesystem::classNameToFilename(
923
+					$printerClass
924
+				);
925
+			}
926
+
927
+			$printerFile = \stream_resolve_include_path($printerFile);
928
+
929
+			if ($printerFile) {
930
+				require $printerFile;
931
+			}
932
+		}
933
+
934
+		if (!\class_exists($printerClass)) {
935
+			$this->exitWithErrorMessage(
936
+				\sprintf(
937
+					'Could not use "%s" as printer: class does not exist',
938
+					$printerClass
939
+				)
940
+			);
941
+		}
942
+
943
+		$class = new ReflectionClass($printerClass);
944
+
945
+		if (!$class->implementsInterface(TestListener::class)) {
946
+			$this->exitWithErrorMessage(
947
+				\sprintf(
948
+					'Could not use "%s" as printer: class does not implement %s',
949
+					$printerClass,
950
+					TestListener::class
951
+				)
952
+			);
953
+		}
954
+
955
+		if (!$class->isSubclassOf(Printer::class)) {
956
+			$this->exitWithErrorMessage(
957
+				\sprintf(
958
+					'Could not use "%s" as printer: class does not extend %s',
959
+					$printerClass,
960
+					Printer::class
961
+				)
962
+			);
963
+		}
964
+
965
+		if (!$class->isInstantiable()) {
966
+			$this->exitWithErrorMessage(
967
+				\sprintf(
968
+					'Could not use "%s" as printer: class cannot be instantiated',
969
+					$printerClass
970
+				)
971
+			);
972
+		}
973
+
974
+		if ($class->isSubclassOf(ResultPrinter::class)) {
975
+			return $printerClass;
976
+		}
977
+
978
+		$outputStream = isset($this->arguments['stderr']) ? 'php://stderr' : null;
979
+
980
+		return $class->newInstance($outputStream);
981
+	}
982
+
983
+	/**
984
+	 * Loads a bootstrap file.
985
+	 *
986
+	 * @param string $filename
987
+	 */
988
+	protected function handleBootstrap($filename)
989
+	{
990
+		try {
991
+			Fileloader::checkAndLoad($filename);
992
+		} catch (Exception $e) {
993
+			$this->exitWithErrorMessage($e->getMessage());
994
+		}
995
+	}
996
+
997
+	protected function handleVersionCheck()
998
+	{
999
+		$this->printVersionString();
1000
+
1001
+		$latestVersion = \file_get_contents('https://phar.phpunit.de/latest-version-of/phpunit');
1002
+		$isOutdated    = \version_compare($latestVersion, Version::id(), '>');
1003
+
1004
+		if ($isOutdated) {
1005
+			\printf(
1006
+				'You are not using the latest version of PHPUnit.' . PHP_EOL .
1007
+				'The latest version is PHPUnit %s.' . PHP_EOL,
1008
+				$latestVersion
1009
+			);
1010
+		} else {
1011
+			print 'You are using the latest version of PHPUnit.' . PHP_EOL;
1012
+		}
1013
+
1014
+		exit(TestRunner::SUCCESS_EXIT);
1015
+	}
1016
+
1017
+	/**
1018
+	 * Show the help message.
1019
+	 */
1020
+	protected function showHelp()
1021
+	{
1022
+		$this->printVersionString();
1023
+
1024
+		print <<<EOT
1025 1025
 Usage: phpunit [options] UnitTest [UnitTest.php]
1026 1026
        phpunit [options] <directory>
1027 1027
 
@@ -1116,161 +1116,161 @@  discard block
 block discarded – undo
1116 1116
   --check-version             Check whether PHPUnit is the latest version.
1117 1117
 
1118 1118
 EOT;
1119
-    }
1119
+	}
1120 1120
 
1121
-    /**
1122
-     * Custom callback for test suite discovery.
1123
-     */
1124
-    protected function handleCustomTestSuite()
1125
-    {
1126
-    }
1121
+	/**
1122
+	 * Custom callback for test suite discovery.
1123
+	 */
1124
+	protected function handleCustomTestSuite()
1125
+	{
1126
+	}
1127 1127
 
1128
-    private function printVersionString()
1129
-    {
1130
-        if ($this->versionStringPrinted) {
1131
-            return;
1132
-        }
1128
+	private function printVersionString()
1129
+	{
1130
+		if ($this->versionStringPrinted) {
1131
+			return;
1132
+		}
1133 1133
 
1134
-        print Version::getVersionString() . PHP_EOL . PHP_EOL;
1134
+		print Version::getVersionString() . PHP_EOL . PHP_EOL;
1135 1135
 
1136
-        $this->versionStringPrinted = true;
1137
-    }
1136
+		$this->versionStringPrinted = true;
1137
+	}
1138 1138
 
1139
-    /**
1140
-     * @param string $message
1141
-     */
1142
-    private function exitWithErrorMessage($message)
1143
-    {
1144
-        $this->printVersionString();
1139
+	/**
1140
+	 * @param string $message
1141
+	 */
1142
+	private function exitWithErrorMessage($message)
1143
+	{
1144
+		$this->printVersionString();
1145 1145
 
1146
-        print $message . PHP_EOL;
1146
+		print $message . PHP_EOL;
1147 1147
 
1148
-        exit(TestRunner::FAILURE_EXIT);
1149
-    }
1148
+		exit(TestRunner::FAILURE_EXIT);
1149
+	}
1150 1150
 
1151
-    /**
1152
-     * @param string $directory
1153
-     */
1154
-    private function handleExtensions($directory)
1155
-    {
1156
-        $facade = new File_Iterator_Facade;
1151
+	/**
1152
+	 * @param string $directory
1153
+	 */
1154
+	private function handleExtensions($directory)
1155
+	{
1156
+		$facade = new File_Iterator_Facade;
1157 1157
 
1158
-        foreach ($facade->getFilesAsArray($directory, '.phar') as $file) {
1159
-            if (!\file_exists('phar://' . $file . '/manifest.xml')) {
1160
-                $this->arguments['notLoadedExtensions'][] = $file . ' is not an extension for PHPUnit';
1158
+		foreach ($facade->getFilesAsArray($directory, '.phar') as $file) {
1159
+			if (!\file_exists('phar://' . $file . '/manifest.xml')) {
1160
+				$this->arguments['notLoadedExtensions'][] = $file . ' is not an extension for PHPUnit';
1161 1161
 
1162
-                continue;
1163
-            }
1162
+				continue;
1163
+			}
1164 1164
 
1165
-            try {
1166
-                $applicationName = new ApplicationName('phpunit/phpunit');
1167
-                $version         = new PharIoVersion(Version::series());
1168
-                $manifest        = ManifestLoader::fromFile('phar://' . $file . '/manifest.xml');
1165
+			try {
1166
+				$applicationName = new ApplicationName('phpunit/phpunit');
1167
+				$version         = new PharIoVersion(Version::series());
1168
+				$manifest        = ManifestLoader::fromFile('phar://' . $file . '/manifest.xml');
1169 1169
 
1170
-                if (!$manifest->isExtensionFor($applicationName)) {
1171
-                    $this->arguments['notLoadedExtensions'][] = $file . ' is not an extension for PHPUnit';
1170
+				if (!$manifest->isExtensionFor($applicationName)) {
1171
+					$this->arguments['notLoadedExtensions'][] = $file . ' is not an extension for PHPUnit';
1172 1172
 
1173
-                    continue;
1174
-                }
1173
+					continue;
1174
+				}
1175 1175
 
1176
-                if (!$manifest->isExtensionFor($applicationName, $version)) {
1177
-                    $this->arguments['notLoadedExtensions'][] = $file . ' is not compatible with this version of PHPUnit';
1176
+				if (!$manifest->isExtensionFor($applicationName, $version)) {
1177
+					$this->arguments['notLoadedExtensions'][] = $file . ' is not compatible with this version of PHPUnit';
1178 1178
 
1179
-                    continue;
1180
-                }
1181
-            } catch (ManifestException $e) {
1182
-                $this->arguments['notLoadedExtensions'][] = $file . ': ' . $e->getMessage();
1179
+					continue;
1180
+				}
1181
+			} catch (ManifestException $e) {
1182
+				$this->arguments['notLoadedExtensions'][] = $file . ': ' . $e->getMessage();
1183 1183
 
1184
-                continue;
1185
-            }
1184
+				continue;
1185
+			}
1186 1186
 
1187
-            require $file;
1187
+			require $file;
1188 1188
 
1189
-            $this->arguments['loadedExtensions'][] = $manifest->getName() . ' ' . $manifest->getVersion()->getVersionString();
1190
-        }
1191
-    }
1189
+			$this->arguments['loadedExtensions'][] = $manifest->getName() . ' ' . $manifest->getVersion()->getVersionString();
1190
+		}
1191
+	}
1192 1192
 
1193
-    private function handleListGroups(TestSuite $suite, bool $exit): int
1194
-    {
1195
-        $this->printVersionString();
1193
+	private function handleListGroups(TestSuite $suite, bool $exit): int
1194
+	{
1195
+		$this->printVersionString();
1196 1196
 
1197
-        print 'Available test group(s):' . PHP_EOL;
1197
+		print 'Available test group(s):' . PHP_EOL;
1198 1198
 
1199
-        $groups = $suite->getGroups();
1200
-        \sort($groups);
1199
+		$groups = $suite->getGroups();
1200
+		\sort($groups);
1201 1201
 
1202
-        foreach ($groups as $group) {
1203
-            \printf(
1204
-                ' - %s' . PHP_EOL,
1205
-                $group
1206
-            );
1207
-        }
1202
+		foreach ($groups as $group) {
1203
+			\printf(
1204
+				' - %s' . PHP_EOL,
1205
+				$group
1206
+			);
1207
+		}
1208 1208
 
1209
-        if ($exit) {
1210
-            exit(TestRunner::SUCCESS_EXIT);
1211
-        }
1209
+		if ($exit) {
1210
+			exit(TestRunner::SUCCESS_EXIT);
1211
+		}
1212 1212
 
1213
-        return TestRunner::SUCCESS_EXIT;
1214
-    }
1213
+		return TestRunner::SUCCESS_EXIT;
1214
+	}
1215 1215
 
1216
-    private function handleListSuites(bool $exit): int
1217
-    {
1218
-        $this->printVersionString();
1216
+	private function handleListSuites(bool $exit): int
1217
+	{
1218
+		$this->printVersionString();
1219 1219
 
1220
-        print 'Available test suite(s):' . PHP_EOL;
1220
+		print 'Available test suite(s):' . PHP_EOL;
1221 1221
 
1222
-        $configuration = Configuration::getInstance(
1223
-            $this->arguments['configuration']
1224
-        );
1222
+		$configuration = Configuration::getInstance(
1223
+			$this->arguments['configuration']
1224
+		);
1225 1225
 
1226
-        $suiteNames = $configuration->getTestSuiteNames();
1226
+		$suiteNames = $configuration->getTestSuiteNames();
1227 1227
 
1228
-        foreach ($suiteNames as $suiteName) {
1229
-            \printf(
1230
-                ' - %s' . PHP_EOL,
1231
-                $suiteName
1232
-            );
1233
-        }
1228
+		foreach ($suiteNames as $suiteName) {
1229
+			\printf(
1230
+				' - %s' . PHP_EOL,
1231
+				$suiteName
1232
+			);
1233
+		}
1234 1234
 
1235
-        if ($exit) {
1236
-            exit(TestRunner::SUCCESS_EXIT);
1237
-        }
1235
+		if ($exit) {
1236
+			exit(TestRunner::SUCCESS_EXIT);
1237
+		}
1238 1238
 
1239
-        return TestRunner::SUCCESS_EXIT;
1240
-    }
1239
+		return TestRunner::SUCCESS_EXIT;
1240
+	}
1241 1241
 
1242
-    private function handleListTests(TestSuite $suite, bool $exit): int
1243
-    {
1244
-        $this->printVersionString();
1242
+	private function handleListTests(TestSuite $suite, bool $exit): int
1243
+	{
1244
+		$this->printVersionString();
1245 1245
 
1246
-        $renderer = new TextTestListRenderer;
1246
+		$renderer = new TextTestListRenderer;
1247 1247
 
1248
-        print $renderer->render($suite);
1248
+		print $renderer->render($suite);
1249 1249
 
1250
-        if ($exit) {
1251
-            exit(TestRunner::SUCCESS_EXIT);
1252
-        }
1250
+		if ($exit) {
1251
+			exit(TestRunner::SUCCESS_EXIT);
1252
+		}
1253 1253
 
1254
-        return TestRunner::SUCCESS_EXIT;
1255
-    }
1254
+		return TestRunner::SUCCESS_EXIT;
1255
+	}
1256 1256
 
1257
-    private function handleListTestsXml(TestSuite $suite, string $target, bool $exit): int
1258
-    {
1259
-        $this->printVersionString();
1257
+	private function handleListTestsXml(TestSuite $suite, string $target, bool $exit): int
1258
+	{
1259
+		$this->printVersionString();
1260 1260
 
1261
-        $renderer = new XmlTestListRenderer;
1261
+		$renderer = new XmlTestListRenderer;
1262 1262
 
1263
-        \file_put_contents($target, $renderer->render($suite));
1263
+		\file_put_contents($target, $renderer->render($suite));
1264 1264
 
1265
-        \printf(
1266
-            'Wrote list of tests that would have been run to %s' . \PHP_EOL,
1267
-            $target
1268
-        );
1265
+		\printf(
1266
+			'Wrote list of tests that would have been run to %s' . \PHP_EOL,
1267
+			$target
1268
+		);
1269 1269
 
1270
-        if ($exit) {
1271
-            exit(TestRunner::SUCCESS_EXIT);
1272
-        }
1270
+		if ($exit) {
1271
+			exit(TestRunner::SUCCESS_EXIT);
1272
+		}
1273 1273
 
1274
-        return TestRunner::SUCCESS_EXIT;
1275
-    }
1274
+		return TestRunner::SUCCESS_EXIT;
1275
+	}
1276 1276
 }
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
         try {
195 195
             $result = $runner->doRun($suite, $this->arguments, $exit);
196 196
         } catch (Exception $e) {
197
-            print $e->getMessage() . PHP_EOL;
197
+            print $e->getMessage().PHP_EOL;
198 198
         }
199 199
 
200 200
         $return = TestRunner::FAILURE_EXIT;
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
                 case '--generate-configuration':
381 381
                     $this->printVersionString();
382 382
 
383
-                    print 'Generating phpunit.xml in ' . \getcwd() . PHP_EOL . PHP_EOL;
383
+                    print 'Generating phpunit.xml in '.\getcwd().PHP_EOL.PHP_EOL;
384 384
 
385 385
                     print 'Bootstrap script (relative to path shown above; default: vendor/autoload.php): ';
386 386
                     $bootstrapScript = \trim(\fgets(STDIN));
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
                         )
416 416
                     );
417 417
 
418
-                    print PHP_EOL . 'Generated phpunit.xml in ' . \getcwd() . PHP_EOL;
418
+                    print PHP_EOL.'Generated phpunit.xml in '.\getcwd().PHP_EOL;
419 419
 
420 420
                     exit(TestRunner::SUCCESS_EXIT);
421 421
 
@@ -695,8 +695,8 @@  discard block
 block discarded – undo
695 695
                     $handler = null;
696 696
                     if (isset($this->longOptions[$optionName])) {
697 697
                         $handler = $this->longOptions[$optionName];
698
-                    } elseif (isset($this->longOptions[$optionName . '='])) {
699
-                        $handler = $this->longOptions[$optionName . '='];
698
+                    } elseif (isset($this->longOptions[$optionName.'='])) {
699
+                        $handler = $this->longOptions[$optionName.'='];
700 700
                     }
701 701
 
702 702
                     if (isset($handler) && \is_callable([$this, $handler])) {
@@ -733,7 +733,7 @@  discard block
 block discarded – undo
733 733
         if (isset($includePath)) {
734 734
             \ini_set(
735 735
                 'include_path',
736
-                $includePath . PATH_SEPARATOR . \ini_get('include_path')
736
+                $includePath.PATH_SEPARATOR.\ini_get('include_path')
737 737
             );
738 738
         }
739 739
 
@@ -743,15 +743,15 @@  discard block
 block discarded – undo
743 743
 
744 744
         if (isset($this->arguments['configuration']) &&
745 745
             \is_dir($this->arguments['configuration'])) {
746
-            $configurationFile = $this->arguments['configuration'] . '/phpunit.xml';
746
+            $configurationFile = $this->arguments['configuration'].'/phpunit.xml';
747 747
 
748 748
             if (\file_exists($configurationFile)) {
749 749
                 $this->arguments['configuration'] = \realpath(
750 750
                     $configurationFile
751 751
                 );
752
-            } elseif (\file_exists($configurationFile . '.dist')) {
752
+            } elseif (\file_exists($configurationFile.'.dist')) {
753 753
                 $this->arguments['configuration'] = \realpath(
754
-                    $configurationFile . '.dist'
754
+                    $configurationFile.'.dist'
755 755
                 );
756 756
             }
757 757
         } elseif (!isset($this->arguments['configuration']) &&
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
                     $this->arguments['configuration']
772 772
                 );
773 773
             } catch (Throwable $t) {
774
-                print $t->getMessage() . PHP_EOL;
774
+                print $t->getMessage().PHP_EOL;
775 775
                 exit(TestRunner::FAILURE_EXIT);
776 776
             }
777 777
 
@@ -1003,12 +1003,12 @@  discard block
 block discarded – undo
1003 1003
 
1004 1004
         if ($isOutdated) {
1005 1005
             \printf(
1006
-                'You are not using the latest version of PHPUnit.' . PHP_EOL .
1007
-                'The latest version is PHPUnit %s.' . PHP_EOL,
1006
+                'You are not using the latest version of PHPUnit.'.PHP_EOL.
1007
+                'The latest version is PHPUnit %s.'.PHP_EOL,
1008 1008
                 $latestVersion
1009 1009
             );
1010 1010
         } else {
1011
-            print 'You are using the latest version of PHPUnit.' . PHP_EOL;
1011
+            print 'You are using the latest version of PHPUnit.'.PHP_EOL;
1012 1012
         }
1013 1013
 
1014 1014
         exit(TestRunner::SUCCESS_EXIT);
@@ -1131,7 +1131,7 @@  discard block
 block discarded – undo
1131 1131
             return;
1132 1132
         }
1133 1133
 
1134
-        print Version::getVersionString() . PHP_EOL . PHP_EOL;
1134
+        print Version::getVersionString().PHP_EOL.PHP_EOL;
1135 1135
 
1136 1136
         $this->versionStringPrinted = true;
1137 1137
     }
@@ -1143,7 +1143,7 @@  discard block
 block discarded – undo
1143 1143
     {
1144 1144
         $this->printVersionString();
1145 1145
 
1146
-        print $message . PHP_EOL;
1146
+        print $message.PHP_EOL;
1147 1147
 
1148 1148
         exit(TestRunner::FAILURE_EXIT);
1149 1149
     }
@@ -1156,8 +1156,8 @@  discard block
 block discarded – undo
1156 1156
         $facade = new File_Iterator_Facade;
1157 1157
 
1158 1158
         foreach ($facade->getFilesAsArray($directory, '.phar') as $file) {
1159
-            if (!\file_exists('phar://' . $file . '/manifest.xml')) {
1160
-                $this->arguments['notLoadedExtensions'][] = $file . ' is not an extension for PHPUnit';
1159
+            if (!\file_exists('phar://'.$file.'/manifest.xml')) {
1160
+                $this->arguments['notLoadedExtensions'][] = $file.' is not an extension for PHPUnit';
1161 1161
 
1162 1162
                 continue;
1163 1163
             }
@@ -1165,28 +1165,28 @@  discard block
 block discarded – undo
1165 1165
             try {
1166 1166
                 $applicationName = new ApplicationName('phpunit/phpunit');
1167 1167
                 $version         = new PharIoVersion(Version::series());
1168
-                $manifest        = ManifestLoader::fromFile('phar://' . $file . '/manifest.xml');
1168
+                $manifest        = ManifestLoader::fromFile('phar://'.$file.'/manifest.xml');
1169 1169
 
1170 1170
                 if (!$manifest->isExtensionFor($applicationName)) {
1171
-                    $this->arguments['notLoadedExtensions'][] = $file . ' is not an extension for PHPUnit';
1171
+                    $this->arguments['notLoadedExtensions'][] = $file.' is not an extension for PHPUnit';
1172 1172
 
1173 1173
                     continue;
1174 1174
                 }
1175 1175
 
1176 1176
                 if (!$manifest->isExtensionFor($applicationName, $version)) {
1177
-                    $this->arguments['notLoadedExtensions'][] = $file . ' is not compatible with this version of PHPUnit';
1177
+                    $this->arguments['notLoadedExtensions'][] = $file.' is not compatible with this version of PHPUnit';
1178 1178
 
1179 1179
                     continue;
1180 1180
                 }
1181 1181
             } catch (ManifestException $e) {
1182
-                $this->arguments['notLoadedExtensions'][] = $file . ': ' . $e->getMessage();
1182
+                $this->arguments['notLoadedExtensions'][] = $file.': '.$e->getMessage();
1183 1183
 
1184 1184
                 continue;
1185 1185
             }
1186 1186
 
1187 1187
             require $file;
1188 1188
 
1189
-            $this->arguments['loadedExtensions'][] = $manifest->getName() . ' ' . $manifest->getVersion()->getVersionString();
1189
+            $this->arguments['loadedExtensions'][] = $manifest->getName().' '.$manifest->getVersion()->getVersionString();
1190 1190
         }
1191 1191
     }
1192 1192
 
@@ -1194,14 +1194,14 @@  discard block
 block discarded – undo
1194 1194
     {
1195 1195
         $this->printVersionString();
1196 1196
 
1197
-        print 'Available test group(s):' . PHP_EOL;
1197
+        print 'Available test group(s):'.PHP_EOL;
1198 1198
 
1199 1199
         $groups = $suite->getGroups();
1200 1200
         \sort($groups);
1201 1201
 
1202 1202
         foreach ($groups as $group) {
1203 1203
             \printf(
1204
-                ' - %s' . PHP_EOL,
1204
+                ' - %s'.PHP_EOL,
1205 1205
                 $group
1206 1206
             );
1207 1207
         }
@@ -1217,7 +1217,7 @@  discard block
 block discarded – undo
1217 1217
     {
1218 1218
         $this->printVersionString();
1219 1219
 
1220
-        print 'Available test suite(s):' . PHP_EOL;
1220
+        print 'Available test suite(s):'.PHP_EOL;
1221 1221
 
1222 1222
         $configuration = Configuration::getInstance(
1223 1223
             $this->arguments['configuration']
@@ -1227,7 +1227,7 @@  discard block
 block discarded – undo
1227 1227
 
1228 1228
         foreach ($suiteNames as $suiteName) {
1229 1229
             \printf(
1230
-                ' - %s' . PHP_EOL,
1230
+                ' - %s'.PHP_EOL,
1231 1231
                 $suiteName
1232 1232
             );
1233 1233
         }
@@ -1263,7 +1263,7 @@  discard block
 block discarded – undo
1263 1263
         \file_put_contents($target, $renderer->render($suite));
1264 1264
 
1265 1265
         \printf(
1266
-            'Wrote list of tests that would have been run to %s' . \PHP_EOL,
1266
+            'Wrote list of tests that would have been run to %s'.\PHP_EOL,
1267 1267
             $target
1268 1268
         );
1269 1269
 
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/TextUI/ResultPrinter.php 2 patches
Indentation   +660 added lines, -660 removed lines patch added patch discarded remove patch
@@ -30,664 +30,664 @@
 block discarded – undo
30 30
  */
31 31
 class ResultPrinter extends Printer implements TestListener
32 32
 {
33
-    const EVENT_TEST_START      = 0;
34
-    const EVENT_TEST_END        = 1;
35
-    const EVENT_TESTSUITE_START = 2;
36
-    const EVENT_TESTSUITE_END   = 3;
37
-
38
-    const COLOR_NEVER   = 'never';
39
-    const COLOR_AUTO    = 'auto';
40
-    const COLOR_ALWAYS  = 'always';
41
-    const COLOR_DEFAULT = self::COLOR_NEVER;
42
-
43
-    /**
44
-     * @var array
45
-     */
46
-    private static $ansiCodes = [
47
-        'bold'       => 1,
48
-        'fg-black'   => 30,
49
-        'fg-red'     => 31,
50
-        'fg-green'   => 32,
51
-        'fg-yellow'  => 33,
52
-        'fg-blue'    => 34,
53
-        'fg-magenta' => 35,
54
-        'fg-cyan'    => 36,
55
-        'fg-white'   => 37,
56
-        'bg-black'   => 40,
57
-        'bg-red'     => 41,
58
-        'bg-green'   => 42,
59
-        'bg-yellow'  => 43,
60
-        'bg-blue'    => 44,
61
-        'bg-magenta' => 45,
62
-        'bg-cyan'    => 46,
63
-        'bg-white'   => 47
64
-    ];
65
-
66
-    /**
67
-     * @var int
68
-     */
69
-    protected $column = 0;
70
-
71
-    /**
72
-     * @var int
73
-     */
74
-    protected $maxColumn;
75
-
76
-    /**
77
-     * @var bool
78
-     */
79
-    protected $lastTestFailed = false;
80
-
81
-    /**
82
-     * @var int
83
-     */
84
-    protected $numAssertions = 0;
85
-
86
-    /**
87
-     * @var int
88
-     */
89
-    protected $numTests = -1;
90
-
91
-    /**
92
-     * @var int
93
-     */
94
-    protected $numTestsRun = 0;
95
-
96
-    /**
97
-     * @var int
98
-     */
99
-    protected $numTestsWidth;
100
-
101
-    /**
102
-     * @var bool
103
-     */
104
-    protected $colors = false;
105
-
106
-    /**
107
-     * @var bool
108
-     */
109
-    protected $debug = false;
110
-
111
-    /**
112
-     * @var bool
113
-     */
114
-    protected $verbose = false;
115
-
116
-    /**
117
-     * @var int
118
-     */
119
-    private $numberOfColumns;
120
-
121
-    /**
122
-     * @var bool
123
-     */
124
-    private $reverse;
125
-
126
-    /**
127
-     * @var bool
128
-     */
129
-    private $defectListPrinted = false;
130
-
131
-    /**
132
-     * Constructor.
133
-     *
134
-     * @param mixed      $out
135
-     * @param bool       $verbose
136
-     * @param string     $colors
137
-     * @param bool       $debug
138
-     * @param int|string $numberOfColumns
139
-     * @param bool       $reverse
140
-     *
141
-     * @throws Exception
142
-     */
143
-    public function __construct($out = null, $verbose = false, $colors = self::COLOR_DEFAULT, $debug = false, $numberOfColumns = 80, $reverse = false)
144
-    {
145
-        parent::__construct($out);
146
-
147
-        if (!\is_bool($verbose)) {
148
-            throw InvalidArgumentHelper::factory(2, 'boolean');
149
-        }
150
-
151
-        $availableColors = [self::COLOR_NEVER, self::COLOR_AUTO, self::COLOR_ALWAYS];
152
-
153
-        if (!\in_array($colors, $availableColors)) {
154
-            throw InvalidArgumentHelper::factory(
155
-                3,
156
-                \vsprintf('value from "%s", "%s" or "%s"', $availableColors)
157
-            );
158
-        }
159
-
160
-        if (!\is_bool($debug)) {
161
-            throw InvalidArgumentHelper::factory(4, 'boolean');
162
-        }
163
-
164
-        if (!\is_int($numberOfColumns) && $numberOfColumns !== 'max') {
165
-            throw InvalidArgumentHelper::factory(5, 'integer or "max"');
166
-        }
167
-
168
-        if (!\is_bool($reverse)) {
169
-            throw InvalidArgumentHelper::factory(6, 'boolean');
170
-        }
171
-
172
-        $console            = new Console;
173
-        $maxNumberOfColumns = $console->getNumberOfColumns();
174
-
175
-        if ($numberOfColumns === 'max' || ($numberOfColumns !== 80 && $numberOfColumns > $maxNumberOfColumns)) {
176
-            $numberOfColumns = $maxNumberOfColumns;
177
-        }
178
-
179
-        $this->numberOfColumns = $numberOfColumns;
180
-        $this->verbose         = $verbose;
181
-        $this->debug           = $debug;
182
-        $this->reverse         = $reverse;
183
-
184
-        if ($colors === self::COLOR_AUTO && $console->hasColorSupport()) {
185
-            $this->colors = true;
186
-        } else {
187
-            $this->colors = (self::COLOR_ALWAYS === $colors);
188
-        }
189
-    }
190
-
191
-    /**
192
-     * @param TestResult $result
193
-     */
194
-    public function printResult(TestResult $result)
195
-    {
196
-        $this->printHeader();
197
-        $this->printErrors($result);
198
-        $this->printWarnings($result);
199
-        $this->printFailures($result);
200
-        $this->printRisky($result);
201
-
202
-        if ($this->verbose) {
203
-            $this->printIncompletes($result);
204
-            $this->printSkipped($result);
205
-        }
206
-
207
-        $this->printFooter($result);
208
-    }
209
-
210
-    /**
211
-     * @param array  $defects
212
-     * @param string $type
213
-     */
214
-    protected function printDefects(array $defects, $type)
215
-    {
216
-        $count = \count($defects);
217
-
218
-        if ($count == 0) {
219
-            return;
220
-        }
221
-
222
-        if ($this->defectListPrinted) {
223
-            $this->write("\n--\n\n");
224
-        }
225
-
226
-        $this->write(
227
-            \sprintf(
228
-                "There %s %d %s%s:\n",
229
-                ($count == 1) ? 'was' : 'were',
230
-                $count,
231
-                $type,
232
-                ($count == 1) ? '' : 's'
233
-            )
234
-        );
235
-
236
-        $i = 1;
237
-
238
-        if ($this->reverse) {
239
-            $defects = \array_reverse($defects);
240
-        }
241
-
242
-        foreach ($defects as $defect) {
243
-            $this->printDefect($defect, $i++);
244
-        }
245
-
246
-        $this->defectListPrinted = true;
247
-    }
248
-
249
-    /**
250
-     * @param TestFailure $defect
251
-     * @param int         $count
252
-     */
253
-    protected function printDefect(TestFailure $defect, $count)
254
-    {
255
-        $this->printDefectHeader($defect, $count);
256
-        $this->printDefectTrace($defect);
257
-    }
258
-
259
-    /**
260
-     * @param TestFailure $defect
261
-     * @param int         $count
262
-     */
263
-    protected function printDefectHeader(TestFailure $defect, $count)
264
-    {
265
-        $this->write(
266
-            \sprintf(
267
-                "\n%d) %s\n",
268
-                $count,
269
-                $defect->getTestName()
270
-            )
271
-        );
272
-    }
273
-
274
-    /**
275
-     * @param TestFailure $defect
276
-     */
277
-    protected function printDefectTrace(TestFailure $defect)
278
-    {
279
-        $e = $defect->thrownException();
280
-        $this->write((string) $e);
281
-
282
-        while ($e = $e->getPrevious()) {
283
-            $this->write("\nCaused by\n" . $e);
284
-        }
285
-    }
286
-
287
-    /**
288
-     * @param TestResult $result
289
-     */
290
-    protected function printErrors(TestResult $result)
291
-    {
292
-        $this->printDefects($result->errors(), 'error');
293
-    }
294
-
295
-    /**
296
-     * @param TestResult $result
297
-     */
298
-    protected function printFailures(TestResult $result)
299
-    {
300
-        $this->printDefects($result->failures(), 'failure');
301
-    }
302
-
303
-    /**
304
-     * @param TestResult $result
305
-     */
306
-    protected function printWarnings(TestResult $result)
307
-    {
308
-        $this->printDefects($result->warnings(), 'warning');
309
-    }
310
-
311
-    /**
312
-     * @param TestResult $result
313
-     */
314
-    protected function printIncompletes(TestResult $result)
315
-    {
316
-        $this->printDefects($result->notImplemented(), 'incomplete test');
317
-    }
318
-
319
-    /**
320
-     * @param TestResult $result
321
-     */
322
-    protected function printRisky(TestResult $result)
323
-    {
324
-        $this->printDefects($result->risky(), 'risky test');
325
-    }
326
-
327
-    /**
328
-     * @param TestResult $result
329
-     */
330
-    protected function printSkipped(TestResult $result)
331
-    {
332
-        $this->printDefects($result->skipped(), 'skipped test');
333
-    }
334
-
335
-    protected function printHeader()
336
-    {
337
-        $this->write("\n\n" . PHP_Timer::resourceUsage() . "\n\n");
338
-    }
339
-
340
-    /**
341
-     * @param TestResult $result
342
-     */
343
-    protected function printFooter(TestResult $result)
344
-    {
345
-        if (\count($result) === 0) {
346
-            $this->writeWithColor(
347
-                'fg-black, bg-yellow',
348
-                'No tests executed!'
349
-            );
350
-
351
-            return;
352
-        }
353
-
354
-        if ($result->wasSuccessful() &&
355
-            $result->allHarmless() &&
356
-            $result->allCompletelyImplemented() &&
357
-            $result->noneSkipped()) {
358
-            $this->writeWithColor(
359
-                'fg-black, bg-green',
360
-                \sprintf(
361
-                    'OK (%d test%s, %d assertion%s)',
362
-                    \count($result),
363
-                    (\count($result) == 1) ? '' : 's',
364
-                    $this->numAssertions,
365
-                    ($this->numAssertions == 1) ? '' : 's'
366
-                )
367
-            );
368
-        } else {
369
-            if ($result->wasSuccessful()) {
370
-                $color = 'fg-black, bg-yellow';
371
-
372
-                if ($this->verbose || !$result->allHarmless()) {
373
-                    $this->write("\n");
374
-                }
375
-
376
-                $this->writeWithColor(
377
-                    $color,
378
-                    'OK, but incomplete, skipped, or risky tests!'
379
-                );
380
-            } else {
381
-                $this->write("\n");
382
-
383
-                if ($result->errorCount()) {
384
-                    $color = 'fg-white, bg-red';
385
-
386
-                    $this->writeWithColor(
387
-                        $color,
388
-                        'ERRORS!'
389
-                    );
390
-                } elseif ($result->failureCount()) {
391
-                    $color = 'fg-white, bg-red';
392
-
393
-                    $this->writeWithColor(
394
-                        $color,
395
-                        'FAILURES!'
396
-                    );
397
-                } elseif ($result->warningCount()) {
398
-                    $color = 'fg-black, bg-yellow';
399
-
400
-                    $this->writeWithColor(
401
-                        $color,
402
-                        'WARNINGS!'
403
-                    );
404
-                }
405
-            }
406
-
407
-            $this->writeCountString(\count($result), 'Tests', $color, true);
408
-            $this->writeCountString($this->numAssertions, 'Assertions', $color, true);
409
-            $this->writeCountString($result->errorCount(), 'Errors', $color);
410
-            $this->writeCountString($result->failureCount(), 'Failures', $color);
411
-            $this->writeCountString($result->warningCount(), 'Warnings', $color);
412
-            $this->writeCountString($result->skippedCount(), 'Skipped', $color);
413
-            $this->writeCountString($result->notImplementedCount(), 'Incomplete', $color);
414
-            $this->writeCountString($result->riskyCount(), 'Risky', $color);
415
-            $this->writeWithColor($color, '.', true);
416
-        }
417
-    }
418
-
419
-    public function printWaitPrompt()
420
-    {
421
-        $this->write("\n<RETURN> to continue\n");
422
-    }
423
-
424
-    /**
425
-     * An error occurred.
426
-     *
427
-     * @param Test       $test
428
-     * @param \Exception $e
429
-     * @param float      $time
430
-     */
431
-    public function addError(Test $test, \Exception $e, $time)
432
-    {
433
-        $this->writeProgressWithColor('fg-red, bold', 'E');
434
-        $this->lastTestFailed = true;
435
-    }
436
-
437
-    /**
438
-     * A failure occurred.
439
-     *
440
-     * @param Test                 $test
441
-     * @param AssertionFailedError $e
442
-     * @param float                $time
443
-     */
444
-    public function addFailure(Test $test, AssertionFailedError $e, $time)
445
-    {
446
-        $this->writeProgressWithColor('bg-red, fg-white', 'F');
447
-        $this->lastTestFailed = true;
448
-    }
449
-
450
-    /**
451
-     * A warning occurred.
452
-     *
453
-     * @param Test    $test
454
-     * @param Warning $e
455
-     * @param float   $time
456
-     */
457
-    public function addWarning(Test $test, Warning $e, $time)
458
-    {
459
-        $this->writeProgressWithColor('fg-yellow, bold', 'W');
460
-        $this->lastTestFailed = true;
461
-    }
462
-
463
-    /**
464
-     * Incomplete test.
465
-     *
466
-     * @param Test       $test
467
-     * @param \Exception $e
468
-     * @param float      $time
469
-     */
470
-    public function addIncompleteTest(Test $test, \Exception $e, $time)
471
-    {
472
-        $this->writeProgressWithColor('fg-yellow, bold', 'I');
473
-        $this->lastTestFailed = true;
474
-    }
475
-
476
-    /**
477
-     * Risky test.
478
-     *
479
-     * @param Test       $test
480
-     * @param \Exception $e
481
-     * @param float      $time
482
-     */
483
-    public function addRiskyTest(Test $test, \Exception $e, $time)
484
-    {
485
-        $this->writeProgressWithColor('fg-yellow, bold', 'R');
486
-        $this->lastTestFailed = true;
487
-    }
488
-
489
-    /**
490
-     * Skipped test.
491
-     *
492
-     * @param Test       $test
493
-     * @param \Exception $e
494
-     * @param float      $time
495
-     */
496
-    public function addSkippedTest(Test $test, \Exception $e, $time)
497
-    {
498
-        $this->writeProgressWithColor('fg-cyan, bold', 'S');
499
-        $this->lastTestFailed = true;
500
-    }
501
-
502
-    /**
503
-     * A testsuite started.
504
-     *
505
-     * @param TestSuite $suite
506
-     */
507
-    public function startTestSuite(TestSuite $suite)
508
-    {
509
-        if ($this->numTests == -1) {
510
-            $this->numTests      = \count($suite);
511
-            $this->numTestsWidth = \strlen((string) $this->numTests);
512
-            $this->maxColumn     = $this->numberOfColumns - \strlen('  /  (XXX%)') - (2 * $this->numTestsWidth);
513
-        }
514
-    }
515
-
516
-    /**
517
-     * A testsuite ended.
518
-     *
519
-     * @param TestSuite $suite
520
-     */
521
-    public function endTestSuite(TestSuite $suite)
522
-    {
523
-    }
524
-
525
-    /**
526
-     * A test started.
527
-     *
528
-     * @param Test $test
529
-     */
530
-    public function startTest(Test $test)
531
-    {
532
-        if ($this->debug) {
533
-            $this->write(
534
-                \sprintf(
535
-                    "\nStarting test '%s'.\n",
536
-                    \PHPUnit\Util\Test::describe($test)
537
-                )
538
-            );
539
-        }
540
-    }
541
-
542
-    /**
543
-     * A test ended.
544
-     *
545
-     * @param Test  $test
546
-     * @param float $time
547
-     */
548
-    public function endTest(Test $test, $time)
549
-    {
550
-        if (!$this->lastTestFailed) {
551
-            $this->writeProgress('.');
552
-        }
553
-
554
-        if ($test instanceof TestCase) {
555
-            $this->numAssertions += $test->getNumAssertions();
556
-        } elseif ($test instanceof PhptTestCase) {
557
-            $this->numAssertions++;
558
-        }
559
-
560
-        $this->lastTestFailed = false;
561
-
562
-        if ($test instanceof TestCase) {
563
-            if (!$test->hasExpectationOnOutput()) {
564
-                $this->write($test->getActualOutput());
565
-            }
566
-        }
567
-    }
568
-
569
-    /**
570
-     * @param string $progress
571
-     */
572
-    protected function writeProgress($progress)
573
-    {
574
-        $this->write($progress);
575
-        $this->column++;
576
-        $this->numTestsRun++;
577
-
578
-        if ($this->column == $this->maxColumn || $this->numTestsRun == $this->numTests) {
579
-            if ($this->numTestsRun == $this->numTests) {
580
-                $this->write(\str_repeat(' ', $this->maxColumn - $this->column));
581
-            }
582
-
583
-            $this->write(
584
-                \sprintf(
585
-                    ' %' . $this->numTestsWidth . 'd / %' .
586
-                    $this->numTestsWidth . 'd (%3s%%)',
587
-                    $this->numTestsRun,
588
-                    $this->numTests,
589
-                    \floor(($this->numTestsRun / $this->numTests) * 100)
590
-                )
591
-            );
592
-
593
-            if ($this->column == $this->maxColumn) {
594
-                $this->writeNewLine();
595
-            }
596
-        }
597
-    }
598
-
599
-    protected function writeNewLine()
600
-    {
601
-        $this->column = 0;
602
-        $this->write("\n");
603
-    }
604
-
605
-    /**
606
-     * Formats a buffer with a specified ANSI color sequence if colors are
607
-     * enabled.
608
-     *
609
-     * @param string $color
610
-     * @param string $buffer
611
-     *
612
-     * @return string
613
-     */
614
-    protected function formatWithColor($color, $buffer)
615
-    {
616
-        if (!$this->colors) {
617
-            return $buffer;
618
-        }
619
-
620
-        $codes   = \array_map('trim', \explode(',', $color));
621
-        $lines   = \explode("\n", $buffer);
622
-        $padding = \max(\array_map('strlen', $lines));
623
-        $styles  = [];
624
-
625
-        foreach ($codes as $code) {
626
-            $styles[] = self::$ansiCodes[$code];
627
-        }
628
-
629
-        $style = \sprintf("\x1b[%sm", \implode(';', $styles));
630
-
631
-        $styledLines = [];
632
-
633
-        foreach ($lines as $line) {
634
-            $styledLines[] = $style . \str_pad($line, $padding) . "\x1b[0m";
635
-        }
636
-
637
-        return \implode("\n", $styledLines);
638
-    }
639
-
640
-    /**
641
-     * Writes a buffer out with a color sequence if colors are enabled.
642
-     *
643
-     * @param string $color
644
-     * @param string $buffer
645
-     * @param bool   $lf
646
-     */
647
-    protected function writeWithColor($color, $buffer, $lf = true)
648
-    {
649
-        $this->write($this->formatWithColor($color, $buffer));
650
-
651
-        if ($lf) {
652
-            $this->write("\n");
653
-        }
654
-    }
655
-
656
-    /**
657
-     * Writes progress with a color sequence if colors are enabled.
658
-     *
659
-     * @param string $color
660
-     * @param string $buffer
661
-     */
662
-    protected function writeProgressWithColor($color, $buffer)
663
-    {
664
-        $buffer = $this->formatWithColor($color, $buffer);
665
-        $this->writeProgress($buffer);
666
-    }
667
-
668
-    /**
669
-     * @param int    $count
670
-     * @param string $name
671
-     * @param string $color
672
-     * @param bool   $always
673
-     */
674
-    private function writeCountString($count, $name, $color, $always = false)
675
-    {
676
-        static $first = true;
677
-
678
-        if ($always || $count > 0) {
679
-            $this->writeWithColor(
680
-                $color,
681
-                \sprintf(
682
-                    '%s%s: %d',
683
-                    !$first ? ', ' : '',
684
-                    $name,
685
-                    $count
686
-                ),
687
-                false
688
-            );
689
-
690
-            $first = false;
691
-        }
692
-    }
33
+	const EVENT_TEST_START      = 0;
34
+	const EVENT_TEST_END        = 1;
35
+	const EVENT_TESTSUITE_START = 2;
36
+	const EVENT_TESTSUITE_END   = 3;
37
+
38
+	const COLOR_NEVER   = 'never';
39
+	const COLOR_AUTO    = 'auto';
40
+	const COLOR_ALWAYS  = 'always';
41
+	const COLOR_DEFAULT = self::COLOR_NEVER;
42
+
43
+	/**
44
+	 * @var array
45
+	 */
46
+	private static $ansiCodes = [
47
+		'bold'       => 1,
48
+		'fg-black'   => 30,
49
+		'fg-red'     => 31,
50
+		'fg-green'   => 32,
51
+		'fg-yellow'  => 33,
52
+		'fg-blue'    => 34,
53
+		'fg-magenta' => 35,
54
+		'fg-cyan'    => 36,
55
+		'fg-white'   => 37,
56
+		'bg-black'   => 40,
57
+		'bg-red'     => 41,
58
+		'bg-green'   => 42,
59
+		'bg-yellow'  => 43,
60
+		'bg-blue'    => 44,
61
+		'bg-magenta' => 45,
62
+		'bg-cyan'    => 46,
63
+		'bg-white'   => 47
64
+	];
65
+
66
+	/**
67
+	 * @var int
68
+	 */
69
+	protected $column = 0;
70
+
71
+	/**
72
+	 * @var int
73
+	 */
74
+	protected $maxColumn;
75
+
76
+	/**
77
+	 * @var bool
78
+	 */
79
+	protected $lastTestFailed = false;
80
+
81
+	/**
82
+	 * @var int
83
+	 */
84
+	protected $numAssertions = 0;
85
+
86
+	/**
87
+	 * @var int
88
+	 */
89
+	protected $numTests = -1;
90
+
91
+	/**
92
+	 * @var int
93
+	 */
94
+	protected $numTestsRun = 0;
95
+
96
+	/**
97
+	 * @var int
98
+	 */
99
+	protected $numTestsWidth;
100
+
101
+	/**
102
+	 * @var bool
103
+	 */
104
+	protected $colors = false;
105
+
106
+	/**
107
+	 * @var bool
108
+	 */
109
+	protected $debug = false;
110
+
111
+	/**
112
+	 * @var bool
113
+	 */
114
+	protected $verbose = false;
115
+
116
+	/**
117
+	 * @var int
118
+	 */
119
+	private $numberOfColumns;
120
+
121
+	/**
122
+	 * @var bool
123
+	 */
124
+	private $reverse;
125
+
126
+	/**
127
+	 * @var bool
128
+	 */
129
+	private $defectListPrinted = false;
130
+
131
+	/**
132
+	 * Constructor.
133
+	 *
134
+	 * @param mixed      $out
135
+	 * @param bool       $verbose
136
+	 * @param string     $colors
137
+	 * @param bool       $debug
138
+	 * @param int|string $numberOfColumns
139
+	 * @param bool       $reverse
140
+	 *
141
+	 * @throws Exception
142
+	 */
143
+	public function __construct($out = null, $verbose = false, $colors = self::COLOR_DEFAULT, $debug = false, $numberOfColumns = 80, $reverse = false)
144
+	{
145
+		parent::__construct($out);
146
+
147
+		if (!\is_bool($verbose)) {
148
+			throw InvalidArgumentHelper::factory(2, 'boolean');
149
+		}
150
+
151
+		$availableColors = [self::COLOR_NEVER, self::COLOR_AUTO, self::COLOR_ALWAYS];
152
+
153
+		if (!\in_array($colors, $availableColors)) {
154
+			throw InvalidArgumentHelper::factory(
155
+				3,
156
+				\vsprintf('value from "%s", "%s" or "%s"', $availableColors)
157
+			);
158
+		}
159
+
160
+		if (!\is_bool($debug)) {
161
+			throw InvalidArgumentHelper::factory(4, 'boolean');
162
+		}
163
+
164
+		if (!\is_int($numberOfColumns) && $numberOfColumns !== 'max') {
165
+			throw InvalidArgumentHelper::factory(5, 'integer or "max"');
166
+		}
167
+
168
+		if (!\is_bool($reverse)) {
169
+			throw InvalidArgumentHelper::factory(6, 'boolean');
170
+		}
171
+
172
+		$console            = new Console;
173
+		$maxNumberOfColumns = $console->getNumberOfColumns();
174
+
175
+		if ($numberOfColumns === 'max' || ($numberOfColumns !== 80 && $numberOfColumns > $maxNumberOfColumns)) {
176
+			$numberOfColumns = $maxNumberOfColumns;
177
+		}
178
+
179
+		$this->numberOfColumns = $numberOfColumns;
180
+		$this->verbose         = $verbose;
181
+		$this->debug           = $debug;
182
+		$this->reverse         = $reverse;
183
+
184
+		if ($colors === self::COLOR_AUTO && $console->hasColorSupport()) {
185
+			$this->colors = true;
186
+		} else {
187
+			$this->colors = (self::COLOR_ALWAYS === $colors);
188
+		}
189
+	}
190
+
191
+	/**
192
+	 * @param TestResult $result
193
+	 */
194
+	public function printResult(TestResult $result)
195
+	{
196
+		$this->printHeader();
197
+		$this->printErrors($result);
198
+		$this->printWarnings($result);
199
+		$this->printFailures($result);
200
+		$this->printRisky($result);
201
+
202
+		if ($this->verbose) {
203
+			$this->printIncompletes($result);
204
+			$this->printSkipped($result);
205
+		}
206
+
207
+		$this->printFooter($result);
208
+	}
209
+
210
+	/**
211
+	 * @param array  $defects
212
+	 * @param string $type
213
+	 */
214
+	protected function printDefects(array $defects, $type)
215
+	{
216
+		$count = \count($defects);
217
+
218
+		if ($count == 0) {
219
+			return;
220
+		}
221
+
222
+		if ($this->defectListPrinted) {
223
+			$this->write("\n--\n\n");
224
+		}
225
+
226
+		$this->write(
227
+			\sprintf(
228
+				"There %s %d %s%s:\n",
229
+				($count == 1) ? 'was' : 'were',
230
+				$count,
231
+				$type,
232
+				($count == 1) ? '' : 's'
233
+			)
234
+		);
235
+
236
+		$i = 1;
237
+
238
+		if ($this->reverse) {
239
+			$defects = \array_reverse($defects);
240
+		}
241
+
242
+		foreach ($defects as $defect) {
243
+			$this->printDefect($defect, $i++);
244
+		}
245
+
246
+		$this->defectListPrinted = true;
247
+	}
248
+
249
+	/**
250
+	 * @param TestFailure $defect
251
+	 * @param int         $count
252
+	 */
253
+	protected function printDefect(TestFailure $defect, $count)
254
+	{
255
+		$this->printDefectHeader($defect, $count);
256
+		$this->printDefectTrace($defect);
257
+	}
258
+
259
+	/**
260
+	 * @param TestFailure $defect
261
+	 * @param int         $count
262
+	 */
263
+	protected function printDefectHeader(TestFailure $defect, $count)
264
+	{
265
+		$this->write(
266
+			\sprintf(
267
+				"\n%d) %s\n",
268
+				$count,
269
+				$defect->getTestName()
270
+			)
271
+		);
272
+	}
273
+
274
+	/**
275
+	 * @param TestFailure $defect
276
+	 */
277
+	protected function printDefectTrace(TestFailure $defect)
278
+	{
279
+		$e = $defect->thrownException();
280
+		$this->write((string) $e);
281
+
282
+		while ($e = $e->getPrevious()) {
283
+			$this->write("\nCaused by\n" . $e);
284
+		}
285
+	}
286
+
287
+	/**
288
+	 * @param TestResult $result
289
+	 */
290
+	protected function printErrors(TestResult $result)
291
+	{
292
+		$this->printDefects($result->errors(), 'error');
293
+	}
294
+
295
+	/**
296
+	 * @param TestResult $result
297
+	 */
298
+	protected function printFailures(TestResult $result)
299
+	{
300
+		$this->printDefects($result->failures(), 'failure');
301
+	}
302
+
303
+	/**
304
+	 * @param TestResult $result
305
+	 */
306
+	protected function printWarnings(TestResult $result)
307
+	{
308
+		$this->printDefects($result->warnings(), 'warning');
309
+	}
310
+
311
+	/**
312
+	 * @param TestResult $result
313
+	 */
314
+	protected function printIncompletes(TestResult $result)
315
+	{
316
+		$this->printDefects($result->notImplemented(), 'incomplete test');
317
+	}
318
+
319
+	/**
320
+	 * @param TestResult $result
321
+	 */
322
+	protected function printRisky(TestResult $result)
323
+	{
324
+		$this->printDefects($result->risky(), 'risky test');
325
+	}
326
+
327
+	/**
328
+	 * @param TestResult $result
329
+	 */
330
+	protected function printSkipped(TestResult $result)
331
+	{
332
+		$this->printDefects($result->skipped(), 'skipped test');
333
+	}
334
+
335
+	protected function printHeader()
336
+	{
337
+		$this->write("\n\n" . PHP_Timer::resourceUsage() . "\n\n");
338
+	}
339
+
340
+	/**
341
+	 * @param TestResult $result
342
+	 */
343
+	protected function printFooter(TestResult $result)
344
+	{
345
+		if (\count($result) === 0) {
346
+			$this->writeWithColor(
347
+				'fg-black, bg-yellow',
348
+				'No tests executed!'
349
+			);
350
+
351
+			return;
352
+		}
353
+
354
+		if ($result->wasSuccessful() &&
355
+			$result->allHarmless() &&
356
+			$result->allCompletelyImplemented() &&
357
+			$result->noneSkipped()) {
358
+			$this->writeWithColor(
359
+				'fg-black, bg-green',
360
+				\sprintf(
361
+					'OK (%d test%s, %d assertion%s)',
362
+					\count($result),
363
+					(\count($result) == 1) ? '' : 's',
364
+					$this->numAssertions,
365
+					($this->numAssertions == 1) ? '' : 's'
366
+				)
367
+			);
368
+		} else {
369
+			if ($result->wasSuccessful()) {
370
+				$color = 'fg-black, bg-yellow';
371
+
372
+				if ($this->verbose || !$result->allHarmless()) {
373
+					$this->write("\n");
374
+				}
375
+
376
+				$this->writeWithColor(
377
+					$color,
378
+					'OK, but incomplete, skipped, or risky tests!'
379
+				);
380
+			} else {
381
+				$this->write("\n");
382
+
383
+				if ($result->errorCount()) {
384
+					$color = 'fg-white, bg-red';
385
+
386
+					$this->writeWithColor(
387
+						$color,
388
+						'ERRORS!'
389
+					);
390
+				} elseif ($result->failureCount()) {
391
+					$color = 'fg-white, bg-red';
392
+
393
+					$this->writeWithColor(
394
+						$color,
395
+						'FAILURES!'
396
+					);
397
+				} elseif ($result->warningCount()) {
398
+					$color = 'fg-black, bg-yellow';
399
+
400
+					$this->writeWithColor(
401
+						$color,
402
+						'WARNINGS!'
403
+					);
404
+				}
405
+			}
406
+
407
+			$this->writeCountString(\count($result), 'Tests', $color, true);
408
+			$this->writeCountString($this->numAssertions, 'Assertions', $color, true);
409
+			$this->writeCountString($result->errorCount(), 'Errors', $color);
410
+			$this->writeCountString($result->failureCount(), 'Failures', $color);
411
+			$this->writeCountString($result->warningCount(), 'Warnings', $color);
412
+			$this->writeCountString($result->skippedCount(), 'Skipped', $color);
413
+			$this->writeCountString($result->notImplementedCount(), 'Incomplete', $color);
414
+			$this->writeCountString($result->riskyCount(), 'Risky', $color);
415
+			$this->writeWithColor($color, '.', true);
416
+		}
417
+	}
418
+
419
+	public function printWaitPrompt()
420
+	{
421
+		$this->write("\n<RETURN> to continue\n");
422
+	}
423
+
424
+	/**
425
+	 * An error occurred.
426
+	 *
427
+	 * @param Test       $test
428
+	 * @param \Exception $e
429
+	 * @param float      $time
430
+	 */
431
+	public function addError(Test $test, \Exception $e, $time)
432
+	{
433
+		$this->writeProgressWithColor('fg-red, bold', 'E');
434
+		$this->lastTestFailed = true;
435
+	}
436
+
437
+	/**
438
+	 * A failure occurred.
439
+	 *
440
+	 * @param Test                 $test
441
+	 * @param AssertionFailedError $e
442
+	 * @param float                $time
443
+	 */
444
+	public function addFailure(Test $test, AssertionFailedError $e, $time)
445
+	{
446
+		$this->writeProgressWithColor('bg-red, fg-white', 'F');
447
+		$this->lastTestFailed = true;
448
+	}
449
+
450
+	/**
451
+	 * A warning occurred.
452
+	 *
453
+	 * @param Test    $test
454
+	 * @param Warning $e
455
+	 * @param float   $time
456
+	 */
457
+	public function addWarning(Test $test, Warning $e, $time)
458
+	{
459
+		$this->writeProgressWithColor('fg-yellow, bold', 'W');
460
+		$this->lastTestFailed = true;
461
+	}
462
+
463
+	/**
464
+	 * Incomplete test.
465
+	 *
466
+	 * @param Test       $test
467
+	 * @param \Exception $e
468
+	 * @param float      $time
469
+	 */
470
+	public function addIncompleteTest(Test $test, \Exception $e, $time)
471
+	{
472
+		$this->writeProgressWithColor('fg-yellow, bold', 'I');
473
+		$this->lastTestFailed = true;
474
+	}
475
+
476
+	/**
477
+	 * Risky test.
478
+	 *
479
+	 * @param Test       $test
480
+	 * @param \Exception $e
481
+	 * @param float      $time
482
+	 */
483
+	public function addRiskyTest(Test $test, \Exception $e, $time)
484
+	{
485
+		$this->writeProgressWithColor('fg-yellow, bold', 'R');
486
+		$this->lastTestFailed = true;
487
+	}
488
+
489
+	/**
490
+	 * Skipped test.
491
+	 *
492
+	 * @param Test       $test
493
+	 * @param \Exception $e
494
+	 * @param float      $time
495
+	 */
496
+	public function addSkippedTest(Test $test, \Exception $e, $time)
497
+	{
498
+		$this->writeProgressWithColor('fg-cyan, bold', 'S');
499
+		$this->lastTestFailed = true;
500
+	}
501
+
502
+	/**
503
+	 * A testsuite started.
504
+	 *
505
+	 * @param TestSuite $suite
506
+	 */
507
+	public function startTestSuite(TestSuite $suite)
508
+	{
509
+		if ($this->numTests == -1) {
510
+			$this->numTests      = \count($suite);
511
+			$this->numTestsWidth = \strlen((string) $this->numTests);
512
+			$this->maxColumn     = $this->numberOfColumns - \strlen('  /  (XXX%)') - (2 * $this->numTestsWidth);
513
+		}
514
+	}
515
+
516
+	/**
517
+	 * A testsuite ended.
518
+	 *
519
+	 * @param TestSuite $suite
520
+	 */
521
+	public function endTestSuite(TestSuite $suite)
522
+	{
523
+	}
524
+
525
+	/**
526
+	 * A test started.
527
+	 *
528
+	 * @param Test $test
529
+	 */
530
+	public function startTest(Test $test)
531
+	{
532
+		if ($this->debug) {
533
+			$this->write(
534
+				\sprintf(
535
+					"\nStarting test '%s'.\n",
536
+					\PHPUnit\Util\Test::describe($test)
537
+				)
538
+			);
539
+		}
540
+	}
541
+
542
+	/**
543
+	 * A test ended.
544
+	 *
545
+	 * @param Test  $test
546
+	 * @param float $time
547
+	 */
548
+	public function endTest(Test $test, $time)
549
+	{
550
+		if (!$this->lastTestFailed) {
551
+			$this->writeProgress('.');
552
+		}
553
+
554
+		if ($test instanceof TestCase) {
555
+			$this->numAssertions += $test->getNumAssertions();
556
+		} elseif ($test instanceof PhptTestCase) {
557
+			$this->numAssertions++;
558
+		}
559
+
560
+		$this->lastTestFailed = false;
561
+
562
+		if ($test instanceof TestCase) {
563
+			if (!$test->hasExpectationOnOutput()) {
564
+				$this->write($test->getActualOutput());
565
+			}
566
+		}
567
+	}
568
+
569
+	/**
570
+	 * @param string $progress
571
+	 */
572
+	protected function writeProgress($progress)
573
+	{
574
+		$this->write($progress);
575
+		$this->column++;
576
+		$this->numTestsRun++;
577
+
578
+		if ($this->column == $this->maxColumn || $this->numTestsRun == $this->numTests) {
579
+			if ($this->numTestsRun == $this->numTests) {
580
+				$this->write(\str_repeat(' ', $this->maxColumn - $this->column));
581
+			}
582
+
583
+			$this->write(
584
+				\sprintf(
585
+					' %' . $this->numTestsWidth . 'd / %' .
586
+					$this->numTestsWidth . 'd (%3s%%)',
587
+					$this->numTestsRun,
588
+					$this->numTests,
589
+					\floor(($this->numTestsRun / $this->numTests) * 100)
590
+				)
591
+			);
592
+
593
+			if ($this->column == $this->maxColumn) {
594
+				$this->writeNewLine();
595
+			}
596
+		}
597
+	}
598
+
599
+	protected function writeNewLine()
600
+	{
601
+		$this->column = 0;
602
+		$this->write("\n");
603
+	}
604
+
605
+	/**
606
+	 * Formats a buffer with a specified ANSI color sequence if colors are
607
+	 * enabled.
608
+	 *
609
+	 * @param string $color
610
+	 * @param string $buffer
611
+	 *
612
+	 * @return string
613
+	 */
614
+	protected function formatWithColor($color, $buffer)
615
+	{
616
+		if (!$this->colors) {
617
+			return $buffer;
618
+		}
619
+
620
+		$codes   = \array_map('trim', \explode(',', $color));
621
+		$lines   = \explode("\n", $buffer);
622
+		$padding = \max(\array_map('strlen', $lines));
623
+		$styles  = [];
624
+
625
+		foreach ($codes as $code) {
626
+			$styles[] = self::$ansiCodes[$code];
627
+		}
628
+
629
+		$style = \sprintf("\x1b[%sm", \implode(';', $styles));
630
+
631
+		$styledLines = [];
632
+
633
+		foreach ($lines as $line) {
634
+			$styledLines[] = $style . \str_pad($line, $padding) . "\x1b[0m";
635
+		}
636
+
637
+		return \implode("\n", $styledLines);
638
+	}
639
+
640
+	/**
641
+	 * Writes a buffer out with a color sequence if colors are enabled.
642
+	 *
643
+	 * @param string $color
644
+	 * @param string $buffer
645
+	 * @param bool   $lf
646
+	 */
647
+	protected function writeWithColor($color, $buffer, $lf = true)
648
+	{
649
+		$this->write($this->formatWithColor($color, $buffer));
650
+
651
+		if ($lf) {
652
+			$this->write("\n");
653
+		}
654
+	}
655
+
656
+	/**
657
+	 * Writes progress with a color sequence if colors are enabled.
658
+	 *
659
+	 * @param string $color
660
+	 * @param string $buffer
661
+	 */
662
+	protected function writeProgressWithColor($color, $buffer)
663
+	{
664
+		$buffer = $this->formatWithColor($color, $buffer);
665
+		$this->writeProgress($buffer);
666
+	}
667
+
668
+	/**
669
+	 * @param int    $count
670
+	 * @param string $name
671
+	 * @param string $color
672
+	 * @param bool   $always
673
+	 */
674
+	private function writeCountString($count, $name, $color, $always = false)
675
+	{
676
+		static $first = true;
677
+
678
+		if ($always || $count > 0) {
679
+			$this->writeWithColor(
680
+				$color,
681
+				\sprintf(
682
+					'%s%s: %d',
683
+					!$first ? ', ' : '',
684
+					$name,
685
+					$count
686
+				),
687
+				false
688
+			);
689
+
690
+			$first = false;
691
+		}
692
+	}
693 693
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
         $this->write((string) $e);
281 281
 
282 282
         while ($e = $e->getPrevious()) {
283
-            $this->write("\nCaused by\n" . $e);
283
+            $this->write("\nCaused by\n".$e);
284 284
         }
285 285
     }
286 286
 
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 
335 335
     protected function printHeader()
336 336
     {
337
-        $this->write("\n\n" . PHP_Timer::resourceUsage() . "\n\n");
337
+        $this->write("\n\n".PHP_Timer::resourceUsage()."\n\n");
338 338
     }
339 339
 
340 340
     /**
@@ -582,8 +582,8 @@  discard block
 block discarded – undo
582 582
 
583 583
             $this->write(
584 584
                 \sprintf(
585
-                    ' %' . $this->numTestsWidth . 'd / %' .
586
-                    $this->numTestsWidth . 'd (%3s%%)',
585
+                    ' %'.$this->numTestsWidth.'d / %'.
586
+                    $this->numTestsWidth.'d (%3s%%)',
587 587
                     $this->numTestsRun,
588 588
                     $this->numTests,
589 589
                     \floor(($this->numTestsRun / $this->numTests) * 100)
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
         $styledLines = [];
632 632
 
633 633
         foreach ($lines as $line) {
634
-            $styledLines[] = $style . \str_pad($line, $padding) . "\x1b[0m";
634
+            $styledLines[] = $style.\str_pad($line, $padding)."\x1b[0m";
635 635
         }
636 636
 
637 637
         return \implode("\n", $styledLines);
Please login to merge, or discard this patch.