From 88220cfecd0f03ac0433e4d27f5170e981c33d81 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 1 Nov 2021 17:29:31 +0100 Subject: [PATCH] [FrameworkBundle] Add types to private properties --- .../AbstractPhpFileCacheWarmer.php | 2 +- .../CacheWarmer/AnnotationsCacheWarmer.php | 6 ++--- .../CachePoolClearerCacheWarmer.php | 7 ++++-- .../CacheWarmer/ConfigBuilderCacheWarmer.php | 4 +-- .../CacheWarmer/RouterCacheWarmer.php | 2 +- .../CacheWarmer/SerializerCacheWarmer.php | 2 +- .../CacheWarmer/TranslationsCacheWarmer.php | 8 +++--- .../CacheWarmer/ValidatorCacheWarmer.php | 2 +- .../Command/AssetsInstallCommand.php | 4 +-- .../Command/CacheClearCommand.php | 4 +-- .../Command/CachePoolClearCommand.php | 7 ++++-- .../Command/CachePoolDeleteCommand.php | 7 ++++-- .../Command/CachePoolListCommand.php | 5 +++- .../Command/CachePoolPruneCommand.php | 4 +-- .../Command/CacheWarmupCommand.php | 2 +- .../Command/ContainerLintCommand.php | 7 ++---- .../Command/DebugAutowiringCommand.php | 4 +-- .../Command/EventDispatcherDebugCommand.php | 2 +- .../Command/RouterDebugCommand.php | 4 +-- .../Command/RouterMatchCommand.php | 8 ++++-- .../Command/SecretsDecryptToLocalCommand.php | 4 +-- .../SecretsEncryptFromLocalCommand.php | 4 +-- .../Command/SecretsGenerateKeysCommand.php | 4 +-- .../Command/SecretsListCommand.php | 4 +-- .../Command/SecretsRemoveCommand.php | 4 +-- .../Command/SecretsSetCommand.php | 4 +-- .../Command/TranslationDebugCommand.php | 16 ++++++------ .../Command/TranslationUpdateCommand.php | 18 ++++++------- .../FrameworkBundle/Console/Application.php | 6 ++--- .../Console/Descriptor/TextDescriptor.php | 2 +- .../Controller/RedirectController.php | 6 ++--- .../Controller/TemplateController.php | 2 +- .../Compiler/UnusedTagsPass.php | 8 +++--- .../DependencyInjection/Configuration.php | 2 +- .../FrameworkExtension.php | 22 ++++++++-------- .../FrameworkBundle/HttpCache/HttpCache.php | 6 ++--- .../Bundle/FrameworkBundle/KernelBrowser.php | 6 ++--- .../Resources/bin/check-unused-known-tags.php | 2 +- .../Routing/DelegatingLoader.php | 6 ++--- .../Bundle/FrameworkBundle/Routing/Router.php | 10 ++++---- .../FrameworkBundle/Secrets/DotenvVault.php | 2 +- .../FrameworkBundle/Secrets/SodiumVault.php | 8 +++--- .../FrameworkBundle/Test/KernelTestCase.php | 2 +- .../FrameworkBundle/Test/TestBrowserToken.php | 2 +- .../FrameworkBundle/Test/TestContainer.php | 4 +-- .../Compiler/UnusedTagsPassTest.php | 14 +++++------ .../Translation/Translator.php | 25 +++++++++++-------- 47 files changed, 149 insertions(+), 135 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AbstractPhpFileCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AbstractPhpFileCacheWarmer.php index f4a06a2cf1bc2..097a356008a5b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AbstractPhpFileCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AbstractPhpFileCacheWarmer.php @@ -19,7 +19,7 @@ abstract class AbstractPhpFileCacheWarmer implements CacheWarmerInterface { - private $phpArrayFile; + private string $phpArrayFile; /** * @param string $phpArrayFile The PHP file where metadata are cached diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php index aaee63b15140e..6bc39acc27923 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php @@ -25,9 +25,9 @@ */ class AnnotationsCacheWarmer extends AbstractPhpFileCacheWarmer { - private $annotationReader; - private $excludeRegexp; - private $debug; + private Reader $annotationReader; + private ?string $excludeRegexp; + private bool $debug; /** * @param string $phpArrayFile The PHP file where annotations are cached diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/CachePoolClearerCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/CachePoolClearerCacheWarmer.php index 0e5997996004f..41041aedaed99 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/CachePoolClearerCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/CachePoolClearerCacheWarmer.php @@ -25,9 +25,12 @@ */ final class CachePoolClearerCacheWarmer implements CacheWarmerInterface { - private $poolClearer; - private $pools; + private Psr6CacheClearer $poolClearer; + private array $pools; + /** + * @param string[] $pools + */ public function __construct(Psr6CacheClearer $poolClearer, array $pools = []) { $this->poolClearer = $poolClearer; diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ConfigBuilderCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ConfigBuilderCacheWarmer.php index c0d96c5ea7b74..70c42c1e05301 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ConfigBuilderCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ConfigBuilderCacheWarmer.php @@ -28,8 +28,8 @@ */ class ConfigBuilderCacheWarmer implements CacheWarmerInterface { - private $kernel; - private $logger; + private KernelInterface $kernel; + private ?LoggerInterface $logger; public function __construct(KernelInterface $kernel, LoggerInterface $logger = null) { diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php index 6cdf176bb33bb..21dd3a2728845 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php @@ -26,7 +26,7 @@ */ class RouterCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInterface { - private $container; + private ContainerInterface $container; public function __construct(ContainerInterface $container) { diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php index e574cea817596..4aae3ba96eaf5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php @@ -27,7 +27,7 @@ */ class SerializerCacheWarmer extends AbstractPhpFileCacheWarmer { - private $loaders; + private array $loaders; /** * @param LoaderInterface[] $loaders The serializer metadata loaders diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TranslationsCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TranslationsCacheWarmer.php index e16ef30b536e5..8cddae7e308ce 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TranslationsCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TranslationsCacheWarmer.php @@ -24,8 +24,8 @@ */ class TranslationsCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInterface { - private $container; - private $translator; + private ContainerInterface $container; + private TranslatorInterface $translator; public function __construct(ContainerInterface $container) { @@ -40,9 +40,7 @@ public function __construct(ContainerInterface $container) */ public function warmUp(string $cacheDir): array { - if (null === $this->translator) { - $this->translator = $this->container->get('translator'); - } + $this->translator ??= $this->container->get('translator'); if ($this->translator instanceof WarmableInterface) { return (array) $this->translator->warmUp($cacheDir); diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php index 6b2c558be96e5..e28e21eb98324 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php @@ -28,7 +28,7 @@ */ class ValidatorCacheWarmer extends AbstractPhpFileCacheWarmer { - private $validatorBuilder; + private ValidatorBuilder $validatorBuilder; /** * @param string $phpArrayFile The PHP file where metadata are cached diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php index 4ed00653315d5..020eb8aae9393 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php @@ -41,8 +41,8 @@ class AssetsInstallCommand extends Command public const METHOD_ABSOLUTE_SYMLINK = 'absolute symlink'; public const METHOD_RELATIVE_SYMLINK = 'relative symlink'; - private $filesystem; - private $projectDir; + private Filesystem $filesystem; + private string $projectDir; public function __construct(Filesystem $filesystem, string $projectDir) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php index d9b2730506020..fb96ee8844dea 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php @@ -37,8 +37,8 @@ #[AsCommand(name: 'cache:clear', description: 'Clear the cache')] class CacheClearCommand extends Command { - private $cacheClearer; - private $filesystem; + private CacheClearerInterface $cacheClearer; + private Filesystem $filesystem; public function __construct(CacheClearerInterface $cacheClearer, Filesystem $filesystem = null) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolClearCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolClearCommand.php index 41f483f5394b2..65da5d7709487 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolClearCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolClearCommand.php @@ -31,9 +31,12 @@ #[AsCommand(name: 'cache:pool:clear', description: 'Clear cache pools')] final class CachePoolClearCommand extends Command { - private $poolClearer; - private $poolNames; + private Psr6CacheClearer $poolClearer; + private ?array $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 aa5da15f5ab22..546bd631d492c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolDeleteCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolDeleteCommand.php @@ -29,9 +29,12 @@ #[AsCommand(name: 'cache:pool:delete', description: 'Delete an item from a cache pool')] final class CachePoolDeleteCommand extends Command { - private $poolClearer; - private $poolNames; + private Psr6CacheClearer $poolClearer; + private ?array $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 bf303379eb137..09ec8b1ef0cc7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolListCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolListCommand.php @@ -25,8 +25,11 @@ #[AsCommand(name: 'cache:pool:list', description: 'List available cache pools')] final class CachePoolListCommand extends Command { - private $poolNames; + private array $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 382b8fbba4a64..1e8bb7f0338a6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolPruneCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolPruneCommand.php @@ -26,10 +26,10 @@ #[AsCommand(name: 'cache:pool:prune', description: 'Prune cache pools')] final class CachePoolPruneCommand extends Command { - private $pools; + private iterable $pools; /** - * @param iterable|PruneableInterface[] $pools + * @param iterable $pools */ public function __construct(iterable $pools) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php index 7a8e0cc555246..36c2f76e7e3cf 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php @@ -30,7 +30,7 @@ #[AsCommand(name: 'cache:warmup', description: 'Warm up an empty cache')] class CacheWarmupCommand extends Command { - private $cacheWarmer; + private CacheWarmerAggregate $cacheWarmer; public function __construct(CacheWarmerAggregate $cacheWarmer) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerLintCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerLintCommand.php index b27ad911892c9..5c6745b0185c1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerLintCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerLintCommand.php @@ -31,10 +31,7 @@ #[AsCommand(name: 'lint:container', description: 'Ensure that arguments injected into services match type declarations')] final class ContainerLintCommand extends Command { - /** - * @var ContainerBuilder - */ - private $containerBuilder; + private ContainerBuilder $containerBuilder; /** * {@inheritdoc} @@ -79,7 +76,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int private function getContainerBuilder(): ContainerBuilder { - if ($this->containerBuilder) { + if (isset($this->containerBuilder)) { return $this->containerBuilder; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php index 7ad8ed67295a0..aab82142d9c67 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php @@ -31,8 +31,8 @@ #[AsCommand(name: 'debug:autowiring', description: 'List classes/interfaces you can use for autowiring')] class DebugAutowiringCommand extends ContainerDebugCommand { - private $supportsHref; - private $fileLinkFormatter; + private bool $supportsHref; + private ?FileLinkFormatter $fileLinkFormatter; public function __construct(string $name = null, FileLinkFormatter $fileLinkFormatter = null) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/EventDispatcherDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/EventDispatcherDebugCommand.php index 01304475798e1..fe56e94f333fa 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/EventDispatcherDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/EventDispatcherDebugCommand.php @@ -34,7 +34,7 @@ class EventDispatcherDebugCommand extends Command { private const DEFAULT_DISPATCHER = 'event_dispatcher'; - private $dispatchers; + private ContainerInterface $dispatchers; public function __construct(ContainerInterface $dispatchers) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php index cf2c93b05e781..ed61ddd8ff7b3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php @@ -39,8 +39,8 @@ class RouterDebugCommand extends Command { use BuildDebugContainerTrait; - private $router; - private $fileLinkFormatter; + private RouterInterface $router; + private ?FileLinkFormatter $fileLinkFormatter; public function __construct(RouterInterface $router, FileLinkFormatter $fileLinkFormatter = null) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php index 404dd140dafd4..da78d510a6b4c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php @@ -19,6 +19,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; @@ -32,9 +33,12 @@ #[AsCommand(name: 'router:match', description: 'Help debug routes by simulating a path info match')] class RouterMatchCommand extends Command { - private $router; - private $expressionLanguageProviders; + private RouterInterface $router; + private iterable $expressionLanguageProviders; + /** + * @param iterable $expressionLanguageProviders + */ public function __construct(RouterInterface $router, iterable $expressionLanguageProviders = []) { parent::__construct(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/SecretsDecryptToLocalCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/SecretsDecryptToLocalCommand.php index 255de463ef6df..823c0f10d8d1a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/SecretsDecryptToLocalCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/SecretsDecryptToLocalCommand.php @@ -28,8 +28,8 @@ #[AsCommand(name: 'secrets:decrypt-to-local', description: 'Decrypt all secrets and stores them in the local vault')] final class SecretsDecryptToLocalCommand extends Command { - private $vault; - private $localVault; + private AbstractVault $vault; + private ?AbstractVault $localVault; public function __construct(AbstractVault $vault, AbstractVault $localVault = null) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/SecretsEncryptFromLocalCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/SecretsEncryptFromLocalCommand.php index 439e060a2d5bb..aa5d25fc8dc2d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/SecretsEncryptFromLocalCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/SecretsEncryptFromLocalCommand.php @@ -27,8 +27,8 @@ #[AsCommand(name: 'secrets:encrypt-from-local', description: 'Encrypt all local secrets to the vault')] final class SecretsEncryptFromLocalCommand extends Command { - private $vault; - private $localVault; + private AbstractVault $vault; + private ?AbstractVault $localVault; public function __construct(AbstractVault $vault, AbstractVault $localVault = null) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/SecretsGenerateKeysCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/SecretsGenerateKeysCommand.php index eeeaa2a391db6..40816665781bf 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/SecretsGenerateKeysCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/SecretsGenerateKeysCommand.php @@ -30,8 +30,8 @@ #[AsCommand(name: 'secrets:generate-keys', description: 'Generate new encryption keys')] final class SecretsGenerateKeysCommand extends Command { - private $vault; - private $localVault; + private AbstractVault $vault; + private ?AbstractVault $localVault; public function __construct(AbstractVault $vault, AbstractVault $localVault = null) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/SecretsListCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/SecretsListCommand.php index 1ce6bbcb7dc89..96f0f3762d393 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/SecretsListCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/SecretsListCommand.php @@ -31,8 +31,8 @@ #[AsCommand(name: 'secrets:list', description: 'List all secrets')] final class SecretsListCommand extends Command { - private $vault; - private $localVault; + private AbstractVault $vault; + private ?AbstractVault $localVault; public function __construct(AbstractVault $vault, AbstractVault $localVault = null) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/SecretsRemoveCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/SecretsRemoveCommand.php index 5e68295e715e4..dfbfcf2267469 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/SecretsRemoveCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/SecretsRemoveCommand.php @@ -32,8 +32,8 @@ #[AsCommand(name: 'secrets:remove', description: 'Remove a secret from the vault')] final class SecretsRemoveCommand extends Command { - private $vault; - private $localVault; + private AbstractVault $vault; + private ?AbstractVault $localVault; public function __construct(AbstractVault $vault, AbstractVault $localVault = null) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/SecretsSetCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/SecretsSetCommand.php index 21113b759b23f..1a0a500d89872 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/SecretsSetCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/SecretsSetCommand.php @@ -33,8 +33,8 @@ #[AsCommand(name: 'secrets:set', description: 'Set a secret in the vault')] final class SecretsSetCommand extends Command { - private $vault; - private $localVault; + private AbstractVault $vault; + private ?AbstractVault $localVault; public function __construct(AbstractVault $vault, AbstractVault $localVault = null) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php index b148190b9c531..906f160b4f11f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php @@ -50,14 +50,14 @@ class TranslationDebugCommand extends Command public const MESSAGE_UNUSED = 1; public const MESSAGE_EQUALS_FALLBACK = 2; - private $translator; - private $reader; - private $extractor; - private $defaultTransPath; - private $defaultViewsPath; - private $transPaths; - private $codePaths; - private $enabledLocales; + private TranslatorInterface $translator; + private TranslationReaderInterface $reader; + private ExtractorInterface $extractor; + private ?string $defaultTransPath; + private ?string $defaultViewsPath; + private array $transPaths; + private array $codePaths; + private array $enabledLocales; public function __construct(TranslatorInterface $translator, TranslationReaderInterface $reader, ExtractorInterface $extractor, string $defaultTransPath = null, string $defaultViewsPath = null, array $transPaths = [], array $codePaths = [], array $enabledLocales = []) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php index 3015e0baeef95..002a80e049b7c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php @@ -50,15 +50,15 @@ class TranslationUpdateCommand extends Command 'xlf20' => ['xlf', '2.0'], ]; - private $writer; - private $reader; - private $extractor; - private $defaultLocale; - private $defaultTransPath; - private $defaultViewsPath; - private $transPaths; - private $codePaths; - private $enabledLocales; + private TranslationWriterInterface $writer; + private TranslationReaderInterface $reader; + private ExtractorInterface $extractor; + private string $defaultLocale; + private ?string $defaultTransPath; + private ?string $defaultViewsPath; + private array $transPaths; + private array $codePaths; + private array $enabledLocales; public function __construct(TranslationWriterInterface $writer, TranslationReaderInterface $reader, ExtractorInterface $extractor, string $defaultLocale, string $defaultTransPath = null, string $defaultViewsPath = null, array $transPaths = [], array $codePaths = [], array $enabledLocales = []) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Application.php b/src/Symfony/Bundle/FrameworkBundle/Console/Application.php index 42bed36f56445..5f7cb53420d6f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Application.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Application.php @@ -29,9 +29,9 @@ */ class Application extends BaseApplication { - private $kernel; - private $commandsRegistered = false; - private $registrationErrors = []; + private KernelInterface $kernel; + private bool $commandsRegistered = false; + private array $registrationErrors = []; public function __construct(KernelInterface $kernel) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php index 581395efd0035..7f1b4d01ab3c6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php @@ -37,7 +37,7 @@ */ class TextDescriptor extends Descriptor { - private $fileLinkFormatter; + private ?FileLinkFormatter $fileLinkFormatter; public function __construct(FileLinkFormatter $fileLinkFormatter = null) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php index edb2f57920f69..992fc802231fc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php @@ -27,9 +27,9 @@ */ class RedirectController { - private $router; - private $httpPort; - private $httpsPort; + private ?UrlGeneratorInterface $router; + private ?int $httpPort; + private ?int $httpsPort; public function __construct(UrlGeneratorInterface $router = null, int $httpPort = null, int $httpsPort = null) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php index 2283dbc91fccf..4aacf24fc05a7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php @@ -23,7 +23,7 @@ */ class TemplateController { - private $twig; + private ?Environment $twig; public function __construct(Environment $twig = null) { 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/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index f766c28ab0f37..3bb0f079b8586 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -46,7 +46,7 @@ */ class Configuration implements ConfigurationInterface { - private $debug; + private bool $debug; /** * @param bool $debug Whether debugging is enabled or not diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index ec2e29a5574b6..a4ca9fd1d1950 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -216,17 +216,17 @@ */ class FrameworkExtension extends Extension { - private $formConfigEnabled = false; - private $translationConfigEnabled = false; - private $sessionConfigEnabled = false; - private $annotationsConfigEnabled = false; - private $validatorConfigEnabled = false; - private $messengerConfigEnabled = false; - private $mailerConfigEnabled = false; - private $httpClientConfigEnabled = false; - private $notifierConfigEnabled = false; - private $propertyAccessConfigEnabled = false; - private static $lockConfigEnabled = false; + private bool $formConfigEnabled = false; + private bool $translationConfigEnabled = false; + private bool $sessionConfigEnabled = false; + private bool $annotationsConfigEnabled = false; + private bool $validatorConfigEnabled = false; + private bool $messengerConfigEnabled = false; + private bool $mailerConfigEnabled = false; + private bool $httpClientConfigEnabled = false; + private bool $notifierConfigEnabled = false; + private bool $propertyAccessConfigEnabled = false; + private static bool $lockConfigEnabled = false; /** * Responds to the app.config configuration parameter. diff --git a/src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php b/src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php index ebae8d3768c00..102892b2f426c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php +++ b/src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php @@ -30,9 +30,9 @@ class HttpCache extends BaseHttpCache protected $cacheDir; protected $kernel; - private $store; - private $surrogate; - private $options; + private ?StoreInterface $store = null; + private ?SurrogateInterface $surrogate; + private array $options; /** * @param $cache The cache directory (default used if null) or the storage instance diff --git a/src/Symfony/Bundle/FrameworkBundle/KernelBrowser.php b/src/Symfony/Bundle/FrameworkBundle/KernelBrowser.php index 1480f43a68b5c..fff42100a9ade 100644 --- a/src/Symfony/Bundle/FrameworkBundle/KernelBrowser.php +++ b/src/Symfony/Bundle/FrameworkBundle/KernelBrowser.php @@ -30,9 +30,9 @@ */ class KernelBrowser extends HttpKernelBrowser { - private $hasPerformedRequest = false; - private $profiler = false; - private $reboot = true; + private bool $hasPerformedRequest = false; + private bool $profiler = false; + private bool $reboot = true; /** * {@inheritdoc} 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/DelegatingLoader.php b/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php index d55e04167af65..a0fefe7fd2fab 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php +++ b/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php @@ -28,9 +28,9 @@ */ class DelegatingLoader extends BaseDelegatingLoader { - private $loading = false; - private $defaultOptions; - private $defaultRequirements; + private bool $loading = false; + private array $defaultOptions; + private array $defaultRequirements; public function __construct(LoaderResolverInterface $resolver, array $defaultOptions = [], array $defaultRequirements = []) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php b/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php index 2942d5d14879c..b213019d3579a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php +++ b/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php @@ -33,9 +33,9 @@ */ class Router extends BaseRouter implements WarmableInterface, ServiceSubscriberInterface { - private $container; - private $collectedParameters = []; - private $paramFetcher; + private ContainerInterface $container; + private array $collectedParameters = []; + private \Closure $paramFetcher; /** * @param mixed $resource The main resource to load @@ -49,9 +49,9 @@ public function __construct(ContainerInterface $container, mixed $resource, arra $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/Secrets/DotenvVault.php b/src/Symfony/Bundle/FrameworkBundle/Secrets/DotenvVault.php index 7c6f6987e291c..4fa7c40bf8d72 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Secrets/DotenvVault.php +++ b/src/Symfony/Bundle/FrameworkBundle/Secrets/DotenvVault.php @@ -18,7 +18,7 @@ */ class DotenvVault extends AbstractVault { - private $dotenvFile; + private string $dotenvFile; public function __construct(string $dotenvFile) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Secrets/SodiumVault.php b/src/Symfony/Bundle/FrameworkBundle/Secrets/SodiumVault.php index 3935a2ac7f5ec..0837ec7fdf241 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Secrets/SodiumVault.php +++ b/src/Symfony/Bundle/FrameworkBundle/Secrets/SodiumVault.php @@ -23,10 +23,10 @@ */ class SodiumVault extends AbstractVault implements EnvVarLoaderInterface { - private $encryptionKey; - private $decryptionKey; - private $pathPrefix; - private $secretsDir; + private ?string $encryptionKey = null; + private string|\Stringable|null $decryptionKey = null; + private string $pathPrefix; + private ?string $secretsDir; /** * @param $decryptionKey A string or a stringable object that defines the private key to use to decrypt the vault diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php b/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php index ae1b563c68ee7..ba02c761d73dc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php +++ b/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php @@ -35,7 +35,7 @@ abstract class KernelTestCase extends TestCase protected static $booted = false; - private static $kernelContainer; + private static ?ContainerInterface $kernelContainer = null; protected function tearDown(): void { diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/TestBrowserToken.php b/src/Symfony/Bundle/FrameworkBundle/Test/TestBrowserToken.php index 6d3c99039b0d8..8bf365eb06380 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Test/TestBrowserToken.php +++ b/src/Symfony/Bundle/FrameworkBundle/Test/TestBrowserToken.php @@ -21,7 +21,7 @@ */ class TestBrowserToken extends AbstractToken { - private $firewallName; + private string $firewallName; public function __construct(array $roles = [], UserInterface $user = null, string $firewallName = 'main') { diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/TestContainer.php b/src/Symfony/Bundle/FrameworkBundle/Test/TestContainer.php index 04f5c9a2b05fa..4ce5772d91e63 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Test/TestContainer.php +++ b/src/Symfony/Bundle/FrameworkBundle/Test/TestContainer.php @@ -28,8 +28,8 @@ */ class TestContainer extends Container { - private $kernel; - private $privateServicesLocatorId; + private KernelInterface $kernel; + private string $privateServicesLocatorId; public function __construct(KernelInterface $kernel, string $privateServicesLocatorId) { 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 4b7736032e543..b4d9a664a5e02 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php +++ b/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php @@ -36,29 +36,32 @@ class Translator extends BaseTranslator implements WarmableInterface ]; /** - * @var array + * @var list */ - private $resourceLocales; + private array $resourceLocales; /** * Holds parameters from addResource() calls so we can defer the actual * parent::addResource() calls until initialize() is executed. * - * @var array + * @var array[] */ - private $resources = []; + private array $resources = []; - private $resourceFiles; + /** + * @var string[][] + */ + private array $resourceFiles; /** * @var string[] */ - private $scannedDirectories; + private array $scannedDirectories; /** * @var string[] */ - private $enabledLocales; + private array $enabledLocales; /** * Constructor. @@ -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);