8000 minor #43871 [FrameworkBundle] Backport type fixes (derrabus) · symfony/symfony@2aff3c2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2aff3c2

Browse files
minor #43871 [FrameworkBundle] Backport type fixes (derrabus)
This PR was merged into the 5.4 branch. Discussion ---------- [FrameworkBundle] Backport type fixes | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | Backports from #43869 | License | MIT | Doc PR | N/A Commits ------- 05d6ea7 [FrameworkBundle] Backport type fixes
2 parents f377018 + 05d6ea7 commit 2aff3c2

File tree

11 files changed

+40
-21
lines changed

11 files changed

+40
-21
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ final class CachePoolClearerCacheWarmer implements CacheWarmerInterface
2828
private $poolClearer;
2929
private $pools;
3030

31+
/**
32+
* @param string[] $pools
33+
*/
3134
public function __construct(Psr6CacheClearer $poolClearer, array $pools = [])
3235
{
3336
$this->poolClearer = $poolClearer;

src/Symfony/Bundle/FrameworkBundle/Command/CachePoolClearCommand.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ final class CachePoolClearCommand extends Command
3535
private $poolClearer;
3636
private $poolNames;
3737

38+
/**
39+
* @param string[]|null $poolNames
40+
*/
3841
public function __construct(Psr6CacheClearer $poolClearer, array $poolNames = null)
3942
{
4043
parent::__construct();

src/Symfony/Bundle/FrameworkBundle/Command/CachePoolDeleteCommand.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ final class CachePoolDeleteCommand extends Command
3333
private $poolClearer;
3434
private $poolNames;
3535

36+
/**
37+
* @param string[]|null $poolNames
38+
*/
3639
public function __construct(Psr6CacheClearer $poolClearer, array $poolNames = null)
3740
{
3841
parent::__construct();

src/Symfony/Bundle/FrameworkBundle/Command/CachePoolListCommand.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ final class CachePoolListCommand extends Command
2828

2929
private $poolNames;
3030

31+
/**
32+
* @param string[] $poolNames
33+
*/
3134
public function __construct(array $poolNames)
3235
{
3336
parent::__construct();

src/Symfony/Bundle/FrameworkBundle/Command/CachePoolPruneCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ final class CachePoolPruneCommand extends Command
3030
private $pools;
3131

3232
/**
33-
* @param iterable|PruneableInterface[] $pools
33+
* @param iterable<mixed, PruneableInterface> $pools
3434
*/
3535
public function __construct(iterable $pools)
3636
{

src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\Console\Input\InputOption;
1919
use Symfony\Component\Console\Output\OutputInterface;
2020
use Symfony\Component\Console\Style\SymfonyStyle;
21+
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
2122
use Symfony\Component\Routing\Matcher\TraceableUrlMatcher;
2223
use Symfony\Component\Routing\RouterInterface;
2324

@@ -36,6 +37,9 @@ class RouterMatchCommand extends Command
3637
private $router;
3738
private $expressionLanguageProviders;
3839

40+
/**
41+
* @param iterable<mixed, ExpressionFunctionProviderInterface> $expressionLanguageProviders
42+
*/
3943
public function __construct(RouterInterface $router, iterable $expressionLanguageProviders = [])
4044
{
4145
parent::__construct();

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222
class UnusedTagsPass implements CompilerPassInterface
2323
{
24-
private $knownTags = [
24+
private const KNOWN_TAGS = [
2525
'annotations.cached_reader',
2626
'assets.package',
2727
'auto_alias',
@@ -74,10 +74,10 @@ class UnusedTagsPass implements CompilerPassInterface
7474
'routing.expression_language_provider',
7575
'routing.loader',
7676
'routing.route_loader',
77+
'security.authenticator.login_linker',
7778
'security.expression_language_provider',
7879
'security.remember_me_aware',
7980
'security.remember_me_handler',
80-
'security.authenticator.login_linker',
8181
'security.voter',
8282
'serializer.encoder',
8383
'serializer.normalizer',
@@ -96,11 +96,11 @@ class UnusedTagsPass implements CompilerPassInterface
9696

9797
public function process(ContainerBuilder $container)
9898
{
99-
$tags = array_unique(array_merge($container->findTags(), $this->knownTags));
99+
$tags = array_unique(array_merge($container->findTags(), self::KNOWN_TAGS));
100100

101101
foreach ($container->findUnusedTags() as $tag) {
102102
// skip known tags
103-
if (\in_array($tag, $this->knownTags)) {
103+
if (\in_array($tag, self::KNOWN_TAGS)) {
104104
continue;
105105
}
106106

src/Symfony/Bundle/FrameworkBundle/Resources/bin/check-unused-known-tags.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515

1616
$target = dirname(__DIR__, 2).'/DependencyInjection/Compiler/UnusedTagsPass.php';
1717
$contents = file_get_contents($target);
18-
$contents = preg_replace('{private \$knownTags = \[(.+?)\];}sm', "private \$knownTags = [\n '".implode("',\n '", UnusedTagsPassUtils::getDefinedTags())."',\n ];", $contents);
18+
$contents = preg_replace('{private const KNOWN_TAGS = \[(.+?)\];}sm', "private const KNOWN_TAGS = [\n '".implode("',\n '", UnusedTagsPassUtils::getDefinedTags())."',\n ];", $contents);
1919
file_put_contents($target, $contents);

src/Symfony/Bundle/FrameworkBundle/Routing/Router.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ public function __construct(ContainerInterface $container, $resource, array $opt
4949
$this->setOptions($options);
5050

5151
if ($parameters) {
52-
$this->paramFetcher = [$parameters, 'get'];
52+
$this->paramFetcher = \Closure::fromCallable([$parameters, 'get']);
5353
} elseif ($container instanceof SymfonyContainerInterface) {
54-
$this->paramFetcher = [$container, 'getParameter'];
54+
$this->paramFetcher = \Closure::fromCallable([$container, 'getParameter']);
5555
} else {
5656
throw new \LogicException(sprintf('You should either pass a "%s" instance or provide the $parameters argument of the "%s" method.', SymfonyContainerInterface::class, __METHOD__));
5757
}

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/UnusedTagsPassTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ public function testMissingKnownTags()
4343

4444< E377 div class="diff-text-inner"> private function getKnownTags(): array
4545
{
46-
// get tags in UnusedTagsPass
47-
$target = \dirname(__DIR__, 3).'/DependencyInjection/Compiler/UnusedTagsPass.php';
48-
$contents = file_get_contents($target);
49-
preg_match('{private \$knownTags = \[(.+?)\];}sm', $contents, $matches);
50-
$tags = array_values(array_filter(array_map(function ($str) {
51-
return trim(preg_replace('{^ +\'(.+)\',}', '$1', $str));
52-
}, explode("\n", $matches[1]))));
46+
$tags = \Closure::bind(
47+
static function () {
48+
return UnusedTagsPass::KNOWN_TAGS;
49+
},
50+
null,
51+
UnusedTagsPass::class
52+
)();
5353
sort($tags);
5454

5555
return $tags;

src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,21 @@ class Translator extends BaseTranslator implements WarmableInterface
3636
];
3737

3838
/**
39-
* @var array
39+
* @var list<string>
4040
*/
4141
private $resourceLocales;
4242

4343
/**
4444
* Holds parameters from addResource() calls so we can defer the actual
4545
* parent::addResource() calls until initialize() is executed.
4646
*
47-
* @var array
47+
* @var array[]
4848
*/
49 F438 49
private $resources = [];
5050

51+
/**
52+
* @var string[][]
53+
*/
5154
private $resourceFiles;
5255

5356
/**
@@ -152,7 +155,7 @@ protected function initialize()
152155
if ($this->resourceFiles) {
153156
$this->addResourceFiles();
154157
}
155-
foreach ($this->resources as $key => $params) {
158+
foreach ($this->resources as $params) {
156159
[$format, $resource, $locale, $domain] = $params;
157160
parent::addResource($format, $resource, $locale, $domain);
158161
}
@@ -165,13 +168,13 @@ protected function initialize()
165168
}
166169
}
167170

168-
private function addResourceFiles()
171+
private function addResourceFiles(): void
169172
{
170173
$filesByLocale = $this->resourceFiles;
171174
$this->resourceFiles = [];
172175

173-
foreach ($filesByLocale as $locale => $files) {
174-
foreach ($files as $key => $file) {
176+
foreach ($filesByLocale as $files) {
177+
foreach ($files as $file) {
175178
// filename is domain.locale.format
176179
$fileNameParts = explode('.', basename($file));
177180
$format = array_pop($fileNameParts);

0 commit comments

Comments
 (0)
0