diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/CachePoolClearerCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/CachePoolClearerCacheWarmer.php index 0e5997996004f..79bca240339b7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/CachePoolClearerCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/CachePoolClearerCacheWarmer.php @@ -28,6 +28,9 @@ final class CachePoolClearerCacheWarmer implements CacheWarmerInterface private $poolClearer; private $pools; + /** + * @param string[] $pools + */ public function __construct(Psr6CacheClearer $poolClearer, array $pools = []) { $this->poolClearer = $poolClearer; diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolClearCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolClearCommand.php index 75898de27d7bf..b72924dfa78d6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolClearCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolClearCommand.php @@ -35,6 +35,9 @@ final class CachePoolClearCommand extends Command private $poolClearer; private $poolNames; + /** + * @param string[]|null $poolNames + */ public function __construct(Psr6CacheClearer $poolClearer, array $poolNames = null) { parent::__construct(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolDeleteCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolDeleteCommand.php index c9ac7c497b9f1..b36d48cfe3973 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolDeleteCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolDeleteCommand.php @@ -33,6 +33,9 @@ final class CachePoolDeleteCommand extends Command private $poolClearer; private $poolNames; + /** + * @param string[]|null $poolNames + */ public function __construct(Psr6CacheClearer $poolClearer, array $poolNames = null) { parent::__construct(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolListCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolListCommand.php index 4a4b1eb2fa49e..0ad33241deb73 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolListCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolListCommand.php @@ -28,6 +28,9 @@ final class CachePoolListCommand extends Command private $poolNames; + /** + * @param string[] $poolNames + */ public function __construct(array $poolNames) { parent::__construct(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolPruneCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolPruneCommand.php index bfe4a444d99ac..8d10352942fb5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolPruneCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolPruneCommand.php @@ -30,7 +30,7 @@ final class CachePoolPruneCommand extends Command private $pools; /** - * @param iterable|PruneableInterface[] $pools + * @param iterable $pools */ public function __construct(iterable $pools) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php index 0edaf661e222b..6cceb945dd96f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php @@ -18,6 +18,7 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; +use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface; use Symfony\Component\Routing\Matcher\TraceableUrlMatcher; use Symfony\Component\Routing\RouterInterface; @@ -36,6 +37,9 @@ class RouterMatchCommand extends Command private $router; private $expressionLanguageProviders; + /** + * @param iterable $expressionLanguageProviders + */ public function __construct(RouterInterface $router, iterable $expressionLanguageProviders = []) { parent::__construct(); diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php index 392a95ce64b5f..a556599e76d0c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php @@ -21,7 +21,7 @@ */ class UnusedTagsPass implements CompilerPassInterface { - private $knownTags = [ + private const KNOWN_TAGS = [ 'annotations.cached_reader', 'assets.package', 'auto_alias', @@ -74,10 +74,10 @@ class UnusedTagsPass implements CompilerPassInterface 'routing.expression_language_provider', 'routing.loader', 'routing.route_loader', + 'security.authenticator.login_linker', 'security.expression_language_provider', 'security.remember_me_aware', 'security.remember_me_handler', - 'security.authenticator.login_linker', 'security.voter', 'serializer.encoder', 'serializer.normalizer', @@ -96,11 +96,11 @@ class UnusedTagsPass implements CompilerPassInterface public function process(ContainerBuilder $container) { - $tags = array_unique(array_merge($container->findTags(), $this->knownTags)); + $tags = array_unique(array_merge($container->findTags(), self::KNOWN_TAGS)); foreach ($container->findUnusedTags() as $tag) { // skip known tags - if (\in_array($tag, $this->knownTags)) { + if (\in_array($tag, self::KNOWN_TAGS)) { continue; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/bin/check-unused-known-tags.php b/src/Symfony/Bundle/FrameworkBundle/Resources/bin/check-unused-known-tags.php index ec9ae1f97c0ff..4920c43ebe182 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/bin/check-unused-known-tags.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/bin/check-unused-known-tags.php @@ -15,5 +15,5 @@ $target = dirname(__DIR__, 2).'/DependencyInjection/Compiler/UnusedTagsPass.php'; $contents = file_get_contents($target); -$contents = preg_replace('{private \$knownTags = \[(.+?)\];}sm', "private \$knownTags = [\n '".implode("',\n '", UnusedTagsPassUtils::getDefinedTags())."',\n ];", $contents); +$contents = preg_replace('{private const KNOWN_TAGS = \[(.+?)\];}sm', "private const KNOWN_TAGS = [\n '".implode("',\n '", UnusedTagsPassUtils::getDefinedTags())."',\n ];", $contents); file_put_contents($target, $contents); diff --git a/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php b/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php index 19088135c6542..585e6ee130deb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php +++ b/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php @@ -49,9 +49,9 @@ public function __construct(ContainerInterface $container, $resource, array $opt $this->setOptions($options); if ($parameters) { - $this->paramFetcher = [$parameters, 'get']; + $this->paramFetcher = \Closure::fromCallable([$parameters, 'get']); } elseif ($container instanceof SymfonyContainerInterface) { - $this->paramFetcher = [$container, 'getParameter']; + $this->paramFetcher = \Closure::fromCallable([$container, 'getParameter']); } else { throw new \LogicException(sprintf('You should either pass a "%s" instance or provide the $parameters argument of the "%s" method.', SymfonyContainerInterface::class, __METHOD__)); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/UnusedTagsPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/UnusedTagsPassTest.php index 89a35285ba234..433b798d81a94 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/UnusedTagsPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/UnusedTagsPassTest.php @@ -43,13 +43,13 @@ public function testMissingKnownTags() private function getKnownTags(): array { - // get tags in UnusedTagsPass - $target = \dirname(__DIR__, 3).'/DependencyInjection/Compiler/UnusedTagsPass.php'; - $contents = file_get_contents($target); - preg_match('{private \$knownTags = \[(.+?)\];}sm', $contents, $matches); - $tags = array_values(array_filter(array_map(function ($str) { - return trim(preg_replace('{^ +\'(.+)\',}', '$1', $str)); - }, explode("\n", $matches[1])))); + $tags = \Closure::bind( + static function () { + return UnusedTagsPass::KNOWN_TAGS; + }, + null, + UnusedTagsPass::class + )(); sort($tags); return $tags; diff --git a/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php b/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php index 0c4deee36d8d3..5173f8a8efb51 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php +++ b/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php @@ -36,7 +36,7 @@ class Translator extends BaseTranslator implements WarmableInterface ]; /** - * @var array + * @var list */ private $resourceLocales; @@ -44,10 +44,13 @@ class Translator extends BaseTranslator implements WarmableInterface * Holds parameters from addResource() calls so we can defer the actual * parent::addResource() calls until initialize() is executed. * - * @var array + * @var array[] */ private $resources = []; + /** + * @var string[][] + */ private $resourceFiles; /** @@ -152,7 +155,7 @@ protected function initialize() if ($this->resourceFiles) { $this->addResourceFiles(); } - foreach ($this->resources as $key => $params) { + foreach ($this->resources as $params) { [$format, $resource, $locale, $domain] = $params; parent::addResource($format, $resource, $locale, $domain); } @@ -165,13 +168,13 @@ protected function initialize() } } - private function addResourceFiles() + private function addResourceFiles(): void { $filesByLocale = $this->resourceFiles; $this->resourceFiles = []; - foreach ($filesByLocale as $locale => $files) { - foreach ($files as $key => $file) { + foreach ($filesByLocale as $files) { + foreach ($files as $file) { // filename is domain.locale.format $fileNameParts = explode('.', basename($file)); $format = array_pop($fileNameParts);