Skip to content

Commit 36a6ee5

Browse files
CS fixes
1 parent 7d1026a commit 36a6ee5

File tree

7 files changed

+25
-25
lines changed

7 files changed

+25
-25
lines changed

Controller/ProfilerController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function panelAction(Request $request, string $token): Response
105105
}
106106

107107
if (!$profile->hasCollector($panel)) {
108-
throw new NotFoundHttpException(sprintf('Panel "%s" is not available for token "%s".', $panel, $token));
108+
throw new NotFoundHttpException(\sprintf('Panel "%s" is not available for token "%s".', $panel, $token));
109109
}
110110

111111
return $this->renderWithCspNonces($request, $this->getTemplateManager()->getName($profile, $panel), [
@@ -343,12 +343,12 @@ public function fontAction(string $fontName): Response
343343
{
344344
$this->denyAccessIfProfilerDisabled();
345345
if ('JetBrainsMono' !== $fontName) {
346-
throw new NotFoundHttpException(sprintf('Font file "%s.woff2" not found.', $fontName));
346+
throw new NotFoundHttpException(\sprintf('Font file "%s.woff2" not found.', $fontName));
347347
}
348348

349349
$fontFile = \dirname(__DIR__).'/Resources/fonts/'.$fontName.'.woff2';
350350
if (!is_file($fontFile) || !is_readable($fontFile)) {
351-
throw new NotFoundHttpException(sprintf('Cannot read font file "%s".', $fontFile));
351+
throw new NotFoundHttpException(\sprintf('Cannot read font file "%s".', $fontFile));
352352
}
353353

354354
$this->profiler?->disable();
@@ -375,7 +375,7 @@ public function openAction(Request $request): Response
375375
$filename = $this->baseDir.\DIRECTORY_SEPARATOR.$file;
376376

377377
if (preg_match("'(^|[/\\\\])\.'", $file) || !is_readable($filename)) {
378-
throw new NotFoundHttpException(sprintf('The file "%s" cannot be opened.', $file));
378+
throw new NotFoundHttpException(\sprintf('The file "%s" cannot be opened.', $file));
379379
}
380380

381381
return $this->renderWithCspNonces($request, '@WebProfiler/Profiler/open.html.twig', [

Csp/ContentSecurityPolicyHandler.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ private function updateCspHeaders(Response $response, array $nonces = []): array
124124
$headers = $this->getCspHeaders($response);
125125

126126
$types = [
127-
'script-src' => 'csp_script_nonce',
128-
'script-src-elem' => 'csp_script_nonce',
129-
'style-src' => 'csp_style_nonce',
130-
'style-src-elem' => 'csp_style_nonce',
127+
'script-src' => 'csp_script_nonce',
128+
'script-src-elem' => 'csp_script_nonce',
129+
'style-src' => 'csp_style_nonce',
130+
'style-src-elem' => 'csp_style_nonce',
131131
];
132132

133133
foreach ($headers as $header => $directives) {
@@ -152,7 +152,7 @@ private function updateCspHeaders(Response $response, array $nonces = []): array
152152
if (!\in_array('\'unsafe-inline\'', $headers[$header][$type], true)) {
153153
$headers[$header][$type][] = '\'unsafe-inline\'';
154154
}
155-
$headers[$header][$type][] = sprintf('\'nonce-%s\'', $nonces[$tokenName]);
155+
$headers[$header][$type][] = \sprintf('\'nonce-%s\'', $nonces[$tokenName]);
156156
}
157157
}
158158

@@ -180,7 +180,7 @@ private function generateNonce(): string
180180
*/
181181
private function generateCspHeader(array $directives): string
182182
{
183-
return array_reduce(array_keys($directives), fn ($res, $name) => ('' !== $res ? $res.'; ' : '').sprintf('%s %s', $name, implode(' ', $directives[$name])), '');
183+
return array_reduce(array_keys($directives), fn ($res, $name) => ('' !== $res ? $res.'; ' : '').\sprintf('%s %s', $name, implode(' ', $directives[$name])), '');
184184
}
185185

186186
/**

EventListener/WebDebugToolbarListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function isEnabled(): bool
6767
public function setMode(int $mode): void
6868
{
6969
if (self::DISABLED !== $mode && self::ENABLED !== $mode) {
70-
throw new \InvalidArgumentException(sprintf('Invalid value provided for mode, use one of "%s::DISABLED" or "%s::ENABLED".', self::class, self::class));
70+
throw new \InvalidArgumentException(\sprintf('Invalid value provided for mode, use one of "%s::DISABLED" or "%s::ENABLED".', self::class, self::class));
7171
}
7272

7373
$this->mode = $mode;

Profiler/TemplateManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function getName(Profile $profile, string $panel): mixed
4545
$templates = $this->getNames($profile);
4646

4747
if (!isset($templates[$panel])) {
48-
throw new NotFoundHttpException(sprintf('Panel "%s" is not registered in profiler or is not present in viewed profile.', $panel));
48+
throw new NotFoundHttpException(\sprintf('Panel "%s" is not registered in profiler or is not present in viewed profile.', $panel));
4949
}
5050

5151
return $templates[$panel];
@@ -77,7 +77,7 @@ public function getNames(Profile $profile): array
7777
}
7878

7979
if (!$loader->exists($template.'.html.twig')) {
80-
throw new \UnexpectedValueException(sprintf('The profiler template "%s.html.twig" for data collector "%s" does not exist.', $template, $name));
80+
throw new \UnexpectedValueException(\sprintf('The profiler template "%s.html.twig" for data collector "%s" does not exist.', $template, $name));
8181
}
8282

8383
$templates[$name] = $template.'.html.twig';

Tests/Controller/ProfilerControllerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public function testSearchBarActionDefaultPage()
225225
$this->assertSame(200, $client->getResponse()->getStatusCode());
226226

227227
foreach (['ip', 'status_code', 'url', 'token', 'start', 'end'] as $searchCriteria) {
228-
$this->assertSame('', $crawler->filter(sprintf('form input[name="%s"]', $searchCriteria))->text());
228+
$this->assertSame('', $crawler->filter(\sprintf('form input[name="%s"]', $searchCriteria))->text());
229229
}
230230
}
231231

@@ -334,7 +334,7 @@ public function testSearchActionWithoutToken()
334334
$client->request('GET', '/_profiler/search?ip=&method=GET&status_code=&url=&token=&start=&end=&limit=10');
335335

336336
$this->assertStringContainsString('results found', $client->getResponse()->getContent());
337-
$this->assertStringContainsString(sprintf('<a href="/_profiler/%s">%s</a>', $token, $token), $client->getResponse()->getContent());
337+
$this->assertStringContainsString(\sprintf('<a href="/_profiler/%s">%s</a>', $token, $token), $client->getResponse()->getContent());
338338
}
339339

340340
public function testPhpinfoActionWithProfilerDisabled()

Tests/DependencyInjection/WebProfilerExtensionTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public function testToolbarConfigUsingInterceptRedirects(
157157
bool $toolbarEnabled,
158158
bool $interceptRedirects,
159159
bool $listenerInjected,
160-
bool $listenerEnabled
160+
bool $listenerEnabled,
161161
) {
162162
$extension = new WebProfilerExtension();
163163
$extension->load(
@@ -178,11 +178,11 @@ public function testToolbarConfigUsingInterceptRedirects(
178178
public static function getInterceptRedirectsToolbarConfig()
179179
{
180180
return [
181-
[
182-
'toolbarEnabled' => false,
183-
'interceptRedirects' => true,
184-
'listenerInjected' => true,
185-
'listenerEnabled' => false,
181+
[
182+
'toolbarEnabled' => false,
183+
'interceptRedirects' => true,
184+
'listenerInjected' => true,
185+
'listenerEnabled' => false,
186186
],
187187
[
188188
'toolbarEnabled' => false,

Tests/Resources/IconTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ public function testIconFileContents($iconFilePath)
2323
$iconFilePath = realpath($iconFilePath);
2424
$svgFileContents = file_get_contents($iconFilePath);
2525

26-
$this->assertStringContainsString('xmlns="http://www.w3.org/2000/svg"', $svgFileContents, sprintf('The SVG metadata of the "%s" icon must use "http://www.w3.org/2000/svg" as its "xmlns" value.', $iconFilePath));
26+
$this->assertStringContainsString('xmlns="http://www.w3.org/2000/svg"', $svgFileContents, \sprintf('The SVG metadata of the "%s" icon must use "http://www.w3.org/2000/svg" as its "xmlns" value.', $iconFilePath));
2727

28-
$this->assertMatchesRegularExpression('~<svg .* width="\d+".+>.*</svg>~s', file_get_contents($iconFilePath), sprintf('The SVG file of the "%s" icon must include a "width" attribute.', $iconFilePath));
28+
$this->assertMatchesRegularExpression('~<svg .* width="\d+".+>.*</svg>~s', file_get_contents($iconFilePath), \sprintf('The SVG file of the "%s" icon must include a "width" attribute.', $iconFilePath));
2929

30-
$this->assertMatchesRegularExpression('~<svg .* height="\d+".+>.*</svg>~s', file_get_contents($iconFilePath), sprintf('The SVG file of the "%s" icon must include a "height" attribute.', $iconFilePath));
30+
$this->assertMatchesRegularExpression('~<svg .* height="\d+".+>.*</svg>~s', file_get_contents($iconFilePath), \sprintf('The SVG file of the "%s" icon must include a "height" attribute.', $iconFilePath));
3131

32-
$this->assertMatchesRegularExpression('~<svg .* viewBox="0 0 \d+ \d+".+>.*</svg>~s', file_get_contents($iconFilePath), sprintf('The SVG file of the "%s" icon must include a "viewBox" attribute.', $iconFilePath));
32+
$this->assertMatchesRegularExpression('~<svg .* viewBox="0 0 \d+ \d+".+>.*</svg>~s', file_get_contents($iconFilePath), \sprintf('The SVG file of the "%s" icon must include a "viewBox" attribute.', $iconFilePath));
3333
}
3434

3535
public static function provideIconFilePaths(): array

0 commit comments

Comments
 (0)