Skip to content

Commit e454ad9

Browse files
tigitznicolas-grekas
authored andcommitted
Leverage arrow function syntax for closure
1 parent 157745e commit e454ad9

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

Csp/ContentSecurityPolicyHandler.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,7 @@ private function generateNonce(): string
180180
*/
181181
private function generateCspHeader(array $directives): string
182182
{
183-
return array_reduce(array_keys($directives), function ($res, $name) use ($directives) {
184-
return ('' !== $res ? $res.'; ' : '').sprintf('%s %s', $name, implode(' ', $directives[$name]));
185-
}, '');
183+
return array_reduce(array_keys($directives), fn ($res, $name) => ('' !== $res ? $res.'; ' : '').sprintf('%s %s', $name, implode(' ', $directives[$name])), '');
186184
}
187185

188186
/**

Tests/Controller/ProfilerControllerTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,7 @@ public function testReturns404onTokenNotFound($withCsp)
188188
$profiler
189189
->expects($this->exactly(2))
190190
->method('loadProfile')
191-
->willReturnCallback(function ($token) {
192-
return 'found' == $token ? new Profile($token) : null;
193-
})
191+
->willReturnCallback(fn ($token) => 'found' == $token ? new Profile($token) : null)
194192
;
195193

196194
$controller = $this->createController($profiler, $twig, $withCsp);

Tests/Resources/IconTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ public function testIconFileContents($iconFilePath)
3434

3535
public function provideIconFilePaths()
3636
{
37-
return array_map(function ($filePath) { return (array) $filePath; }, glob(__DIR__.'/../../Resources/views/Icon/*.svg'));
37+
return array_map(fn ($filePath) => (array) $filePath, glob(__DIR__.'/../../Resources/views/Icon/*.svg'));
3838
}
3939
}

0 commit comments

Comments
 (0)