From cde1dab5eefff1d0785e233d82704699b7cd5aa8 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 2 Jan 2024 11:13:48 +0100 Subject: [PATCH 01/10] append instead of replacing potentially non-existent named-arguments --- DependencyInjection/FrameworkExtension.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/DependencyInjection/FrameworkExtension.php b/DependencyInjection/FrameworkExtension.php index 7529acd60..842066954 100644 --- a/DependencyInjection/FrameworkExtension.php +++ b/DependencyInjection/FrameworkExtension.php @@ -2594,27 +2594,27 @@ private function registerNotifierConfiguration(array $config, ContainerBuilder $ if (ContainerBuilder::willBeAvailable('symfony/mercure-notifier', MercureTransportFactory::class, $parentPackages, true) && ContainerBuilder::willBeAvailable('symfony/mercure-bundle', MercureBundle::class, $parentPackages, true) && \in_array(MercureBundle::class, $container->getParameter('kernel.bundles'), true)) { $container->getDefinition($classToServices[MercureTransportFactory::class]) - ->replaceArgument('$registry', new Reference(HubRegistry::class)) - ->replaceArgument('$client', new Reference('http_client', ContainerBuilder::NULL_ON_INVALID_REFERENCE)) - ->replaceArgument('$dispatcher', new Reference('event_dispatcher', ContainerBuilder::NULL_ON_INVALID_REFERENCE)); + ->replaceArgument(0, new Reference(HubRegistry::class)) + ->replaceArgument(1, new Reference('event_dispatcher', ContainerBuilder::NULL_ON_INVALID_REFERENCE)) + ->addArgument(new Reference('http_client', ContainerBuilder::NULL_ON_INVALID_REFERENCE)); } elseif (ContainerBuilder::willBeAvailable('symfony/mercure-notifier', MercureTransportFactory::class, $parentPackages, true)) { $container->removeDefinition($classToServices[MercureTransportFactory::class]); } if (ContainerBuilder::willBeAvailable('symfony/fake-chat-notifier', FakeChatTransportFactory::class, ['symfony/framework-bundle', 'symfony/notifier', 'symfony/mailer'], true)) { $container->getDefinition($classToServices[FakeChatTransportFactory::class]) - ->replaceArgument('$mailer', new Reference('mailer')) - ->replaceArgument('$logger', new Reference('logger')) - ->replaceArgument('$client', new Reference('http_client', ContainerBuilder::NULL_ON_INVALID_REFERENCE)) - ->replaceArgument('$dispatcher', new Reference('event_dispatcher', ContainerBuilder::NULL_ON_INVALID_REFERENCE)); + ->replaceArgument(0, new Reference('mailer')) + ->replaceArgument(1, new Reference('logger')) + ->addArgument(new Reference('event_dispatcher', ContainerBuilder::NULL_ON_INVALID_REFERENCE)) + ->addArgument(new Reference('http_client', ContainerBuilder::NULL_ON_INVALID_REFERENCE)); } if (ContainerBuilder::willBeAvailable('symfony/fake-sms-notifier', FakeSmsTransportFactory::class, ['symfony/framework-bundle', 'symfony/notifier', 'symfony/mailer'], true)) { $container->getDefinition($classToServices[FakeSmsTransportFactory::class]) - ->replaceArgument('$mailer', new Reference('mailer')) - ->replaceArgument('$logger', new Reference('logger')) - ->replaceArgument('$client', new Reference('http_client', ContainerBuilder::NULL_ON_INVALID_REFERENCE)) - ->replaceArgument('$dispatcher', new Reference('event_dispatcher', ContainerBuilder::NULL_ON_INVALID_REFERENCE)); + ->replaceArgument(0, new Reference('mailer')) + ->replaceArgument(1, new Reference('logger')) + ->addArgument(new Reference('event_dispatcher', ContainerBuilder::NULL_ON_INVALID_REFERENCE)) + ->addArgument(new Reference('http_client', ContainerBuilder::NULL_ON_INVALID_REFERENCE)); } if (isset($config['admin_recipients'])) { From 60512ffab83561e045afe0e05739f082dfca0542 Mon Sep 17 00:00:00 2001 From: valtzu Date: Sun, 3 Dec 2023 13:43:58 +0200 Subject: [PATCH 02/10] [Scheduler] Separate id and description in message providers --- Tests/Fixtures/Messenger/DummyTask.php | 3 +++ Tests/Functional/SchedulerTest.php | 1 + 2 files changed, 4 insertions(+) diff --git a/Tests/Fixtures/Messenger/DummyTask.php b/Tests/Fixtures/Messenger/DummyTask.php index 94773b4e1..06cadadef 100644 --- a/Tests/Fixtures/Messenger/DummyTask.php +++ b/Tests/Fixtures/Messenger/DummyTask.php @@ -9,6 +9,9 @@ #[AsCronTask(expression: '0 * * * *', timezone: 'Europe/Berlin', arguments: ['2'], schedule: 'dummy_task', method: 'method2')] #[AsPeriodicTask(frequency: 5, arguments: [3], schedule: 'dummy_task')] #[AsPeriodicTask(frequency: '1 day', from: '2023-10-25 09:59:00Z', jitter: 60, arguments: ['4'], schedule: 'dummy_task', method: 'method4')] +#[AsPeriodicTask(frequency: '1 day', from: '2023-10-25 09:59:00Z', arguments: ['9'], schedule: 'dummy_task', method: 'method5')] +#[AsPeriodicTask(frequency: '1 day', from: '2023-10-25 09:59:00Z', arguments: ['9b'], schedule: 'dummy_task', method: 'method5')] +#[AsPeriodicTask(frequency: '1 day', from: '2023-10-25 09:59:00Z', arguments: ['named' => '9'], schedule: 'dummy_task', method: 'method5')] class DummyTask { public static array $calls = []; diff --git a/Tests/Functional/SchedulerTest.php b/Tests/Functional/SchedulerTest.php index 7b3cd197d..7f737a4c4 100644 --- a/Tests/Functional/SchedulerTest.php +++ b/Tests/Functional/SchedulerTest.php @@ -84,6 +84,7 @@ public function testAutoconfiguredScheduler() $this->assertCount(779, $calls['__invoke']); $this->assertSame([['2']], $calls['method2']); $this->assertSame([['4']], $calls['method4']); + $this->assertSame([['9'], ['9b'], ['named' => '9']], $calls['method5']); $this->assertSame([['5', 6], ['7', 8]], $calls['attributesOnMethod']); } From a1313b750f73badf71d130980c90b8403b770b70 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 3 Jan 2024 08:23:18 +0100 Subject: [PATCH 03/10] fix lowest deps --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 3aedebd74..afb7c2069 100644 --- a/composer.json +++ b/composer.json @@ -57,7 +57,7 @@ "symfony/notifier": "^5.4|^6.0|^7.0", "symfony/process": "^5.4|^6.0|^7.0", "symfony/rate-limiter": "^5.4|^6.0|^7.0", - "symfony/scheduler": "^6.4|^7.0", + "symfony/scheduler": "^6.4.3|^7.0.3", "symfony/security-bundle": "^5.4|^6.0|^7.0", "symfony/semaphore": "^5.4|^6.0|^7.0", "symfony/serializer": "^6.4|^7.0", @@ -93,7 +93,7 @@ "symfony/mime": "<6.4", "symfony/property-info": "<5.4", "symfony/property-access": "<5.4", - "symfony/scheduler": "<6.4", + "symfony/scheduler": "<6.4.3|>=7.0.0,<7.0.3", "symfony/serializer": "<6.4", "symfony/security-csrf": "<5.4", "symfony/security-core": "<5.4", From ef3dea3e0cc0ccd5f79add84847b3a4411a193fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Andr=C3=A9?= Date: Thu, 4 Jan 2024 15:06:27 +0100 Subject: [PATCH 04/10] [Notifier] Fix FrameworkExtension factory classes (MessageBird & TurboSms) --- DependencyInjection/FrameworkExtension.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DependencyInjection/FrameworkExtension.php b/DependencyInjection/FrameworkExtension.php index 00abd6080..ba542ddd9 100644 --- a/DependencyInjection/FrameworkExtension.php +++ b/DependencyInjection/FrameworkExtension.php @@ -138,7 +138,7 @@ use Symfony\Component\Notifier\Bridge\Mailjet\MailjetTransportFactory as MailjetNotifierTransportFactory; use Symfony\Component\Notifier\Bridge\Mattermost\MattermostTransportFactory; use Symfony\Component\Notifier\Bridge\Mercure\MercureTransportFactory; -use Symfony\Component\Notifier\Bridge\MessageBird\MessageBirdTransport; +use Symfony\Component\Notifier\Bridge\MessageBird\MessageBirdTransportFactory; use Symfony\Component\Notifier\Bridge\MessageMedia\MessageMediaTransportFactory; use Symfony\Component\Notifier\Bridge\MicrosoftTeams\MicrosoftTeamsTransportFactory; use Symfony\Component\Notifier\Bridge\Mobyt\MobytTransportFactory; @@ -157,7 +157,7 @@ use Symfony\Component\Notifier\Bridge\SpotHit\SpotHitTransportFactory; use Symfony\Component\Notifier\Bridge\Telegram\TelegramTransportFactory; use Symfony\Component\Notifier\Bridge\Telnyx\TelnyxTransportFactory; -use Symfony\Component\Notifier\Bridge\TurboSms\TurboSmsTransport; +use Symfony\Component\Notifier\Bridge\TurboSms\TurboSmsTransportFactory; use Symfony\Component\Notifier\Bridge\Twilio\TwilioTransportFactory; use Symfony\Component\Notifier\Bridge\Vonage\VonageTransportFactory; use Symfony\Component\Notifier\Bridge\Yunpian\YunpianTransportFactory; @@ -2555,7 +2555,7 @@ private function registerNotifierConfiguration(array $config, ContainerBuilder $ MailjetNotifierTransportFactory::class => 'notifier.transport_factory.mailjet', MattermostTransportFactory::class => 'notifier.transport_factory.mattermost', MercureTransportFactory::class => 'notifier.transport_factory.mercure', - MessageBirdTransport::class => 'notifier.transport_factory.message-bird', + MessageBirdTransportFactory::class => 'notifier.transport_factory.message-bird', MessageMediaTransportFactory::class => 'notifier.transport_factory.message-media', MicrosoftTeamsTransportFactory::class => 'notifier.transport_factory.microsoft-teams', MobytTransportFactory::class => 'notifier.transport_factory.mobyt', @@ -2574,7 +2574,7 @@ private function registerNotifierConfiguration(array $config, ContainerBuilder $ SpotHitTransportFactory::class => 'notifier.transport_factory.spot-hit', TelegramTransportFactory::class => 'notifier.transport_factory.telegram', TelnyxTransportFactory::class => 'notifier.transport_factory.telnyx', - TurboSmsTransport::class => 'notifier.transport_factory.turbo-sms', + TurboSmsTransportFactory::class => 'notifier.transport_factory.turbo-sms', TwilioTransportFactory::class => 'notifier.transport_factory.twilio', VonageTransportFactory::class => 'notifier.transport_factory.vonage', YunpianTransportFactory::class => 'notifier.transport_factory.yunpian', From 40a4b5b7c33b3e096172c2e5cc3b1eb47f2ca39a Mon Sep 17 00:00:00 2001 From: JoppeDC Date: Wed, 17 Jan 2024 10:14:38 +0100 Subject: [PATCH 05/10] Fix broken link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 14c600fac..220d72a8a 100644 --- a/README.md +++ b/README.md @@ -17,4 +17,4 @@ Resources [send Pull Requests](https://github.com/symfony/symfony/pulls) in the [main Symfony repository](https://github.com/symfony/symfony) -[3]: https://symfony.com/sponsor +[1]: https://symfony.com/sponsor From 23f67d6b4142816475289353ffcfc1d25e9c9981 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 22 Jan 2024 09:33:52 +0100 Subject: [PATCH 06/10] grab a service from the container only if it exists --- Command/CachePoolClearCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Command/CachePoolClearCommand.php b/Command/CachePoolClearCommand.php index 5569a5ab1..c5f34deec 100644 --- a/Command/CachePoolClearCommand.php +++ b/Command/CachePoolClearCommand.php @@ -70,7 +70,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $clearers = []; $poolNames = $input->getArgument('pools'); - if ($input->getOption('all')) { + if ($clearAll = $input->getOption('all')) { if (!$this->poolNames) { throw new InvalidArgumentException('Could not clear all cache pools, try specifying a specific pool or cache clearer.'); } @@ -84,7 +84,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int foreach ($poolNames as $id) { if ($this->poolClearer->hasPool($id)) { $pools[$id] = $id; - } else { + } elseif (!$clearAll || $kernel->getContainer()->has($id)) { $pool = $kernel->getContainer()->get($id); if ($pool instanceof CacheItemPoolInterface) { From 9f39bd6765360a670db4f4c38ad18206a923e293 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 23 Jan 2024 14:51:25 +0100 Subject: [PATCH 07/10] Apply php-cs-fixer fix --rules nullable_type_declaration_for_default_null_value --- CacheWarmer/AnnotationsCacheWarmer.php | 2 +- CacheWarmer/ConfigBuilderCacheWarmer.php | 2 +- Command/CacheClearCommand.php | 2 +- Command/CachePoolClearCommand.php | 2 +- Command/CachePoolDeleteCommand.php | 2 +- Command/DebugAutowiringCommand.php | 2 +- Command/RouterDebugCommand.php | 2 +- Command/SecretsDecryptToLocalCommand.php | 2 +- Command/SecretsEncryptFromLocalCommand.php | 2 +- Command/SecretsGenerateKeysCommand.php | 2 +- Command/SecretsListCommand.php | 2 +- Command/SecretsRemoveCommand.php | 2 +- Command/SecretsSetCommand.php | 2 +- Command/TranslationDebugCommand.php | 2 +- Command/TranslationUpdateCommand.php | 2 +- Console/Application.php | 2 +- Console/Descriptor/Descriptor.php | 6 +++--- Console/Descriptor/JsonDescriptor.php | 4 ++-- Console/Descriptor/MarkdownDescriptor.php | 4 ++-- Console/Descriptor/TextDescriptor.php | 8 ++++---- Console/Descriptor/XmlDescriptor.php | 14 +++++++------- Console/Helper/DescriptorHelper.php | 2 +- Controller/AbstractController.php | 12 ++++++------ Controller/RedirectController.php | 4 ++-- Controller/TemplateController.php | 6 +++--- DependencyInjection/Configuration.php | 2 +- HttpCache/HttpCache.php | 4 ++-- KernelBrowser.php | 2 +- Routing/DelegatingLoader.php | 2 +- Routing/RedirectableCompiledUrlMatcher.php | 2 +- Routing/Router.php | 2 +- Test/BrowserKitAssertionsTrait.php | 16 ++++++++-------- Test/MailerAssertionsTrait.php | 12 ++++++------ Test/TestBrowserToken.php | 2 +- Tests/Command/TranslationDebugCommandTest.php | 4 ++-- .../TranslationUpdateCommandCompletionTest.php | 2 +- Tests/Command/TranslationUpdateCommandTest.php | 2 +- Tests/Controller/ControllerResolverTest.php | 4 ++-- .../Compiler/DataCollectorTranslatorPassTest.php | 2 +- .../Compiler/ProfilerPassTest.php | 4 ++-- .../FrameworkExtensionTestCase.php | 2 +- .../AutowiringTypes/AutowiredServices.php | 2 +- .../Controller/AnnotatedController.php | 2 +- Translation/Translator.php | 2 +- 44 files changed, 81 insertions(+), 81 deletions(-) diff --git a/CacheWarmer/AnnotationsCacheWarmer.php b/CacheWarmer/AnnotationsCacheWarmer.php index 550440017..9c6ac5fe0 100644 --- a/CacheWarmer/AnnotationsCacheWarmer.php +++ b/CacheWarmer/AnnotationsCacheWarmer.php @@ -32,7 +32,7 @@ class AnnotationsCacheWarmer extends AbstractPhpFileCacheWarmer /** * @param string $phpArrayFile The PHP file where annotations are cached */ - public function __construct(Reader $annotationReader, string $phpArrayFile, string $excludeRegexp = null, bool $debug = false) + public function __construct(Reader $annotationReader, string $phpArrayFile, ?string $excludeRegexp = null, bool $debug = false) { parent::__construct($phpArrayFile); $this->annotationReader = $annotationReader; diff --git a/CacheWarmer/ConfigBuilderCacheWarmer.php b/CacheWarmer/ConfigBuilderCacheWarmer.php index 50843f526..aabb0061e 100644 --- a/CacheWarmer/ConfigBuilderCacheWarmer.php +++ b/CacheWarmer/ConfigBuilderCacheWarmer.php @@ -31,7 +31,7 @@ class ConfigBuilderCacheWarmer implements CacheWarmerInterface private $kernel; private $logger; - public function __construct(KernelInterface $kernel, LoggerInterface $logger = null) + public function __construct(KernelInterface $kernel, ?LoggerInterface $logger = null) { $this->kernel = $kernel; $this->logger = $logger; diff --git a/Command/CacheClearCommand.php b/Command/CacheClearCommand.php index 4d2d84223..4be5c2c98 100644 --- a/Command/CacheClearCommand.php +++ b/Command/CacheClearCommand.php @@ -41,7 +41,7 @@ class CacheClearCommand extends Command private $cacheClearer; private $filesystem; - public function __construct(CacheClearerInterface $cacheClearer, Filesystem $filesystem = null) + public function __construct(CacheClearerInterface $cacheClearer, ?Filesystem $filesystem = null) { parent::__construct(); diff --git a/Command/CachePoolClearCommand.php b/Command/CachePoolClearCommand.php index b72924dfa..21ac705ee 100644 --- a/Command/CachePoolClearCommand.php +++ b/Command/CachePoolClearCommand.php @@ -38,7 +38,7 @@ final class CachePoolClearCommand extends Command /** * @param string[]|null $poolNames */ - public function __construct(Psr6CacheClearer $poolClearer, array $poolNames = null) + public function __construct(Psr6CacheClearer $poolClearer, ?array $poolNames = null) { parent::__construct(); diff --git a/Command/CachePoolDeleteCommand.php b/Command/CachePoolDeleteCommand.php index b36d48cfe..e43966543 100644 --- a/Command/CachePoolDeleteCommand.php +++ b/Command/CachePoolDeleteCommand.php @@ -36,7 +36,7 @@ final class CachePoolDeleteCommand extends Command /** * @param string[]|null $poolNames */ - public function __construct(Psr6CacheClearer $poolClearer, array $poolNames = null) + public function __construct(Psr6CacheClearer $poolClearer, ?array $poolNames = null) { parent::__construct(); diff --git a/Command/DebugAutowiringCommand.php b/Command/DebugAutowiringCommand.php index e1e3c9534..478509a5c 100644 --- a/Command/DebugAutowiringCommand.php +++ b/Command/DebugAutowiringCommand.php @@ -37,7 +37,7 @@ class DebugAutowiringCommand extends ContainerDebugCommand private $supportsHref; private $fileLinkFormatter; - public function __construct(string $name = null, FileLinkFormatter $fileLinkFormatter = null) + public function __construct(?string $name = null, ?FileLinkFormatter $fileLinkFormatter = null) { $this->supportsHref = method_exists(OutputFormatterStyle::class, 'setHref'); $this->fileLinkFormatter = $fileLinkFormatter; diff --git a/Command/RouterDebugCommand.php b/Command/RouterDebugCommand.php index cf929f987..bb1eff1ab 100644 --- a/Command/RouterDebugCommand.php +++ b/Command/RouterDebugCommand.php @@ -42,7 +42,7 @@ class RouterDebugCommand extends Command private $router; private $fileLinkFormatter; - public function __construct(RouterInterface $router, FileLinkFormatter $fileLinkFormatter = null) + public function __construct(RouterInterface $router, ?FileLinkFormatter $fileLinkFormatter = null) { parent::__construct(); diff --git a/Command/SecretsDecryptToLocalCommand.php b/Command/SecretsDecryptToLocalCommand.php index 0e07d88fa..24bb242d9 100644 --- a/Command/SecretsDecryptToLocalCommand.php +++ b/Command/SecretsDecryptToLocalCommand.php @@ -32,7 +32,7 @@ final class SecretsDecryptToLocalCommand extends Command private $vault; private $localVault; - public function __construct(AbstractVault $vault, AbstractVault $localVault = null) + public function __construct(AbstractVault $vault, ?AbstractVault $localVault = null) { $this->vault = $vault; $this->localVault = $localVault; diff --git a/Command/SecretsEncryptFromLocalCommand.php b/Command/SecretsEncryptFromLocalCommand.php index 79f51c51a..1e5edcfbb 100644 --- a/Command/SecretsEncryptFromLocalCommand.php +++ b/Command/SecretsEncryptFromLocalCommand.php @@ -31,7 +31,7 @@ final class SecretsEncryptFromLocalCommand extends Command private $vault; private $localVault; - public function __construct(AbstractVault $vault, AbstractVault $localVault = null) + public function __construct(AbstractVault $vault, ?AbstractVault $localVault = null) { $this->vault = $vault; $this->localVault = $localVault; diff --git a/Command/SecretsGenerateKeysCommand.php b/Command/SecretsGenerateKeysCommand.php index a9440b4c8..f2c2a3cfe 100644 --- a/Command/SecretsGenerateKeysCommand.php +++ b/Command/SecretsGenerateKeysCommand.php @@ -34,7 +34,7 @@ final class SecretsGenerateKeysCommand extends Command private $vault; private $localVault; - public function __construct(AbstractVault $vault, AbstractVault $localVault = null) + public function __construct(AbstractVault $vault, ?AbstractVault $localVault = null) { $this->vault = $vault; $this->localVault = $localVault; diff --git a/Command/SecretsListCommand.php b/Command/SecretsListCommand.php index 0b13e0cf2..7dd826e31 100644 --- a/Command/SecretsListCommand.php +++ b/Command/SecretsListCommand.php @@ -35,7 +35,7 @@ final class SecretsListCommand extends Command private $vault; private $localVault; - public function __construct(AbstractVault $vault, AbstractVault $localVault = null) + public function __construct(AbstractVault $vault, ?AbstractVault $localVault = null) { $this->vault = $vault; $this->localVault = $localVault; diff --git a/Command/SecretsRemoveCommand.php b/Command/SecretsRemoveCommand.php index 0451ef300..5be85e45d 100644 --- a/Command/SecretsRemoveCommand.php +++ b/Command/SecretsRemoveCommand.php @@ -36,7 +36,7 @@ final class SecretsRemoveCommand extends Command private $vault; private $localVault; - public function __construct(AbstractVault $vault, AbstractVault $localVault = null) + public function __construct(AbstractVault $vault, ?AbstractVault $localVault = null) { $this->vault = $vault; $this->localVault = $localVault; diff --git a/Command/SecretsSetCommand.php b/Command/SecretsSetCommand.php index 412247da7..e96b83886 100644 --- a/Command/SecretsSetCommand.php +++ b/Command/SecretsSetCommand.php @@ -37,7 +37,7 @@ final class SecretsSetCommand extends Command private $vault; private $localVault; - public function __construct(AbstractVault $vault, AbstractVault $localVault = null) + public function __construct(AbstractVault $vault, ?AbstractVault $localVault = null) { $this->vault = $vault; $this->localVault = $localVault; diff --git a/Command/TranslationDebugCommand.php b/Command/TranslationDebugCommand.php index 006fd2505..12155a646 100644 --- a/Command/TranslationDebugCommand.php +++ b/Command/TranslationDebugCommand.php @@ -60,7 +60,7 @@ class TranslationDebugCommand extends Command private $codePaths; private $enabledLocales; - public function __construct(TranslatorInterface $translator, TranslationReaderInterface $reader, ExtractorInterface $extractor, string $defaultTransPath = null, string $defaultViewsPath = null, array $transPaths = [], array $codePaths = [], array $enabledLocales = []) + public function __construct(TranslatorInterface $translator, TranslationReaderInterface $reader, ExtractorInterface $extractor, ?string $defaultTransPath = null, ?string $defaultViewsPath = null, array $transPaths = [], array $codePaths = [], array $enabledLocales = []) { parent::__construct(); diff --git a/Command/TranslationUpdateCommand.php b/Command/TranslationUpdateCommand.php index 7adc0b4bb..634c5be09 100644 --- a/Command/TranslationUpdateCommand.php +++ b/Command/TranslationUpdateCommand.php @@ -61,7 +61,7 @@ class TranslationUpdateCommand extends Command private $codePaths; private $enabledLocales; - public function __construct(TranslationWriterInterface $writer, TranslationReaderInterface $reader, ExtractorInterface $extractor, string $defaultLocale, string $defaultTransPath = null, string $defaultViewsPath = null, array $transPaths = [], array $codePaths = [], 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 = []) { parent::__construct(); diff --git a/Console/Application.php b/Console/Application.php index 7fe7bc937..1bd56cc7a 100644 --- a/Console/Application.php +++ b/Console/Application.php @@ -135,7 +135,7 @@ public function get(string $name) /** * {@inheritdoc} */ - public function all(string $namespace = null) + public function all(?string $namespace = null) { $this->registerCommands(); diff --git a/Console/Descriptor/Descriptor.php b/Console/Descriptor/Descriptor.php index 537d6d08c..d3b3b6896 100644 --- a/Console/Descriptor/Descriptor.php +++ b/Console/Descriptor/Descriptor.php @@ -113,7 +113,7 @@ abstract protected function describeContainerTags(ContainerBuilder $builder, arr * * @param Definition|Alias|object $service */ - abstract protected function describeContainerService(object $service, array $options = [], ContainerBuilder $builder = null); + abstract protected function describeContainerService(object $service, array $options = [], ?ContainerBuilder $builder = null); /** * Describes container services. @@ -127,7 +127,7 @@ abstract protected function describeContainerDeprecations(ContainerBuilder $buil abstract protected function describeContainerDefinition(Definition $definition, array $options = []); - abstract protected function describeContainerAlias(Alias $alias, array $options = [], ContainerBuilder $builder = null); + abstract protected function describeContainerAlias(Alias $alias, array $options = [], ?ContainerBuilder $builder = null); abstract protected function describeContainerParameter($parameter, array $options = []); @@ -304,7 +304,7 @@ protected function sortByPriority(array $tag): array return $tag; } - public static function getClassDescription(string $class, string &$resolvedClass = null): string + public static function getClassDescription(string $class, ?string &$resolvedClass = null): string { $resolvedClass = $class; try { diff --git a/Console/Descriptor/JsonDescriptor.php b/Console/Descriptor/JsonDescriptor.php index 0ad063343..585af1eef 100644 --- a/Console/Descriptor/JsonDescriptor.php +++ b/Console/Descriptor/JsonDescriptor.php @@ -67,7 +67,7 @@ protected function describeContainerTags(ContainerBuilder $builder, array $optio $this->writeData($data, $options); } - protected function describeContainerService(object $service, array $options = [], ContainerBuilder $builder = null) + protected function describeContainerService(object $service, array $options = [], ?ContainerBuilder $builder = null) { if (!isset($options['id'])) { throw new \InvalidArgumentException('An "id" option must be provided.'); @@ -120,7 +120,7 @@ protected function describeContainerDefinition(Definition $definition, array $op $this->writeData($this->getContainerDefinitionData($definition, isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments']), $options); } - protected function describeContainerAlias(Alias $alias, array $options = [], ContainerBuilder $builder = null) + protected function describeContainerAlias(Alias $alias, array $options = [], ?ContainerBuilder $builder = null) { if (!$builder) { $this->writeData($this->getContainerAliasData($alias), $options); diff --git a/Console/Descriptor/MarkdownDescriptor.php b/Console/Descriptor/MarkdownDescriptor.php index a3fbabc6d..f23be9d57 100644 --- a/Console/Descriptor/MarkdownDescriptor.php +++ b/Console/Descriptor/MarkdownDescriptor.php @@ -88,7 +88,7 @@ protected function describeContainerTags(ContainerBuilder $builder, array $optio } } - protected function describeContainerService(object $service, array $options = [], ContainerBuilder $builder = null) + protected function describeContainerService(object $service, array $options = [], ?ContainerBuilder $builder = null) { if (!isset($options['id'])) { throw new \InvalidArgumentException('An "id" option must be provided.'); @@ -253,7 +253,7 @@ protected function describeContainerDefinition(Definition $definition, array $op $this->write(isset($options['id']) ? sprintf("### %s\n\n%s\n", $options['id'], $output) : $output); } - protected function describeContainerAlias(Alias $alias, array $options = [], ContainerBuilder $builder = null) + protected function describeContainerAlias(Alias $alias, array $options = [], ?ContainerBuilder $builder = null) { $output = '- Service: `'.$alias.'`' ."\n".'- Public: '.($alias->isPublic() && !$alias->isPrivate() ? 'yes' : 'no'); diff --git a/Console/Descriptor/TextDescriptor.php b/Console/Descriptor/TextDescriptor.php index e7eb18762..56bb0fbd9 100644 --- a/Console/Descriptor/TextDescriptor.php +++ b/Console/Descriptor/TextDescriptor.php @@ -39,7 +39,7 @@ class TextDescriptor extends Descriptor { private $fileLinkFormatter; - public function __construct(FileLinkFormatter $fileLinkFormatter = null) + public function __construct(?FileLinkFormatter $fileLinkFormatter = null) { $this->fileLinkFormatter = $fileLinkFormatter; } @@ -141,7 +141,7 @@ protected function describeContainerTags(ContainerBuilder $builder, array $optio } } - protected function describeContainerService(object $service, array $options = [], ContainerBuilder $builder = null) + protected function describeContainerService(object $service, array $options = [], ?ContainerBuilder $builder = null) { if (!isset($options['id'])) { throw new \InvalidArgumentException('An "id" option must be provided.'); @@ -389,7 +389,7 @@ protected function describeContainerDeprecations(ContainerBuilder $builder, arra $options['output']->listing($formattedLogs); } - protected function describeContainerAlias(Alias $alias, array $options = [], ContainerBuilder $builder = null) + protected function describeContainerAlias(Alias $alias, array $options = [], ?ContainerBuilder $builder = null) { if ($alias->isPublic() && !$alias->isPrivate()) { $options['output']->comment(sprintf('This service is a public alias for the service %s', (string) $alias)); @@ -541,7 +541,7 @@ private function formatRouterConfig(array $config): string return trim($configAsString); } - private function formatControllerLink($controller, string $anchorText, callable $getContainer = null): string + private function formatControllerLink($controller, string $anchorText, ?callable $getContainer = null): string { if (null === $this->fileLinkFormatter) { return $anchorText; diff --git a/Console/Descriptor/XmlDescriptor.php b/Console/Descriptor/XmlDescriptor.php index 350452f33..56b1af9bf 100644 --- a/Console/Descriptor/XmlDescriptor.php +++ b/Console/Descriptor/XmlDescriptor.php @@ -53,7 +53,7 @@ protected function describeContainerTags(ContainerBuilder $builder, array $optio $this->writeDocument($this->getContainerTagsDocument($builder, isset($options['show_hidden']) && $options['show_hidden'])); } - protected function describeContainerService(object $service, array $options = [], ContainerBuilder $builder = null) + protected function describeContainerService(object $service, array $options = [], ?ContainerBuilder $builder = null) { if (!isset($options['id'])) { throw new \InvalidArgumentException('An "id" option must be provided.'); @@ -72,7 +72,7 @@ protected function describeContainerDefinition(Definition $definition, array $op $this->writeDocument($this->getContainerDefinitionDocument($definition, $options['id'] ?? null, isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments'])); } - protected function describeContainerAlias(Alias $alias, array $options = [], ContainerBuilder $builder = null) + protected function describeContainerAlias(Alias $alias, array $options = [], ?ContainerBuilder $builder = null) { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($dom->importNode($this->getContainerAliasDocument($alias, $options['id'] ?? null)->childNodes->item(0), true)); @@ -155,7 +155,7 @@ private function getRouteCollectionDocument(RouteCollection $routes): \DOMDocume return $dom; } - private function getRouteDocument(Route $route, string $name = null): \DOMDocument + private function getRouteDocument(Route $route, ?string $name = null): \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($routeXML = $dom->createElement('route')); @@ -255,7 +255,7 @@ private function getContainerTagsDocument(ContainerBuilder $builder, bool $showH return $dom; } - private function getContainerServiceDocument(object $service, string $id, ContainerBuilder $builder = null, bool $showArguments = false): \DOMDocument + private function getContainerServiceDocument(object $service, string $id, ?ContainerBuilder $builder = null, bool $showArguments = false): \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); @@ -275,7 +275,7 @@ private function getContainerServiceDocument(object $service, string $id, Contai return $dom; } - private function getContainerServicesDocument(ContainerBuilder $builder, string $tag = null, bool $showHidden = false, bool $showArguments = false, callable $filter = null): \DOMDocument + private function getContainerServicesDocument(ContainerBuilder $builder, ?string $tag = null, bool $showHidden = false, bool $showArguments = false, ?callable $filter = null): \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($containerXML = $dom->createElement('container')); @@ -301,7 +301,7 @@ private function getContainerServicesDocument(ContainerBuilder $builder, string return $dom; } - private function getContainerDefinitionDocument(Definition $definition, string $id = null, bool $omitTags = false, bool $showArguments = false): \DOMDocument + private function getContainerDefinitionDocument(Definition $definition, ?string $id = null, bool $omitTags = false, bool $showArguments = false): \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($serviceXML = $dom->createElement('definition')); @@ -432,7 +432,7 @@ private function getArgumentNodes(array $arguments, \DOMDocument $dom): array return $nodes; } - private function getContainerAliasDocument(Alias $alias, string $id = null): \DOMDocument + private function getContainerAliasDocument(Alias $alias, ?string $id = null): \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($aliasXML = $dom->createElement('alias')); diff --git a/Console/Helper/DescriptorHelper.php b/Console/Helper/DescriptorHelper.php index 1f17c9994..ca303e12d 100644 --- a/Console/Helper/DescriptorHelper.php +++ b/Console/Helper/DescriptorHelper.php @@ -25,7 +25,7 @@ */ class DescriptorHelper extends BaseDescriptorHelper { - public function __construct(FileLinkFormatter $fileLinkFormatter = null) + public function __construct(?FileLinkFormatter $fileLinkFormatter = null) { $this ->register('txt', new TextDescriptor($fileLinkFormatter)) diff --git a/Controller/AbstractController.php b/Controller/AbstractController.php index d4b9f4181..7eebd8ac7 100644 --- a/Controller/AbstractController.php +++ b/Controller/AbstractController.php @@ -193,7 +193,7 @@ protected function json($data, int $status = 200, array $headers = [], array $co * * @param \SplFileInfo|string $file File object or path to file to be sent as response */ - protected function file($file, string $fileName = null, string $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT): BinaryFileResponse + protected function file($file, ?string $fileName = null, string $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT): BinaryFileResponse { $response = new BinaryFileResponse($file); $response->setContentDisposition($disposition, null === $fileName ? $response->getFile()->getFilename() : $fileName); @@ -261,7 +261,7 @@ protected function renderView(string $view, array $parameters = []): string /** * Renders a view. */ - protected function render(string $view, array $parameters = [], Response $response = null): Response + protected function render(string $view, array $parameters = [], ?Response $response = null): Response { $content = $this->renderView($view, $parameters); @@ -279,7 +279,7 @@ protected function render(string $view, array $parameters = [], Response $respon * * If an invalid form is found in the list of parameters, a 422 status code is returned. */ - protected function renderForm(string $view, array $parameters = [], Response $response = null): Response + protected function renderForm(string $view, array $parameters = [], ?Response $response = null): Response { if (null === $response) { $response = new Response(); @@ -307,7 +307,7 @@ protected function renderForm(string $view, array $parameters = [], Response $re /** * Streams a view. */ - protected function stream(string $view, array $parameters = [], StreamedResponse $response = null): StreamedResponse + protected function stream(string $view, array $parameters = [], ?StreamedResponse $response = null): StreamedResponse { if (!$this->container->has('twig')) { throw new \LogicException('You cannot use the "stream" method if the Twig Bundle is not available. Try running "composer require symfony/twig-bundle".'); @@ -335,7 +335,7 @@ protected function stream(string $view, array $parameters = [], StreamedResponse * * throw $this->createNotFoundException('Page not found!'); */ - protected function createNotFoundException(string $message = 'Not Found', \Throwable $previous = null): NotFoundHttpException + protected function createNotFoundException(string $message = 'Not Found', ?\Throwable $previous = null): NotFoundHttpException { return new NotFoundHttpException($message, $previous); } @@ -349,7 +349,7 @@ protected function createNotFoundException(string $message = 'Not Found', \Throw * * @throws \LogicException If the Security component is not available */ - protected function createAccessDeniedException(string $message = 'Access Denied.', \Throwable $previous = null): AccessDeniedException + protected function createAccessDeniedException(string $message = 'Access Denied.', ?\Throwable $previous = null): AccessDeniedException { if (!class_exists(AccessDeniedException::class)) { throw new \LogicException('You cannot use the "createAccessDeniedException" method if the Security component is not available. Try running "composer require symfony/security-bundle".'); diff --git a/Controller/RedirectController.php b/Controller/RedirectController.php index 6a0fed64f..702d69748 100644 --- a/Controller/RedirectController.php +++ b/Controller/RedirectController.php @@ -31,7 +31,7 @@ class RedirectController private $httpPort; private $httpsPort; - public function __construct(UrlGeneratorInterface $router = null, int $httpPort = null, int $httpsPort = null) + public function __construct(?UrlGeneratorInterface $router = null, ?int $httpPort = null, ?int $httpsPort = null) { $this->router = $router; $this->httpPort = $httpPort; @@ -107,7 +107,7 @@ public function redirectAction(Request $request, string $route, bool $permanent * * @throws HttpException In case the path is empty */ - public function urlRedirectAction(Request $request, string $path, bool $permanent = false, string $scheme = null, int $httpPort = null, int $httpsPort = null, bool $keepRequestMethod = false): Response + public function urlRedirectAction(Request $request, string $path, bool $permanent = false, ?string $scheme = null, ?int $httpPort = null, ?int $httpsPort = null, bool $keepRequestMethod = false): Response { if ('' == $path) { throw new HttpException($permanent ? 410 : 404); diff --git a/Controller/TemplateController.php b/Controller/TemplateController.php index 2283dbc91..5ea4c5b53 100644 --- a/Controller/TemplateController.php +++ b/Controller/TemplateController.php @@ -25,7 +25,7 @@ class TemplateController { private $twig; - public function __construct(Environment $twig = null) + public function __construct(?Environment $twig = null) { $this->twig = $twig; } @@ -40,7 +40,7 @@ public function __construct(Environment $twig = null) * @param array $context The context (arguments) of the template * @param int $statusCode The HTTP status code to return with the response. Defaults to 200 */ - public function templateAction(string $template, int $maxAge = null, int $sharedAge = null, bool $private = null, array $context = [], int $statusCode = 200): Response + public function templateAction(string $template, ?int $maxAge = null, ?int $sharedAge = null, ?bool $private = null, array $context = [], int $statusCode = 200): Response { if (null === $this->twig) { throw new \LogicException('You cannot use the TemplateController if the Twig Bundle is not available.'); @@ -65,7 +65,7 @@ public function templateAction(string $template, int $maxAge = null, int $shared return $response; } - public function __invoke(string $template, int $maxAge = null, int $sharedAge = null, bool $private = null, array $context = [], int $statusCode = 200): Response + public function __invoke(string $template, ?int $maxAge = null, ?int $sharedAge = null, ?bool $private = null, array $context = [], int $statusCode = 200): Response { return $this->templateAction($template, $maxAge, $sharedAge, $private, $context, $statusCode); } diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 156c16b27..487759a87 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -123,7 +123,7 @@ public function getConfigTreeBuilder() ->end() ; - $willBeAvailable = static function (string $package, string $class, string $parentPackage = null) { + $willBeAvailable = static function (string $package, string $class, ?string $parentPackage = null) { $parentPackages = (array) $parentPackage; $parentPackages[] = 'symfony/framework-bundle'; diff --git a/HttpCache/HttpCache.php b/HttpCache/HttpCache.php index fe38c4adc..e2dd8f940 100644 --- a/HttpCache/HttpCache.php +++ b/HttpCache/HttpCache.php @@ -37,7 +37,7 @@ class HttpCache extends BaseHttpCache /** * @param string|StoreInterface $cache The cache directory (default used if null) or the storage instance */ - public function __construct(KernelInterface $kernel, $cache = null, SurrogateInterface $surrogate = null, array $options = null) + public function __construct(KernelInterface $kernel, $cache = null, ?SurrogateInterface $surrogate = null, ?array $options = null) { $this->kernel = $kernel; $this->surrogate = $surrogate; @@ -65,7 +65,7 @@ public function __construct(KernelInterface $kernel, $cache = null, SurrogateInt /** * {@inheritdoc} */ - protected function forward(Request $request, bool $catch = false, Response $entry = null) + protected function forward(Request $request, bool $catch = false, ?Response $entry = null) { $this->getKernel()->boot(); $this->getKernel()->getContainer()->set('cache', $this); diff --git a/KernelBrowser.php b/KernelBrowser.php index a02853012..3dec82d8c 100644 --- a/KernelBrowser.php +++ b/KernelBrowser.php @@ -37,7 +37,7 @@ class KernelBrowser extends HttpKernelBrowser /** * {@inheritdoc} */ - public function __construct(KernelInterface $kernel, array $server = [], History $history = null, CookieJar $cookieJar = null) + public function __construct(KernelInterface $kernel, array $server = [], ?History $history = null, ?CookieJar $cookieJar = null) { parent::__construct($kernel, $server, $history, $cookieJar); } diff --git a/Routing/DelegatingLoader.php b/Routing/DelegatingLoader.php index e130bd2fa..2660f7265 100644 --- a/Routing/DelegatingLoader.php +++ b/Routing/DelegatingLoader.php @@ -43,7 +43,7 @@ public function __construct(LoaderResolverInterface $resolver, array $defaultOpt /** * {@inheritdoc} */ - public function load($resource, string $type = null): RouteCollection + public function load($resource, ?string $type = null): RouteCollection { if ($this->loading) { // This can happen if a fatal error occurs in parent::load(). diff --git a/Routing/RedirectableCompiledUrlMatcher.php b/Routing/RedirectableCompiledUrlMatcher.php index dba9d6d96..3ae4523ba 100644 --- a/Routing/RedirectableCompiledUrlMatcher.php +++ b/Routing/RedirectableCompiledUrlMatcher.php @@ -24,7 +24,7 @@ class RedirectableCompiledUrlMatcher extends CompiledUrlMatcher implements Redir /** * {@inheritdoc} */ - public function redirect(string $path, string $route, string $scheme = null): array + public function redirect(string $path, string $route, ?string $scheme = null): array { return [ '_controller' => 'Symfony\\Bundle\\FrameworkBundle\\Controller\\RedirectController::urlRedirectAction', diff --git a/Routing/Router.php b/Routing/Router.php index 8e36efe0a..06a3f71ff 100644 --- a/Routing/Router.php +++ b/Routing/Router.php @@ -40,7 +40,7 @@ class Router extends BaseRouter implements WarmableInterface, ServiceSubscriberI /** * @param mixed $resource The main resource to load */ - public function __construct(ContainerInterface $container, $resource, array $options = [], RequestContext $context = null, ContainerInterface $parameters = null, LoggerInterface $logger = null, string $defaultLocale = null) + public function __construct(ContainerInterface $container, $resource, array $options = [], ?RequestContext $context = null, ?ContainerInterface $parameters = null, ?LoggerInterface $logger = null, ?string $defaultLocale = null) { $this->container = $container; $this->resource = $resource; diff --git a/Test/BrowserKitAssertionsTrait.php b/Test/BrowserKitAssertionsTrait.php index 55b95f055..9b8db8ca3 100644 --- a/Test/BrowserKitAssertionsTrait.php +++ b/Test/BrowserKitAssertionsTrait.php @@ -43,7 +43,7 @@ public static function assertResponseFormatSame(?string $expectedFormat, string self::assertThatForResponse(new ResponseConstraint\ResponseFormatSame(self::getRequest(), $expectedFormat), $message); } - public static function assertResponseRedirects(string $expectedLocation = null, int $expectedCode = null, string $message = ''): void + public static function assertResponseRedirects(?string $expectedLocation = null, ?int $expectedCode = null, string $message = ''): void { $constraint = new ResponseConstraint\ResponseIsRedirected(); if ($expectedLocation) { @@ -76,17 +76,17 @@ public static function assertResponseHeaderNotSame(string $headerName, string $e self::assertThatForResponse(new LogicalNot(new ResponseConstraint\ResponseHeaderSame($headerName, $expectedValue)), $message); } - public static function assertResponseHasCookie(string $name, string $path = '/', string $domain = null, string $message = ''): void + public static function assertResponseHasCookie(string $name, string $path = '/', ?string $domain = null, string $message = ''): void { self::assertThatForResponse(new ResponseConstraint\ResponseHasCookie($name, $path, $domain), $message); } - public static function assertResponseNotHasCookie(string $name, string $path = '/', string $domain = null, string $message = ''): void + public static function assertResponseNotHasCookie(string $name, string $path = '/', ?string $domain = null, string $message = ''): void { self::assertThatForResponse(new LogicalNot(new ResponseConstraint\ResponseHasCookie($name, $path, $domain)), $message); } - public static function assertResponseCookieValueSame(string $name, string $expectedValue, string $path = '/', string $domain = null, string $message = ''): void + public static function assertResponseCookieValueSame(string $name, string $expectedValue, string $path = '/', ?string $domain = null, string $message = ''): void { self::assertThatForResponse(LogicalAnd::fromConstraints( new ResponseConstraint\ResponseHasCookie($name, $path, $domain), @@ -99,17 +99,17 @@ public static function assertResponseIsUnprocessable(string $message = ''): void self::assertThatForResponse(new ResponseConstraint\ResponseIsUnprocessable(), $message); } - public static function assertBrowserHasCookie(string $name, string $path = '/', string $domain = null, string $message = ''): void + public static function assertBrowserHasCookie(string $name, string $path = '/', ?string $domain = null, string $message = ''): void { self::assertThatForClient(new BrowserKitConstraint\BrowserHasCookie($name, $path, $domain), $message); } - public static function assertBrowserNotHasCookie(string $name, string $path = '/', string $domain = null, string $message = ''): void + public static function assertBrowserNotHasCookie(string $name, string $path = '/', ?string $domain = null, string $message = ''): void { self::assertThatForClient(new LogicalNot(new BrowserKitConstraint\BrowserHasCookie($name, $path, $domain)), $message); } - public static function assertBrowserCookieValueSame(string $name, string $expectedValue, bool $raw = false, string $path = '/', string $domain = null, string $message = ''): void + public static function assertBrowserCookieValueSame(string $name, string $expectedValue, bool $raw = false, string $path = '/', ?string $domain = null, string $message = ''): void { self::assertThatForClient(LogicalAnd::fromConstraints( new BrowserKitConstraint\BrowserHasCookie($name, $path, $domain), @@ -156,7 +156,7 @@ public static function assertThatForClient(Constraint $constraint, string $messa self::assertThat(self::getClient(), $constraint, $message); } - private static function getClient(AbstractBrowser $newClient = null): ?AbstractBrowser + private static function getClient(?AbstractBrowser $newClient = null): ?AbstractBrowser { static $client; diff --git a/Test/MailerAssertionsTrait.php b/Test/MailerAssertionsTrait.php index 1a629d625..491812aa9 100644 --- a/Test/MailerAssertionsTrait.php +++ b/Test/MailerAssertionsTrait.php @@ -20,12 +20,12 @@ trait MailerAssertionsTrait { - public static function assertEmailCount(int $count, string $transport = null, string $message = ''): void + public static function assertEmailCount(int $count, ?string $transport = null, string $message = ''): void { self::assertThat(self::getMessageMailerEvents(), new MailerConstraint\EmailCount($count, $transport), $message); } - public static function assertQueuedEmailCount(int $count, string $transport = null, string $message = ''): void + public static function assertQueuedEmailCount(int $count, ?string $transport = null, string $message = ''): void { self::assertThat(self::getMessageMailerEvents(), new MailerConstraint\EmailCount($count, $transport, true), $message); } @@ -93,12 +93,12 @@ public static function assertEmailAddressContains(RawMessage $email, string $hea /** * @return MessageEvent[] */ - public static function getMailerEvents(string $transport = null): array + public static function getMailerEvents(?string $transport = null): array { return self::getMessageMailerEvents()->getEvents($transport); } - public static function getMailerEvent(int $index = 0, string $transport = null): ?MessageEvent + public static function getMailerEvent(int $index = 0, ?string $transport = null): ?MessageEvent { return self::getMailerEvents($transport)[$index] ?? null; } @@ -106,12 +106,12 @@ public static function getMailerEvent(int $index = 0, string $transport = null): /** * @return RawMessage[] */ - public static function getMailerMessages(string $transport = null): array + public static function getMailerMessages(?string $transport = null): array { return self::getMessageMailerEvents()->getMessages($transport); } - public static function getMailerMessage(int $index = 0, string $transport = null): ?RawMessage + public static function getMailerMessage(int $index = 0, ?string $transport = null): ?RawMessage { return self::getMailerMessages($transport)[$index] ?? null; } diff --git a/Test/TestBrowserToken.php b/Test/TestBrowserToken.php index 7580743f6..ebc88c98e 100644 --- a/Test/TestBrowserToken.php +++ b/Test/TestBrowserToken.php @@ -23,7 +23,7 @@ class TestBrowserToken extends AbstractToken { private $firewallName; - public function __construct(array $roles = [], UserInterface $user = null, string $firewallName = 'main') + public function __construct(array $roles = [], ?UserInterface $user = null, string $firewallName = 'main') { parent::__construct($roles); diff --git a/Tests/Command/TranslationDebugCommandTest.php b/Tests/Command/TranslationDebugCommandTest.php index e3ac1066a..57535aea5 100644 --- a/Tests/Command/TranslationDebugCommandTest.php +++ b/Tests/Command/TranslationDebugCommandTest.php @@ -158,12 +158,12 @@ protected function tearDown(): void $this->fs->remove($this->translationDir); } - private function createCommandTester(array $extractedMessages = [], array $loadedMessages = [], KernelInterface $kernel = null, array $transPaths = [], array $codePaths = []): CommandTester + private function createCommandTester(array $extractedMessages = [], array $loadedMessages = [], ?KernelInterface $kernel = null, array $transPaths = [], array $codePaths = []): CommandTester { return new CommandTester($this->createCommand($extractedMessages, $loadedMessages, $kernel, $transPaths, $codePaths)); } - private function createCommand(array $extractedMessages = [], array $loadedMessages = [], KernelInterface $kernel = null, array $transPaths = [], array $codePaths = [], ExtractorInterface $extractor = null, array $bundles = [], array $enabledLocales = []): TranslationDebugCommand + private function createCommand(array $extractedMessages = [], array $loadedMessages = [], ?KernelInterface $kernel = null, array $transPaths = [], array $codePaths = [], ?ExtractorInterface $extractor = null, array $bundles = [], array $enabledLocales = []): TranslationDebugCommand { $translator = $this->createMock(Translator::class); $translator diff --git a/Tests/Command/TranslationUpdateCommandCompletionTest.php b/Tests/Command/TranslationUpdateCommandCompletionTest.php index 6992ade4d..0b8ee7648 100644 --- a/Tests/Command/TranslationUpdateCommandCompletionTest.php +++ b/Tests/Command/TranslationUpdateCommandCompletionTest.php @@ -67,7 +67,7 @@ protected function tearDown(): void $this->fs->remove($this->translationDir); } - private function createCommandCompletionTester($extractedMessages = [], $loadedMessages = [], KernelInterface $kernel = null, array $transPaths = [], array $codePaths = []): CommandCompletionTester + private function createCommandCompletionTester($extractedMessages = [], $loadedMessages = [], ?KernelInterface $kernel = null, array $transPaths = [], array $codePaths = []): CommandCompletionTester { $translator = $this->createMock(Translator::class); $translator diff --git a/Tests/Command/TranslationUpdateCommandTest.php b/Tests/Command/TranslationUpdateCommandTest.php index f883fac0c..8b2ad0891 100644 --- a/Tests/Command/TranslationUpdateCommandTest.php +++ b/Tests/Command/TranslationUpdateCommandTest.php @@ -193,7 +193,7 @@ protected function tearDown(): void $this->fs->remove($this->translationDir); } - private function createCommandTester($extractedMessages = [], $loadedMessages = [], KernelInterface $kernel = null, array $transPaths = [], array $codePaths = []): CommandTester + private function createCommandTester($extractedMessages = [], $loadedMessages = [], ?KernelInterface $kernel = null, array $transPaths = [], array $codePaths = []): CommandTester { $translator = $this->createMock(Translator::class); $translator diff --git a/Tests/Controller/ControllerResolverTest.php b/Tests/Controller/ControllerResolverTest.php index 5fb3e774a..68e9ea413 100644 --- a/Tests/Controller/ControllerResolverTest.php +++ b/Tests/Controller/ControllerResolverTest.php @@ -148,7 +148,7 @@ class_exists(AbstractControllerTest::class); $this->assertSame($controllerContainer, $controller->getContainer()); } - protected function createControllerResolver(LoggerInterface $logger = null, Psr11ContainerInterface $container = null) + protected function createControllerResolver(?LoggerInterface $logger = null, ?Psr11ContainerInterface $container = null) { if (!$container) { $container = $this->createMockContainer(); @@ -172,7 +172,7 @@ class ContainerAwareController implements ContainerAwareInterface { private $container; - public function setContainer(ContainerInterface $container = null) + public function setContainer(?ContainerInterface $container = null) { $this->container = $container; } diff --git a/Tests/DependencyInjection/Compiler/DataCollectorTranslatorPassTest.php b/Tests/DependencyInjection/Compiler/DataCollectorTranslatorPassTest.php index a5d58edbb..21275b490 100644 --- a/Tests/DependencyInjection/Compiler/DataCollectorTranslatorPassTest.php +++ b/Tests/DependencyInjection/Compiler/DataCollectorTranslatorPassTest.php @@ -108,7 +108,7 @@ public static function getNotImplementingTranslatorBagInterfaceTranslatorClassNa class TranslatorWithTranslatorBag implements TranslatorInterface { - public function trans(string $id, array $parameters = [], string $domain = null, string $locale = null): string + public function trans(string $id, array $parameters = [], ?string $domain = null, ?string $locale = null): string { } diff --git a/Tests/DependencyInjection/Compiler/ProfilerPassTest.php b/Tests/DependencyInjection/Compiler/ProfilerPassTest.php index 9792d2266..8794f539e 100644 --- a/Tests/DependencyInjection/Compiler/ProfilerPassTest.php +++ b/Tests/DependencyInjection/Compiler/ProfilerPassTest.php @@ -65,7 +65,7 @@ public function testValidCollector() public static function provideValidCollectorWithTemplateUsingAutoconfigure(): \Generator { yield [new class() implements TemplateAwareDataCollectorInterface { - public function collect(Request $request, Response $response, \Throwable $exception = null) + public function collect(Request $request, Response $response, ?\Throwable $exception = null) { } @@ -85,7 +85,7 @@ public static function getTemplate(): string }]; yield [new class() extends AbstractDataCollector { - public function collect(Request $request, Response $response, \Throwable $exception = null) + public function collect(Request $request, Response $response, ?\Throwable $exception = null) { } diff --git a/Tests/DependencyInjection/FrameworkExtensionTestCase.php b/Tests/DependencyInjection/FrameworkExtensionTestCase.php index 52a6ad6a4..5e955d016 100644 --- a/Tests/DependencyInjection/FrameworkExtensionTestCase.php +++ b/Tests/DependencyInjection/FrameworkExtensionTestCase.php @@ -2093,7 +2093,7 @@ protected function createContainer(array $data = []) ], $data))); } - protected function createContainerFromFile($file, $data = [], $resetCompilerPasses = true, $compile = true, FrameworkExtension $extension = null) + protected function createContainerFromFile($file, $data = [], $resetCompilerPasses = true, $compile = true, ?FrameworkExtension $extension = null) { $cacheKey = md5(static::class.$file.serialize($data)); if ($compile && isset(self::$containerCache[$cacheKey])) { diff --git a/Tests/Functional/Bundle/TestBundle/AutowiringTypes/AutowiredServices.php b/Tests/Functional/Bundle/TestBundle/AutowiringTypes/AutowiredServices.php index 4743460e6..2aefbde4f 100644 --- a/Tests/Functional/Bundle/TestBundle/AutowiringTypes/AutowiredServices.php +++ b/Tests/Functional/Bundle/TestBundle/AutowiringTypes/AutowiredServices.php @@ -21,7 +21,7 @@ class AutowiredServices private $dispatcher; private $cachePool; - public function __construct(Reader $annotationReader = null, EventDispatcherInterface $dispatcher, CacheItemPoolInterface $cachePool) + public function __construct(?Reader $annotationReader = null, EventDispatcherInterface $dispatcher, CacheItemPoolInterface $cachePool) { $this->annotationReader = $annotationReader; $this->dispatcher = $dispatcher; diff --git a/Tests/Functional/Bundle/TestBundle/Controller/AnnotatedController.php b/Tests/Functional/Bundle/TestBundle/Controller/AnnotatedController.php index f2f077786..0a01712ca 100644 --- a/Tests/Functional/Bundle/TestBundle/Controller/AnnotatedController.php +++ b/Tests/Functional/Bundle/TestBundle/Controller/AnnotatedController.php @@ -20,7 +20,7 @@ class AnnotatedController /** * @Route("/null_request", name="null_request") */ - public function requestDefaultNullAction(Request $request = null) + public function requestDefaultNullAction(?Request $request = null) { return new Response($request ? \get_class($request) : null); } diff --git a/Translation/Translator.php b/Translation/Translator.php index 5173f8a8e..fba3fea8d 100644 --- a/Translation/Translator.php +++ b/Translation/Translator.php @@ -120,7 +120,7 @@ public function warmUp(string $cacheDir) return []; } - public function addResource(string $format, $resource, string $locale, string $domain = null) + public function addResource(string $format, $resource, string $locale, ?string $domain = null) { if ($this->resourceFiles) { $this->addResourceFiles(); From 89805687f360133f18bdedfb32138ce0ddd5383c Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 23 Jan 2024 15:23:03 +0100 Subject: [PATCH 08/10] Fix implicitly-required parameters --- .../Bundle/TestBundle/AutowiringTypes/AutowiredServices.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Functional/Bundle/TestBundle/AutowiringTypes/AutowiredServices.php b/Tests/Functional/Bundle/TestBundle/AutowiringTypes/AutowiredServices.php index 2aefbde4f..2dc1fac4b 100644 --- a/Tests/Functional/Bundle/TestBundle/AutowiringTypes/AutowiredServices.php +++ b/Tests/Functional/Bundle/TestBundle/AutowiringTypes/AutowiredServices.php @@ -21,7 +21,7 @@ class AutowiredServices private $dispatcher; private $cachePool; - public function __construct(?Reader $annotationReader = null, EventDispatcherInterface $dispatcher, CacheItemPoolInterface $cachePool) + public function __construct(?Reader $annotationReader, EventDispatcherInterface $dispatcher, CacheItemPoolInterface $cachePool) { $this->annotationReader = $annotationReader; $this->dispatcher = $dispatcher; From 88747da4005cea448d2383e1fbeb2499e490dfb5 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 24 Jan 2024 19:53:26 +0100 Subject: [PATCH 09/10] [DependencyInjection] Fix loading all env vars from secrets when only a subset is needed --- Secrets/SodiumVault.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Secrets/SodiumVault.php b/Secrets/SodiumVault.php index 9b8208d90..dcf79869f 100644 --- a/Secrets/SodiumVault.php +++ b/Secrets/SodiumVault.php @@ -12,6 +12,7 @@ namespace Symfony\Bundle\FrameworkBundle\Secrets; use Symfony\Component\DependencyInjection\EnvVarLoaderInterface; +use Symfony\Component\String\LazyString; use Symfony\Component\VarExporter\VarExporter; /** @@ -169,7 +170,14 @@ public function list(bool $reveal = false): array public function loadEnvVars(): array { - return $this->list(true); + $envs = []; + $reveal = $this->reveal(...); + + foreach ($this->list() as $name => $value) { + $envs[$name] = LazyString::fromCallable($reveal, $name); + } + + return $envs; } private function loadKeys(): void From 386e2facbd9c57e2b459172aa8b1d9d50b94393c Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 29 Jan 2024 15:14:51 +0100 Subject: [PATCH 10/10] [FrameworkBundle] ConfigBuilderCacheWarmer should be non-optional --- CacheWarmer/ConfigBuilderCacheWarmer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CacheWarmer/ConfigBuilderCacheWarmer.php b/CacheWarmer/ConfigBuilderCacheWarmer.php index 81a0a26c7..9921dd2f5 100644 --- a/CacheWarmer/ConfigBuilderCacheWarmer.php +++ b/CacheWarmer/ConfigBuilderCacheWarmer.php @@ -85,6 +85,6 @@ private function dumpExtension(ExtensionInterface $extension, ConfigBuilderGener public function isOptional(): bool { - return true; + return false; } }