Skip to content

Commit d75465d

Browse files
committed
minor symfony#57775 [HttpFoundation][HttpKernel] Remove unused code and useless casts (alexandre-daubois)
This PR was merged into the 7.2 branch. Discussion ---------- [HttpFoundation][HttpKernel] Remove unused code and useless casts | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT Removed some superfluous code and useless casts across HttpFoundation and HttpKernel Commits ------- c26bb3a [HttpFoundation][HttpKernel] Remove dead code and useless casts
2 parents c97bd94 + c26bb3a commit d75465d

File tree

14 files changed

+15
-20
lines changed

14 files changed

+15
-20
lines changed

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function warmUp(string $cacheDir, ?string $buildDir = null): array
4343
$router = $this->container->get('router');
4444

4545
if ($router instanceof WarmableInterface) {
46-
return (array) $router->warmUp($cacheDir, $buildDir);
46+
return $router->warmUp($cacheDir, $buildDir);
4747
}
4848

4949
throw new \LogicException(\sprintf('The router "%s" cannot be warmed up because it does not implement "%s".', get_debug_type($router), WarmableInterface::class));

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TranslationsCacheWarmer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function warmUp(string $cacheDir, ?string $buildDir = null): array
4040
$this->translator ??= $this->container->get('translator');
4141

4242
if ($this->translator instanceof WarmableInterface) {
43-
return (array) $this->translator->warmUp($cacheDir, $buildDir);
43+
return $this->translator->warmUp($cacheDir, $buildDir);
4444
}
4545

4646
return [];

src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/RouterCacheWarmerTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public function testWarmUpWithWarmableInterfaceWithBuildDir()
2424
$container = new Container();
2525

2626
$routerMock = $this->getMockBuilder(testRouterInterfaceWithWarmableInterface::class)->onlyMethods(['match', 'generate', 'getContext', 'setContext', 'getRouteCollection', 'warmUp'])->getMock();
27+
$routerMock->method('warmUp')->willReturn([]);
28+
2729
$container->set('router', $routerMock);
2830
$routerCacheWarmer = new RouterCacheWarmer($container);
2931

src/Symfony/Component/HttpFoundation/BinaryFileResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function setFile(\SplFileInfo|string $file, ?string $contentDisposition =
7070
if ($file instanceof \SplFileInfo) {
7171
$file = new File($file->getPathname(), !$isTemporaryFile);
7272
} else {
73-
$file = new File((string) $file);
73+
$file = new File($file);
7474
}
7575
}
7676

src/Symfony/Component/HttpFoundation/File/File.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ protected function getName(string $name): string
134134
{
135135
$originalName = str_replace('\\', '/', $name);
136136
$pos = strrpos($originalName, '/');
137-
$originalName = false === $pos ? $originalName : substr($originalName, $pos + 1);
138137

139-
return $originalName;
138+
return false === $pos ? $originalName : substr($originalName, $pos + 1);
140139
}
141140
}

src/Symfony/Component/HttpFoundation/HeaderBag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function get(string $key, ?string $default = null): ?string
118118
return null;
119119
}
120120

121-
return (string) $headers[0];
121+
return $headers[0];
122122
}
123123

124124
/**

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1878,7 +1878,7 @@ protected function preparePathInfo(): string
18781878
}
18791879

18801880
$pathInfo = substr($requestUri, \strlen($baseUrl));
1881-
if (false === $pathInfo || '' === $pathInfo) {
1881+
if ('' === $pathInfo) {
18821882
// If substr() returns false then PATH_INFO is set to an empty string
18831883
return '/';
18841884
}

src/Symfony/Component/HttpFoundation/Test/Constraint/ResponseCookieValueSame.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ public function toString(): string
3434
if ($this->domain) {
3535
$str .= \sprintf(' for domain "%s"', $this->domain);
3636
}
37-
$str .= \sprintf(' with value "%s"', $this->value);
3837

39-
return $str;
38+
return $str.\sprintf(' with value "%s"', $this->value);
4039
}
4140

4241
/**

src/Symfony/Component/HttpKernel/Attribute/AsController.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,4 @@
2121
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_FUNCTION)]
2222
class AsController
2323
{
24-
public function __construct()
25-
{
26-
}
2724
}

src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function warmUp(string $cacheDir, ?string $buildDir = null, ?SymfonyStyle
9393
}
9494

9595
$start = microtime(true);
96-
foreach ((array) $warmer->warmUp($cacheDir, $buildDir) as $item) {
96+
foreach ($warmer->warmUp($cacheDir, $buildDir) as $item) {
9797
if (is_dir($item) || (str_starts_with($item, \dirname($cacheDir)) && !is_file($item)) || ($buildDir && str_starts_with($item, \dirname($buildDir)) && !is_file($item))) {
9898
throw new \LogicException(\sprintf('"%s::warmUp()" should return a list of files or classes but "%s" is none of them.', $warmer::class, $item));
9999
}

0 commit comments

Comments
 (0)