Skip to content

Commit dfffc32

Browse files
committed
cs whitespace
1 parent 89cae50 commit dfffc32

23 files changed

+106
-7
lines changed

src/CodeCoverage/Generators/AbstractGenerator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,15 @@ public function render(string $file = null): void
8484
$this->renderSelf();
8585
} catch (\Throwable $e) {
8686
}
87+
8788
ob_end_flush();
8889
fclose($handle);
8990

9091
if (isset($e)) {
9192
if ($file) {
9293
unlink($file);
9394
}
95+
9496
throw $e;
9597
}
9698
}

src/CodeCoverage/Generators/CloverXMLGenerator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public function __construct(string $file, array $sources = [])
3838
if (!extension_loaded('dom') || !extension_loaded('tokenizer')) {
3939
throw new \LogicException('CloverXML generator requires DOM and Tokenizer extensions to be loaded.');
4040
}
41+
4142
parent::__construct($file, $sources);
4243
}
4344

@@ -121,6 +122,7 @@ protected function renderSelf(): void
121122
self::setMetricAttributes($elClassMetrics, $classMetrics);
122123
self::appendMetrics($fileMetrics, $classMetrics);
123124
}
125+
124126
self::setMetricAttributes($elFileMetrics, $fileMetrics);
125127

126128

src/CodeCoverage/Generators/HtmlGenerator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,12 @@ private function parse(): void
8585
if ($flag >= self::CODE_UNTESTED) {
8686
$total++;
8787
}
88+
8889
if ($flag >= self::CODE_TESTED) {
8990
$covered++;
9091
}
9192
}
93+
9294
$coverage = round($covered * 100 / $total);
9395
$this->totalSum += $total;
9496
$this->coveredSum += $covered;

src/CodeCoverage/PhpParser.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public function parse(string $code): \stdClass
9999
'methods' => [],
100100
];
101101
}
102+
102103
break;
103104

104105
case T_PUBLIC:
@@ -128,8 +129,10 @@ public function parse(string $code): \stdClass
128129
'end' => null,
129130
];
130131
}
132+
131133
$functionLevel = $level + 1;
132134
}
135+
133136
unset($visibility, $isAbstract);
134137
break;
135138

@@ -148,6 +151,7 @@ public function parse(string $code): \stdClass
148151
$class->end = $line;
149152
unset($class);
150153
}
154+
151155
$level--;
152156
break;
153157

@@ -177,8 +181,10 @@ private static function fetch(array &$tokens, $take): ?string
177181
} elseif (!in_array($token, [T_DOC_COMMENT, T_WHITESPACE, T_COMMENT], true)) {
178182
break;
179183
}
184+
180185
next($tokens);
181186
}
187+
182188
return $res;
183189
}
184190
}

src/Framework/Assert.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public static function notEqual($expected, $actual, string $description = null):
9898
$res = self::isEqual($expected, $actual);
9999
} catch (AssertException $e) {
100100
}
101+
101102
if (empty($e) && $res) {
102103
self::fail(self::describe('%1 should not be equal to %2', $description), $actual, $expected);
103104
}
@@ -308,14 +309,12 @@ public static function type($type, $value, string $description = null): void
308309
if (!is_array($value) || ($value && array_keys($value) !== range(0, count($value) - 1))) {
309310
self::fail(self::describe("%1 should be $type", $description), $value);
310311
}
311-
312312
} elseif (in_array($type, ['array', 'bool', 'callable', 'float',
313313
'int', 'integer', 'null', 'object', 'resource', 'scalar', 'string', ], true)
314314
) {
315315
if (!("is_$type")($value)) {
316316
self::fail(self::describe(gettype($value) . " should be $type", $description));
317317
}
318-
319318
} elseif (!$value instanceof $type) {
320319
$actual = is_object($value) ? get_class($value) : gettype($value);
321320
$type = is_object($type) ? get_class($type) : $type;
@@ -339,6 +338,7 @@ public static function exception(
339338
$function();
340339
} catch (\Throwable $e) {
341340
}
341+
342342
if ($e === null) {
343343
self::fail("$class was expected, but none was thrown");
344344

@@ -351,6 +351,7 @@ public static function exception(
351351
} elseif ($code !== null && $e->getCode() !== $code) {
352352
self::fail("$class with a code %2 was expected but got %1", $e->getCode(), $code);
353353
}
354+
354355
return $e;
355356
}
356357

@@ -421,6 +422,7 @@ public static function error(callable $function, $expectedType, string $expected
421422
if ($expected) {
422423
self::fail('Error was expected, but was not generated');
423424
}
425+
424426
return null;
425427
}
426428

@@ -433,6 +435,7 @@ public static function noError(callable $function): void
433435
if (($count = func_num_args()) > 1) {
434436
throw new \Exception(__METHOD__ . "() expects 1 parameter, $count given.");
435437
}
438+
436439
self::error($function, []);
437440
}
438441

@@ -465,6 +468,7 @@ public static function match(string $pattern, $actual, string $description = nul
465468
if (self::$expandPatterns) {
466469
[$pattern, $actual] = self::expandMatchingPatterns($pattern, $actual);
467470
}
471+
468472
self::fail(self::describe('%1 should match %2', $description), $actual, $pattern);
469473
}
470474
}
@@ -487,6 +491,7 @@ public static function matchFile(string $file, $actual, string $description = nu
487491
if (self::$expandPatterns) {
488492
[$pattern, $actual] = self::expandMatchingPatterns($pattern, $actual);
489493
}
494+
490495
self::fail(self::describe('%1 should match %2', $description), $actual, $pattern, null, basename($file));
491496
}
492497
}
@@ -566,6 +571,7 @@ public static function isMatching(string $pattern, $actual, bool $strict = false
566571
if ($res === false || preg_last_error()) {
567572
throw new \Exception('Error while executing regular expression. (PREG Error Code ' . preg_last_error() . ')');
568573
}
574+
569575
return (bool) $res;
570576
}
571577

@@ -655,6 +661,7 @@ private static function isEqual($expected, $actual, int $level = 0, $objects = n
655661
} elseif ($expected === $actual) {
656662
return true;
657663
}
664+
658665
$objects[$expected] = $actual;
659666
$objects[$actual] = $expected;
660667
$expected = (array) $expected;
@@ -672,8 +679,10 @@ private static function isEqual($expected, $actual, int $level = 0, $objects = n
672679
if (!self::isEqual($value, current($actual), $level + 1, $objects)) {
673680
return false;
674681
}
682+
675683
next($actual);
676684
}
685+
677686
return true;
678687

679688
default:

src/Framework/DataProvider.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public static function load(string $file, string $query = ''): array
3535
} elseif (!is_array($data)) {
3636
throw new \Exception("Data provider '$file' did not return array or Traversable.");
3737
}
38-
3938
} else {
4039
$data = @parse_ini_file($file, true); // @ is escalated to exception
4140
if ($data === false) {
@@ -68,6 +67,7 @@ public static function testQuery(string $input, string $query): bool
6867
return false;
6968
}
7069
}
70+
7171
return true;
7272
}
7373

@@ -93,6 +93,7 @@ private static function compare($l, string $operator, $r): bool
9393
case '<>':
9494
return $l != $r;
9595
}
96+
9697
throw new \InvalidArgumentException("Unknown operator $operator.");
9798
}
9899

@@ -105,6 +106,7 @@ public static function parseAnnotation(string $annotation, string $file): array
105106
if (!preg_match('#^(\??)\s*([^,\s]+)\s*,?\s*(\S.*)?()#', $annotation, $m)) {
106107
throw new \Exception("Invalid @dataProvider value '$annotation'.");
107108
}
109+
108110
return [dirname($file) . DIRECTORY_SEPARATOR . $m[2], $m[3], (bool) $m[1]];
109111
}
110112
}

src/Framework/DomQuery.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public static function fromHtml(string $html): self
4141
trigger_error(__METHOD__ . ": $error->message on line $error->line.", E_USER_WARNING);
4242
}
4343
}
44+
4445
return simplexml_import_dom($dom, self::class);
4546
}
4647

@@ -107,6 +108,7 @@ public static function css2xpath(string $css): string
107108
$xpath .= "[$attr]";
108109
continue;
109110
}
111+
110112
$val = trim($m[5], '"\'');
111113
if ($m[4] === '') {
112114
$xpath .= "[$attr='$val']";
@@ -131,6 +133,7 @@ public static function css2xpath(string $css): string
131133
$xpath .= '//*';
132134
}
133135
}
136+
134137
return $xpath;
135138
}
136139
}

src/Framework/Dumper.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public static function toLine($var): string
5151
} elseif (strlen($var) > self::$maxLength) {
5252
$var = substr($var, 0, self::$maxLength) . '...';
5353
}
54+
5455
return self::encodeStringLine($var);
5556

5657
} elseif (is_array($var)) {
@@ -62,10 +63,12 @@ public static function toLine($var): string
6263
$out .= '...';
6364
break;
6465
}
66+
6567
$out .= ($k === $counter ? '' : self::toLine($k) . ' => ')
6668
. (is_array($v) && $v ? '[...]' : self::toLine($v));
6769
$counter = is_int($k) ? max($k + 1, $counter) : $counter;
6870
}
71+
6972
return "[$out]";
7073

7174
} elseif ($var instanceof \Throwable) {
@@ -145,6 +148,7 @@ private static function _toPhp(&$var, array &$list = [], int $level = 0, int &$l
145148
if ($marker === null) {
146149
$marker = uniqid("\x00", true);
147150
}
151+
148152
if (empty($var)) {
149153
$out = '';
150154

@@ -167,12 +171,14 @@ private static function _toPhp(&$var, array &$list = [], int $level = 0, int &$l
167171
$line++;
168172
}
169173
}
174+
170175
unset($var[$marker]);
171176
if (strpos($outShort, "\n") === false && strlen($outShort) < self::$maxLength) {
172177
$line = $oldLine;
173178
$out = $outShort;
174179
}
175180
}
181+
176182
return '[' . $out . ']';
177183

178184
} elseif ($var instanceof \Closure) {
@@ -183,6 +189,7 @@ private static function _toPhp(&$var, array &$list = [], int $level = 0, int &$l
183189
if (($rc = new \ReflectionObject($var))->isAnonymous()) {
184190
return "/* Anonymous class defined in file {$rc->getFileName()} on line {$rc->getStartLine()} */";
185191
}
192+
186193
$arr = (array) $var;
187194
$space = str_repeat("\t", $level);
188195
$class = get_class($var);
@@ -205,11 +212,14 @@ private static function _toPhp(&$var, array &$list = [], int $level = 0, int &$l
205212
if (isset($k[0]) && $k[0] === "\x00") {
206213
$k = substr($k, strrpos($k, "\x00") + 1);
207214
}
215+
208216
$out .= "$space\t" . self::_toPhp($k, $list, $level + 1, $line) . ' => ' . self::_toPhp($v, $list, $level + 1, $line) . ",\n";
209217
$line++;
210218
}
219+
211220
$out .= $space;
212221
}
222+
213223
$hash = self::hash($var);
214224
return $class === 'stdClass'
215225
? "(object) /* $hash */ [$out]"
@@ -340,6 +350,7 @@ public static function dumpException(\Throwable $e): string
340350
? "$m[1]$m[2]\n" . str_repeat(' ', $delta - 3) . "...$m[3]$m[4]"
341351
: "$m[1]$m[2]$m[3]\n" . str_repeat(' ', strlen($m[1]) - 4) . "... $m[4]";
342352
}
353+
343354
$message = strtr($message, [
344355
'%1' => self::color('yellow') . self::toLine($actual) . self::color('white'),
345356
'%2' => self::color('yellow') . self::toLine($expected) . self::color('white'),
@@ -357,6 +368,7 @@ public static function dumpException(\Throwable $e): string
357368
if ($e instanceof AssertException && $item['file'] === __DIR__ . DIRECTORY_SEPARATOR . 'Assert.php') {
358369
continue;
359370
}
371+
360372
$line = $item['class'] === Assert::class && method_exists($item['class'], $item['function'])
361373
&& strpos($tmp = file($item['file'])[$item['line'] - 1], "::$item[function](") ? $tmp : null;
362374

@@ -382,6 +394,7 @@ public static function dumpException(\Throwable $e): string
382394
if ($e->getPrevious()) {
383395
$s .= "\n(previous) " . static::dumpException($e->getPrevious());
384396
}
397+
385398
return $s;
386399
}
387400

@@ -395,6 +408,7 @@ public static function saveOutput(string $testFile, $content, string $suffix = '
395408
if (!preg_match('#/|\w:#A', self::$dumpDir)) {
396409
$path = dirname($testFile) . DIRECTORY_SEPARATOR . $path;
397410
}
411+
398412
@mkdir(dirname($path)); // @ - directory may already exist
399413
file_put_contents($path, is_string($content) ? $content : (self::toPhp($content) . "\n"));
400414
return $path;

src/Framework/Environment.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ public static function setupErrors(): void
113113
) {
114114
self::handleException(new \ErrorException($message, 0, $severity, $file, $line));
115115
}
116+
116117
return false;
117118
});
118119

@@ -202,6 +203,7 @@ public static function bypassFinals(): void
202203
: $token;
203204
}
204205
}
206+
205207
return $code;
206208
});
207209
}
@@ -218,13 +220,15 @@ public static function loadData(): array
218220
if (!array_key_exists($key, $data)) {
219221
throw new \Exception("Missing dataset '$key' from data provider '$file'.");
220222
}
223+
221224
return $data[$key];
222225
}
223226

224227
$annotations = self::getTestAnnotations();
225228
if (!isset($annotations['dataprovider'])) {
226229
throw new \Exception('Missing annotation @dataProvider.');
227230
}
231+
228232
$provider = (array) $annotations['dataprovider'];
229233
[$file, $query] = DataProvider::parseAnnotation($provider[0], $annotations['file']);
230234

src/Framework/Expect.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public function __call(string $method, array $args): self
7373
$this->constraints[] = (object) ['method' => lcfirst($m[1]), 'args' => $args];
7474
return $this;
7575
}
76+
7677
throw new \Error('Call to undefined method ' . self::class . '::' . $method . '()');
7778
}
7879

@@ -119,6 +120,7 @@ public function dump(): string
119120
$res[] = is_string($cstr) ? $cstr : 'user-expectation';
120121
}
121122
}
123+
122124
return implode(',', $res);
123125
}
124126
}

src/Framework/FileMock.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ public function stream_seek(int $offset, int $whence): bool
140140
} elseif ($whence === SEEK_END) {
141141
$offset += strlen($this->content);
142142
}
143+
143144
if ($offset >= 0) {
144145
$this->readingPos = $offset;
145146
$this->writingPos = $this->appendMode ? $this->writingPos : $offset;
@@ -194,6 +195,7 @@ public function stream_metadata(string $path, int $option, $value): bool
194195
case STREAM_META_TOUCH:
195196
return true;
196197
}
198+
197199
return false;
198200
}
199201

0 commit comments

Comments
 (0)