Skip to content

Commit 889bca5

Browse files
tigitznicolas-grekas
authored andcommitted
Leverage arrow function syntax for closure
1 parent 45a63a5 commit 889bca5

8 files changed

+16
-30
lines changed

GenericRuntime.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function getResolver(callable $callable, \ReflectionFunction $reflector =
113113

114114
public function getRunner(?object $application): RunnerInterface
115115
{
116-
$application ??= static function () { return 0; };
116+
$application ??= static fn () => 0;
117117

118118
if ($application instanceof RunnerInterface) {
119119
return $application;

Tests/phpt/dotenv_overload.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,4 @@
1919

2020
require __DIR__.'/autoload.php';
2121

22-
return function (Request $request, array $context) {
23-
return new Response('OK Request '.$context['SOME_VAR']);
24-
};
22+
return fn (Request $request, array $context) => new Response('OK Request '.$context['SOME_VAR']);

Tests/phpt/dotenv_overload_command_debug_exists_0_to_1.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020

2121
require __DIR__.'/autoload.php';
2222

23-
return static function (Command $command, OutputInterface $output, array $context): Command {
24-
return $command->setCode(static function () use ($output, $context): void {
25-
$output->writeln($context['DEBUG_ENABLED']);
26-
});
27-
};
23+
return static fn (Command $command, OutputInterface $output, array $context): Command => $command->setCode(static function () use ($output, $context): void {
24+
$output->writeln($context['DEBUG_ENABLED']);
25+
});

Tests/phpt/dotenv_overload_command_debug_exists_1_to_0.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020

2121
require __DIR__.'/autoload.php';
2222

23-
return static function (Command $command, OutputInterface $output, array $context): Command {
24-
return $command->setCode(static function () use ($output, $context): void {
25-
$output->writeln($context['DEBUG_MODE']);
26-
});
27-
};
23+
return static fn (Command $command, OutputInterface $output, array $context): Command => $command->setCode(static function () use ($output, $context): void {
24+
$output->writeln($context['DEBUG_MODE']);
25+
});

Tests/phpt/dotenv_overload_command_env_exists.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020

2121
require __DIR__.'/autoload.php';
2222

23-
return static function (Command $command, OutputInterface $output, array $context): Command {
24-
return $command->setCode(static function () use ($output, $context): void {
25-
$output->writeln($context['ENV_MODE']);
26-
});
27-
};
23+
return static fn (Command $command, OutputInterface $output, array $context): Command => $command->setCode(static function () use ($output, $context): void {
24+
$output->writeln($context['ENV_MODE']);
25+
});

Tests/phpt/dotenv_overload_command_no_debug.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
require __DIR__.'/autoload.php';
2121

22-
return static function (Command $command, OutputInterface $output, array $context): Command {
23-
return $command->setCode(static function () use ($output, $context): void {
24-
$output->writeln($context['DEBUG_ENABLED']);
25-
});
26-
};
22+
return static fn (Command $command, OutputInterface $output, array $context): Command => $command->setCode(static function () use ($output, $context): void {
23+
$output->writeln($context['DEBUG_ENABLED']);
24+
});

Tests/phpt/kernel.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,4 @@ public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = tr
3030
}
3131
}
3232

33-
return function (array $context) {
34-
return new TestKernel($context['SOME_VAR']);
35-
};
33+
return fn (array $context) => new TestKernel($context['SOME_VAR']);

Tests/phpt/request.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,4 @@
1414

1515
require __DIR__.'/autoload.php';
1616

17-
return function (Request $request, array $context) {
18-
return new Response('OK Request '.$context['SOME_VAR']);
19-
};
17+
return fn (Request $request, array $context) => new Response('OK Request '.$context['SOME_VAR']);

0 commit comments

Comments
 (0)