Skip to content

Commit 72e5b35

Browse files
Use arrow functions
1 parent b61f014 commit 72e5b35

28 files changed

+144
-374
lines changed

src/Framework/Constraint/Operator/BinaryOperator.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ abstract class BinaryOperator extends Operator
2525
protected function __construct(mixed ...$constraints)
2626
{
2727
$this->constraints = array_map(
28-
function ($constraint): Constraint
29-
{
30-
return $this->checkConstraint($constraint);
31-
},
28+
fn ($constraint): Constraint => $this->checkConstraint($constraint),
3229
$constraints
3330
);
3431
}

src/Framework/Constraint/Operator/LogicalNot.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ public static function negate(string $string): string
5151

5252
preg_match('/(\'[\w\W]*\')([\w\W]*)("[\w\W]*")/i', $string, $matches);
5353

54-
$positives = array_map(static function (string $s)
55-
{
56-
return '/\\b' . preg_quote($s, '/') . '/';
57-
}, $positives);
54+
$positives = array_map(
55+
static fn (string $s) => '/\\b' . preg_quote($s, '/') . '/',
56+
$positives
57+
);
5858

5959
if (count($matches) > 0) {
6060
$nonInput = $matches[2];

src/Framework/Constraint/Operator/LogicalXor.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,7 @@ public function matches(mixed $other): bool
5959

6060
return array_reduce(
6161
$constraints,
62-
static function (bool $matches, Constraint $constraint) use ($other): bool
63-
{
64-
return $matches xor $constraint->evaluate($other, '', true);
65-
},
62+
static fn (bool $matches, Constraint $constraint): bool => $matches xor $constraint->evaluate($other, '', true),
6663
$initial->evaluate($other, '', true)
6764
);
6865
}

src/Framework/ExecutionOrderDependency.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,7 @@ public static function filterInvalid(array $dependencies): array
6969
return array_values(
7070
array_filter(
7171
$dependencies,
72-
static function (self $d)
73-
{
74-
return $d->isValid();
75-
}
72+
static fn (self $d) => $d->isValid()
7673
)
7774
);
7875
}
@@ -86,10 +83,7 @@ static function (self $d)
8683
public static function mergeUnique(array $existing, array $additional): array
8784
{
8885
$existingTargets = array_map(
89-
static function ($dependency)
90-
{
91-
return $dependency->getTarget();
92-
},
86+
static fn ($dependency) => $dependency->getTarget(),
9387
$existing
9488
);
9589

@@ -123,10 +117,7 @@ public static function diff(array $left, array $right): array
123117

124118
$diff = [];
125119
$rightTargets = array_map(
126-
static function ($dependency)
127-
{
128-
return $dependency->getTarget();
129-
},
120+
static fn ($dependency) => $dependency->getTarget(),
130121
$right
131122
);
132123

src/Framework/MockObject/Builder/InvocationMocker.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,7 @@ public function method(Constraint|string $constraint): self
210210

211211
if (is_string($constraint)) {
212212
$this->configurableMethodNames ??= array_flip(array_map(
213-
static function (ConfigurableMethod $configurable)
214-
{
215-
return strtolower($configurable->name());
216-
},
213+
static fn (ConfigurableMethod $configurable) => strtolower($configurable->name()),
217214
$this->configurableMethods
218215
));
219216

src/Logging/TestDox/NamePrettifier.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,10 @@ public function prettifyTestCase(TestCase $test, bool $colorize): string
182182
$providedData = $this->mapTestMethodParameterNamesToProvidedDataValues($test, $colorize);
183183

184184
$variables = array_map(
185-
static function (string $variable): string
186-
{
187-
return sprintf(
188-
'/%s(?=\b)/',
189-
preg_quote($variable, '/')
190-
);
191-
},
185+
static fn (string $variable): string => sprintf(
186+
'/%s(?=\b)/',
187+
preg_quote($variable, '/')
188+
),
192189
array_keys($providedData)
193190
);
194191

@@ -270,10 +267,7 @@ private function mapTestMethodParameterNamesToProvidedDataValues(TestCase $test,
270267
}
271268

272269
if ($colorize) {
273-
$providedData = array_map(static function ($value)
274-
{
275-
return Color::colorize('fg-cyan', Color::visualizeWhitespace((string) $value, true));
276-
}, $providedData);
270+
$providedData = array_map(static fn ($value) => Color::colorize('fg-cyan', Color::visualizeWhitespace((string) $value, true)), $providedData);
277271
}
278272

279273
return $providedData;

0 commit comments

Comments
 (0)