Skip to content

Commit

Permalink
Fix: Run 'php-cs-fixer fix'
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz authored and sebastianbergmann committed Aug 27, 2021
1 parent 137e72f commit a8f8f8f
Show file tree
Hide file tree
Showing 24 changed files with 92 additions and 46 deletions.
3 changes: 2 additions & 1 deletion src/Framework/MockObject/Builder/InvocationMocker.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ public function method($constraint): self
}

$configurableMethodNames = array_map(
static function (ConfigurableMethod $configurable) {
static function (ConfigurableMethod $configurable)
{
return strtolower($configurable->getName());
},
$this->configurableMethods
Expand Down
3 changes: 2 additions & 1 deletion src/Framework/MockObject/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ public function getMock($type, $methods = [], array $arguments = [], string $moc
if (is_array($type)) {
$type = array_unique(
array_map(
static function ($type) {
static function ($type)
{
if ($type === 'Traversable' ||
$type === '\\Traversable' ||
$type === '\\Iterator') {
Expand Down
6 changes: 4 additions & 2 deletions src/Framework/MockObject/Invocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,15 @@ public function generateReturnValue()

case 'callable':
case 'closure':
return static function (): void {
return static function (): void
{
};

case 'traversable':
case 'generator':
case 'iterable':
$generator = static function () {
$generator = static function ()
{
yield from [];
};

Expand Down
3 changes: 2 additions & 1 deletion src/Framework/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -1708,7 +1708,8 @@ protected function createPartialMock($originalClassName, array $methods): MockOb

$mockedMethodsThatDontExist = array_filter(
$methods,
static function (string $method) use ($reflection) {
static function (string $method) use ($reflection)
{
return !$reflection->hasMethod($method);
}
);
Expand Down
18 changes: 12 additions & 6 deletions src/Runner/TestSuiteSorter.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ private function suiteOnlyContainsTests(TestSuite $suite): bool
{
return array_reduce(
$suite->tests(),
static function ($carry, $test) {
static function ($carry, $test)
{
return $carry && ($test instanceof TestCase || $test instanceof DataProviderTestSuite);
},
true
Expand All @@ -272,7 +273,8 @@ private function sortDefectsFirst(array $tests): array
/**
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
function ($left, $right) {
function ($left, $right)
{
return $this->cmpDefectPriorityAndTime($left, $right);
}
);
Expand All @@ -287,7 +289,8 @@ private function sortByDuration(array $tests): array
/**
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
function ($left, $right) {
function ($left, $right)
{
return $this->cmpDuration($left, $right);
}
);
Expand All @@ -302,7 +305,8 @@ private function sortBySize(array $tests): array
/**
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
function ($left, $right) {
function ($left, $right)
{
return $this->cmpSize($left, $right);
}
);
Expand Down Expand Up @@ -386,7 +390,8 @@ private function resolveDependencies(array $tests): array
/**
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
static function ($test) {
static function ($test)
{
return self::getTestSorterUID($test);
},
$tests
Expand Down Expand Up @@ -417,7 +422,8 @@ private function getNormalizedDependencyNames($test): array
}

$names = array_map(
static function ($name) use ($testClass) {
static function ($name) use ($testClass)
{
return strpos($name, '::') === false ? $testClass . '::' . $name : $name;
},
$test->getDependencies()
Expand Down
3 changes: 2 additions & 1 deletion src/TextUI/Help.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ private function writeWithColor(): void
$arg = Color::colorize('fg-green', str_pad($option['arg'], $this->maxArgLength));
$arg = preg_replace_callback(
'/(<[^>]+>)/',
static function ($matches) {
static function ($matches)
{
return Color::colorize('fg-cyan', $matches[0]);
},
$arg
Expand Down
3 changes: 2 additions & 1 deletion src/Util/Annotation/DocBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,8 @@ private static function extractAnnotationsFromReflector(Reflector $reflector): a
$annotations = array_merge(
$annotations,
...array_map(
static function (ReflectionClass $trait): array {
static function (ReflectionClass $trait): array
{
return self::parseDocBlock((string) $trait->getDocComment());
},
array_values($reflector->getTraits())
Expand Down
6 changes: 4 additions & 2 deletions src/Util/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ public static function colorizePath(string $path, ?string $prevPath = null, bool
$last = count($path) - 1;
$path[$last] = preg_replace_callback(
'/([\-_\.]+|phpt$)/',
static function ($matches) {
static function ($matches)
{
return self::dim($matches[0]);
},
$path[$last]
Expand All @@ -139,7 +140,8 @@ public static function visualizeWhitespace(string $buffer, bool $visualizeEOL =
{
$replaceMap = $visualizeEOL ? self::WHITESPACE_EOL_MAP : self::WHITESPACE_MAP;

return preg_replace_callback('/\s+/', static function ($matches) use ($replaceMap) {
return preg_replace_callback('/\s+/', static function ($matches) use ($replaceMap)
{
return self::dim(strtr($matches[0], $replaceMap));
}, $buffer);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Util/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ final class ErrorHandler
public static function invokeIgnoringWarnings(callable $callable)
{
set_error_handler(
static function ($errorNumber, $errorString) {
static function ($errorNumber, $errorString)
{
if ($errorNumber === E_WARNING) {
return;
}
Expand Down
3 changes: 2 additions & 1 deletion src/Util/PHP/AbstractPhpProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ private function processChildResult(Test $test, TestResult $result, string $stdo
/**
* @throws ErrorException
*/
static function ($errno, $errstr, $errfile, $errline): void {
static function ($errno, $errstr, $errfile, $errline): void
{
throw new ErrorException($errstr, $errno, $errno, $errfile, $errline);
}
);
Expand Down
3 changes: 2 additions & 1 deletion src/Util/RegularExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ final class RegularExpression
public static function safeMatch(string $pattern, string $subject)
{
return ErrorHandler::invokeIgnoringWarnings(
static function () use ($pattern, $subject) {
static function () use ($pattern, $subject)
{
return preg_match($pattern, $subject);
}
);
Expand Down
3 changes: 2 additions & 1 deletion src/Util/TestDox/CliTestDoxPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ protected function formatTestResultMessage(Throwable $t, array $result, ?string

if ($this->colors) {
$color = self::STATUS_STYLES[$result['status']]['color'] ?? '';
$prefix = array_map(static function ($p) use ($color) {
$prefix = array_map(static function ($p) use ($color)
{
return Color::colorize($color, $p);
}, self::PREFIX_DECORATED);
}
Expand Down
6 changes: 4 additions & 2 deletions src/Util/TestDox/NamePrettifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ public function prettifyTestCase(TestCase $test): string
$annotations = $test->getAnnotations();
$annotationWithPlaceholders = false;

$callback = static function (string $variable): string {
$callback = static function (string $variable): string
{
return sprintf('/%s(?=\b)/', preg_quote($variable, '/'));
};

Expand Down Expand Up @@ -314,7 +315,8 @@ private function mapTestMethodParameterNamesToProvidedDataValues(TestCase $test)
}

if ($this->useColor) {
$providedData = array_map(static function ($value) {
$providedData = array_map(static function ($value)
{
return Color::colorize('fg-cyan', Color::visualizeWhitespace((string) $value, true));
}, $providedData);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Util/TestDox/TestDoxPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@ protected function prefixLines(string $prefix, string $message): string
return implode(
PHP_EOL,
array_map(
static function (string $text) use ($prefix) {
static function (string $text) use ($prefix)
{
return ' ' . $prefix . ($text ? ' ' . $text : '');
},
preg_split('/\r\n|\r|\n/', $message)
Expand Down
3 changes: 2 additions & 1 deletion src/Util/TestDox/XmlResultPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ public function endTest(Test $test, float $time): void

$groups = array_filter(
$test->getGroups(),
static function ($group) {
static function ($group)
{
return !($group === 'small' || $group === 'medium' || $group === 'large');
}
);
Expand Down
3 changes: 2 additions & 1 deletion src/Util/XdebugFilterScriptGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public function generate(array $filterData): string
$items = $this->getWhitelistItems($filterData);

$files = array_map(
static function ($item) {
static function ($item)
{
return sprintf(
" '%s'",
$item
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/Framework/Assert/FunctionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public function provideStaticAssertionMethodNames(): array

return array_reduce(
$matches[1],
static function (array $functionNames, string $functionName) {
static function (array $functionNames, string $functionName)
{
$functionNames[$functionName] = [$functionName];

return $functionNames;
Expand Down
9 changes: 6 additions & 3 deletions tests/unit/Framework/AssertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,8 @@ public function testAssertThatCallback(): void
{
$this->assertThat(
null,
$this->callback(static function ($other) {
$this->callback(static function ($other)
{
return true;
})
);
Expand Down Expand Up @@ -2041,7 +2042,8 @@ public function testScalarTypeCanBeAsserted(): void

public function testCallableTypeCanBeAsserted(): void
{
$this->assertIsCallable(static function (): void {
$this->assertIsCallable(static function (): void
{
});

try {
Expand Down Expand Up @@ -2188,7 +2190,8 @@ public function testNotCallableTypeCanBeAsserted(): void
$this->assertIsNotCallable(null);

try {
$this->assertIsNotCallable(static function (): void {
$this->assertIsNotCallable(static function (): void
{
});
} catch (AssertionFailedError $e) {
return;
Expand Down
9 changes: 6 additions & 3 deletions tests/unit/Framework/Constraint/CallbackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ public function callbackReturningTrue()

public function testConstraintCallback(): void
{
$closureReflect = static function ($parameter) {
$closureReflect = static function ($parameter)
{
return $parameter;
};

$closureWithoutParameter = static function () {
$closureWithoutParameter = static function ()
{
return true;
};

Expand All @@ -56,7 +58,8 @@ public function testConstraintCallback(): void

public function testConstraintCallbackFailure(): void
{
$constraint = new Callback(static function () {
$constraint = new Callback(static function ()
{
return false;
});

Expand Down
9 changes: 6 additions & 3 deletions tests/unit/Framework/Constraint/LogicalAndTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public function testCountReturnsCountOfComposedConstraints(): void
8,
];

$constraints = array_map(static function (int $count) {
$constraints = array_map(static function (int $count)
{
return CountConstraint::fromCount($count);
}, $counts);

Expand All @@ -76,7 +77,8 @@ public function testToStringReturnsImplodedStringRepresentationOfComposedConstra
'is rich in unsaturated fats',
];

$constraints = array_map(static function (string $name) {
$constraints = array_map(static function (string $name)
{
return NamedConstraint::fromName($name);
}, $names);

Expand Down Expand Up @@ -240,7 +242,8 @@ private function stringify(array $constraints): string
{
return implode(
' and ',
array_map(static function (Constraint $constraint) {
array_map(static function (Constraint $constraint)
{
return $constraint->toString();
}, $constraints)
);
Expand Down
9 changes: 6 additions & 3 deletions tests/unit/Framework/Constraint/LogicalOrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public function testCountReturnsCountOfComposedConstraints(): void
8,
];

$constraints = array_map(static function (int $count) {
$constraints = array_map(static function (int $count)
{
return CountConstraint::fromCount($count);
}, $counts);

Expand All @@ -68,7 +69,8 @@ public function testToStringReturnsImplodedStringRepresentationOfComposedConstra
'is rich in unsaturated fats',
];

$constraints = array_map(static function (string $name) {
$constraints = array_map(static function (string $name)
{
return NamedConstraint::fromName($name);
}, $names);

Expand Down Expand Up @@ -234,7 +236,8 @@ private function stringify(array $constraints): string
{
return implode(
' or ',
array_map(static function (Constraint $constraint) {
array_map(static function (Constraint $constraint)
{
return $constraint->toString();
}, $constraints)
);
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/Framework/Constraint/LogicalXorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public function testFromConstraintsReturnsConstraint(): void
$other = 'Foo';
$count = 5;

$constraints = array_map(function () use ($other) {
$constraints = array_map(function () use ($other)
{
static $count = 0;

$constraint = $this->getMockBuilder(Constraint::class)->getMock();
Expand Down

0 comments on commit a8f8f8f

Please sign in to comment.