From 2bb2cba685aabd859f22cf6946554e8e7f3c329a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 28 Jun 2025 10:14:51 +0200 Subject: [PATCH 1/6] Update VERSION for 6.4.23 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 91c143f342..04f788167c 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '6.4.23-DEV'; + public const VERSION = '6.4.23'; public const VERSION_ID = 60423; public const MAJOR_VERSION = 6; public const MINOR_VERSION = 4; public const RELEASE_VERSION = 23; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '11/2026'; public const END_OF_LIFE = '11/2027'; From 54e84316f07afdfdf6c43677da76bc3a445a0b86 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 28 Jun 2025 10:19:39 +0200 Subject: [PATCH 2/6] Bump Symfony version to 6.4.24 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 04f788167c..761461f616 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '6.4.23'; - public const VERSION_ID = 60423; + public const VERSION = '6.4.24-DEV'; + public const VERSION_ID = 60424; public const MAJOR_VERSION = 6; public const MINOR_VERSION = 4; - public const RELEASE_VERSION = 23; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 24; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '11/2026'; public const END_OF_LIFE = '11/2027'; From 3f461ff845e4529e0fa14f9639a7b6898367aa34 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 28 Jun 2025 10:20:39 +0200 Subject: [PATCH 3/6] Update VERSION for 7.2.8 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 8948fc7533..12ec6da633 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.2.8-DEV'; + public const VERSION = '7.2.8'; public const VERSION_ID = 70208; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 2; public const RELEASE_VERSION = 8; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '07/2025'; public const END_OF_LIFE = '07/2025'; From 2a5fa0e3df2402e22ead00d4cdb0dd443d4f80f4 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 28 Jun 2025 10:23:57 +0200 Subject: [PATCH 4/6] Bump Symfony version to 7.2.9 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 12ec6da633..5013a64f76 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.2.8'; - public const VERSION_ID = 70208; + public const VERSION = '7.2.9-DEV'; + public const VERSION_ID = 70209; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 2; - public const RELEASE_VERSION = 8; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 9; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '07/2025'; public const END_OF_LIFE = '07/2025'; From ab1f64e4bf0eeafb927e7ad6f9de4b0be3f3966e Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 28 Jun 2025 10:29:55 +0200 Subject: [PATCH 5/6] Bump Symfony version to 7.3.2 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 4829bfb7de..7bc59a9e68 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.3.1'; - public const VERSION_ID = 70301; + public const VERSION = '7.3.2-DEV'; + public const VERSION_ID = 70302; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 3; - public const RELEASE_VERSION = 1; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 2; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '01/2026'; public const END_OF_LIFE = '01/2026'; From 63f320d6a15f23be309c7ec4b72bb89794cfa727 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 10 Jul 2025 09:12:18 +0200 Subject: [PATCH 6/6] CS fixes --- Attribute/WithLogLevel.php | 2 +- Bundle/Bundle.php | 4 +-- CacheClearer/Psr6CacheClearer.php | 4 +-- CacheWarmer/CacheWarmer.php | 2 +- CacheWarmer/CacheWarmerAggregate.php | 4 +-- Controller/ArgumentResolver.php | 8 +++--- .../BackedEnumValueResolver.php | 4 +-- .../DateTimeValueResolver.php | 2 +- .../NotTaggedControllerValueResolver.php | 4 +-- .../QueryParameterValueResolver.php | 12 ++++---- .../RequestPayloadValueResolver.php | 12 ++++---- .../ArgumentResolver/ServiceValueResolver.php | 4 +-- .../ArgumentResolver/UidValueResolver.php | 2 +- .../VariadicValueResolver.php | 2 +- Controller/ContainerControllerResolver.php | 6 ++-- Controller/ControllerResolver.php | 28 +++++++++---------- ControllerMetadata/ArgumentMetadata.php | 2 +- DataCollector/ConfigDataCollector.php | 2 +- DataCollector/DumpDataCollector.php | 6 ++-- DataCollector/RequestDataCollector.php | 2 +- DependencyInjection/FragmentRendererPass.php | 4 +-- ...RegisterControllerArgumentLocatorsPass.php | 12 ++++---- ...oveEmptyControllerArgumentLocatorsPass.php | 4 +-- DependencyInjection/ResettableServicePass.php | 2 +- EventListener/ErrorListener.php | 4 +-- EventListener/RouterListener.php | 6 ++-- Exception/ResolverNotFoundException.php | 2 +- Fragment/FragmentHandler.php | 4 +-- Fragment/FragmentUriGenerator.php | 2 +- Fragment/HIncludeFragmentRenderer.php | 4 +-- HttpCache/AbstractSurrogate.php | 18 ++++++------ HttpCache/Esi.php | 6 ++-- HttpCache/HttpCache.php | 2 +- HttpCache/ResponseCacheStrategy.php | 4 +-- HttpCache/Ssi.php | 2 +- HttpCache/Store.php | 2 +- HttpCache/SubRequestHandler.php | 6 ++-- HttpClientKernel.php | 2 +- HttpKernel.php | 16 +++++------ Kernel.php | 22 +++++++-------- Log/Logger.php | 8 +++--- Profiler/FileProfilerStorage.php | 6 ++-- Profiler/Profile.php | 2 +- Profiler/Profiler.php | 2 +- .../RequestPayloadValueResolverTest.php | 28 +++++++++---------- Tests/Controller/ArgumentResolverTest.php | 4 +-- .../TraceableArgumentResolverTest.php | 2 +- .../TraceableControllerResolverTest.php | 2 +- .../DataCollector/ConfigDataCollectorTest.php | 4 +-- .../RequestDataCollectorTest.php | 8 +++--- ...sterControllerArgumentLocatorsPassTest.php | 2 +- .../CacheAttributeListenerTest.php | 2 +- Tests/EventListener/SessionListenerTest.php | 2 +- Tests/HttpCache/HttpCacheTest.php | 8 +++--- Tests/HttpCache/HttpCacheTestCase.php | 4 +-- Tests/HttpCache/ResponseCacheStrategyTest.php | 6 ++-- Tests/KernelTest.php | 6 ++-- 57 files changed, 166 insertions(+), 166 deletions(-) diff --git a/Attribute/WithLogLevel.php b/Attribute/WithLogLevel.php index 762b077043..10ed3b8eaa 100644 --- a/Attribute/WithLogLevel.php +++ b/Attribute/WithLogLevel.php @@ -25,7 +25,7 @@ final class WithLogLevel public function __construct(public readonly string $level) { if (!\defined('Psr\Log\LogLevel::'.strtoupper($this->level))) { - throw new \InvalidArgumentException(sprintf('Invalid log level "%s".', $this->level)); + throw new \InvalidArgumentException(\sprintf('Invalid log level "%s".', $this->level)); } } } diff --git a/Bundle/Bundle.php b/Bundle/Bundle.php index 09a19c480c..0efc21a5e0 100644 --- a/Bundle/Bundle.php +++ b/Bundle/Bundle.php @@ -70,7 +70,7 @@ public function getContainerExtension(): ?ExtensionInterface if (null !== $extension) { if (!$extension instanceof ExtensionInterface) { - throw new \LogicException(sprintf('Extension "%s" must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface.', get_debug_type($extension))); + throw new \LogicException(\sprintf('Extension "%s" must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface.', get_debug_type($extension))); } // check naming convention @@ -78,7 +78,7 @@ public function getContainerExtension(): ?ExtensionInterface $expectedAlias = Container::underscore($basename); if ($expectedAlias != $extension->getAlias()) { - throw new \LogicException(sprintf('Users will expect the alias of the default extension of a bundle to be the underscored version of the bundle name ("%s"). You can override "Bundle::getContainerExtension()" if you want to use "%s" or another alias.', $expectedAlias, $extension->getAlias())); + throw new \LogicException(\sprintf('Users will expect the alias of the default extension of a bundle to be the underscored version of the bundle name ("%s"). You can override "Bundle::getContainerExtension()" if you want to use "%s" or another alias.', $expectedAlias, $extension->getAlias())); } $this->extension = $extension; diff --git a/CacheClearer/Psr6CacheClearer.php b/CacheClearer/Psr6CacheClearer.php index 3c99b74af3..87614e9417 100644 --- a/CacheClearer/Psr6CacheClearer.php +++ b/CacheClearer/Psr6CacheClearer.php @@ -39,7 +39,7 @@ public function hasPool(string $name): bool public function getPool(string $name): CacheItemPoolInterface { if (!$this->hasPool($name)) { - throw new \InvalidArgumentException(sprintf('Cache pool not found: "%s".', $name)); + throw new \InvalidArgumentException(\sprintf('Cache pool not found: "%s".', $name)); } return $this->pools[$name]; @@ -51,7 +51,7 @@ public function getPool(string $name): CacheItemPoolInterface public function clearPool(string $name): bool { if (!isset($this->pools[$name])) { - throw new \InvalidArgumentException(sprintf('Cache pool not found: "%s".', $name)); + throw new \InvalidArgumentException(\sprintf('Cache pool not found: "%s".', $name)); } return $this->pools[$name]->clear(); diff --git a/CacheWarmer/CacheWarmer.php b/CacheWarmer/CacheWarmer.php index f940ba4a72..664110a222 100644 --- a/CacheWarmer/CacheWarmer.php +++ b/CacheWarmer/CacheWarmer.php @@ -30,6 +30,6 @@ protected function writeCacheFile(string $file, $content) return; } - throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $file)); + throw new \RuntimeException(\sprintf('Failed to write cache file "%s".', $file)); } } diff --git a/CacheWarmer/CacheWarmerAggregate.php b/CacheWarmer/CacheWarmerAggregate.php index 47873fe183..9f1c53456c 100644 --- a/CacheWarmer/CacheWarmerAggregate.php +++ b/CacheWarmer/CacheWarmerAggregate.php @@ -107,13 +107,13 @@ public function warmUp(string $cacheDir, string|SymfonyStyle|null $buildDir = nu $start = microtime(true); foreach ((array) $warmer->warmUp($cacheDir, $buildDir) as $item) { if (is_dir($item) || (str_starts_with($item, \dirname($cacheDir)) && !is_file($item)) || ($buildDir && str_starts_with($item, \dirname($buildDir)) && !is_file($item))) { - throw new \LogicException(sprintf('"%s::warmUp()" should return a list of files or classes but "%s" is none of them.', $warmer::class, $item)); + throw new \LogicException(\sprintf('"%s::warmUp()" should return a list of files or classes but "%s" is none of them.', $warmer::class, $item)); } $preload[] = $item; } if ($io?->isDebug()) { - $io->info(sprintf('"%s" completed in %0.2fms.', $warmer::class, 1000 * (microtime(true) - $start))); + $io->info(\sprintf('"%s" completed in %0.2fms.', $warmer::class, 1000 * (microtime(true) - $start))); } } } finally { diff --git a/Controller/ArgumentResolver.php b/Controller/ArgumentResolver.php index 23c2d7faa2..991e99bdc6 100644 --- a/Controller/ArgumentResolver.php +++ b/Controller/ArgumentResolver.php @@ -60,7 +60,7 @@ public function getArguments(Request $request, callable $controller, ?\Reflectio if ($attribute->disabled) { $disabledResolvers[$attribute->resolver] = true; } elseif ($resolverName) { - throw new \LogicException(sprintf('You can only pin one resolver per argument, but argument "$%s" of "%s()" has more.', $metadata->getName(), $this->getPrettyName($controller))); + throw new \LogicException(\sprintf('You can only pin one resolver per argument, but argument "$%s" of "%s()" has more.', $metadata->getName(), $this->getPrettyName($controller))); } else { $resolverName = $attribute->resolver; } @@ -94,7 +94,7 @@ public function getArguments(Request $request, callable $controller, ?\Reflectio } if (1 < $count && !$metadata->isVariadic()) { - throw new \InvalidArgumentException(sprintf('"%s::resolve()" must yield at most one value for non-variadic arguments.', get_debug_type($resolver))); + throw new \InvalidArgumentException(\sprintf('"%s::resolve()" must yield at most one value for non-variadic arguments.', get_debug_type($resolver))); } if ($count) { @@ -103,11 +103,11 @@ public function getArguments(Request $request, callable $controller, ?\Reflectio } if (!$resolver instanceof ValueResolverInterface) { - throw new \InvalidArgumentException(sprintf('"%s::resolve()" must yield at least one value.', get_debug_type($resolver))); + throw new \InvalidArgumentException(\sprintf('"%s::resolve()" must yield at least one value.', get_debug_type($resolver))); } } - throw new \RuntimeException(sprintf('Controller "%s" requires that you provide a value for the "$%s" argument. Either the argument is nullable and no null value has been provided, no default value has been provided or there is a non-optional argument after this one.', $this->getPrettyName($controller), $metadata->getName())); + throw new \RuntimeException(\sprintf('Controller "%s" requires that you provide a value for the "$%s" argument. Either the argument is nullable and no null value has been provided, no default value has been provided or there is a non-optional argument after this one.', $this->getPrettyName($controller), $metadata->getName())); } return $arguments; diff --git a/Controller/ArgumentResolver/BackedEnumValueResolver.php b/Controller/ArgumentResolver/BackedEnumValueResolver.php index 620e2de080..c29725dd22 100644 --- a/Controller/ArgumentResolver/BackedEnumValueResolver.php +++ b/Controller/ArgumentResolver/BackedEnumValueResolver.php @@ -78,7 +78,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable } if (!\is_int($value) && !\is_string($value)) { - throw new \LogicException(sprintf('Could not resolve the "%s $%s" controller argument: expecting an int or string, got "%s".', $argument->getType(), $argument->getName(), get_debug_type($value))); + throw new \LogicException(\sprintf('Could not resolve the "%s $%s" controller argument: expecting an int or string, got "%s".', $argument->getType(), $argument->getName(), get_debug_type($value))); } /** @var class-string<\BackedEnum> $enumType */ @@ -87,7 +87,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable try { return [$enumType::from($value)]; } catch (\ValueError|\TypeError $e) { - throw new NotFoundHttpException(sprintf('Could not resolve the "%s $%s" controller argument: ', $argument->getType(), $argument->getName()).$e->getMessage(), $e); + throw new NotFoundHttpException(\sprintf('Could not resolve the "%s $%s" controller argument: ', $argument->getType(), $argument->getName()).$e->getMessage(), $e); } } } diff --git a/Controller/ArgumentResolver/DateTimeValueResolver.php b/Controller/ArgumentResolver/DateTimeValueResolver.php index 0cfd42badc..388f02b317 100644 --- a/Controller/ArgumentResolver/DateTimeValueResolver.php +++ b/Controller/ArgumentResolver/DateTimeValueResolver.php @@ -90,7 +90,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): array } if (!$date) { - throw new NotFoundHttpException(sprintf('Invalid date given for parameter "%s".', $argument->getName())); + throw new NotFoundHttpException(\sprintf('Invalid date given for parameter "%s".', $argument->getName())); } return [$date]; diff --git a/Controller/ArgumentResolver/NotTaggedControllerValueResolver.php b/Controller/ArgumentResolver/NotTaggedControllerValueResolver.php index 2640361288..594f1b8a6f 100644 --- a/Controller/ArgumentResolver/NotTaggedControllerValueResolver.php +++ b/Controller/ArgumentResolver/NotTaggedControllerValueResolver.php @@ -82,8 +82,8 @@ public function resolve(Request $request, ArgumentMetadata $argument): array return []; } - $what = sprintf('argument $%s of "%s()"', $argument->getName(), $controller); - $message = sprintf('Could not resolve %s, maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?', $what); + $what = \sprintf('argument $%s of "%s()"', $argument->getName(), $controller); + $message = \sprintf('Could not resolve %s, maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?', $what); throw new RuntimeException($message); } diff --git a/Controller/ArgumentResolver/QueryParameterValueResolver.php b/Controller/ArgumentResolver/QueryParameterValueResolver.php index b186a39c59..0b64a444b9 100644 --- a/Controller/ArgumentResolver/QueryParameterValueResolver.php +++ b/Controller/ArgumentResolver/QueryParameterValueResolver.php @@ -38,7 +38,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): array return []; } - throw new NotFoundHttpException(sprintf('Missing query parameter "%s".', $name)); + throw new NotFoundHttpException(\sprintf('Missing query parameter "%s".', $name)); } $value = $request->query->all()[$name]; @@ -52,7 +52,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): array $filtered = array_values(array_filter((array) $value, \is_array(...))); if ($filtered !== $value && !($attribute->flags & \FILTER_NULL_ON_FAILURE)) { - throw new NotFoundHttpException(sprintf('Invalid query parameter "%s".', $name)); + throw new NotFoundHttpException(\sprintf('Invalid query parameter "%s".', $name)); } return $filtered; @@ -80,8 +80,8 @@ public function resolve(Request $request, ArgumentMetadata $argument): array default => match ($enumType = is_subclass_of($type, \BackedEnum::class) ? (new \ReflectionEnum($type))->getBackingType()->getName() : null) { 'int' => \FILTER_VALIDATE_INT, 'string' => \FILTER_DEFAULT, - default => throw new \LogicException(sprintf('#[MapQueryParameter] cannot be used on controller argument "%s$%s" of type "%s"; one of array, string, int, float, bool or \BackedEnum should be used.', $argument->isVariadic() ? '...' : '', $argument->getName(), $type ?? 'mixed')), - } + default => throw new \LogicException(\sprintf('#[MapQueryParameter] cannot be used on controller argument "%s$%s" of type "%s"; one of array, string, int, float, bool or \BackedEnum should be used.', $argument->isVariadic() ? '...' : '', $argument->getName(), $type ?? 'mixed')), + }, }; $value = filter_var($value, $attribute->filter ?? $filter, $options); @@ -103,7 +103,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): array } if (null === $value && !($attribute->flags & \FILTER_NULL_ON_FAILURE)) { - throw new NotFoundHttpException(sprintf('Invalid query parameter "%s".', $name)); + throw new NotFoundHttpException(\sprintf('Invalid query parameter "%s".', $name)); } if (!\is_array($value)) { @@ -117,7 +117,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): array } if ($filtered !== $value && !($attribute->flags & \FILTER_NULL_ON_FAILURE)) { - throw new NotFoundHttpException(sprintf('Invalid query parameter "%s".', $name)); + throw new NotFoundHttpException(\sprintf('Invalid query parameter "%s".', $name)); } return $argument->isVariadic() ? $filtered : [$filtered]; diff --git a/Controller/ArgumentResolver/RequestPayloadValueResolver.php b/Controller/ArgumentResolver/RequestPayloadValueResolver.php index f0f735da42..996eacf06f 100644 --- a/Controller/ArgumentResolver/RequestPayloadValueResolver.php +++ b/Controller/ArgumentResolver/RequestPayloadValueResolver.php @@ -71,7 +71,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable } if ($argument->isVariadic()) { - throw new \LogicException(sprintf('Mapping variadic argument "$%s" is not supported.', $argument->getName())); + throw new \LogicException(\sprintf('Mapping variadic argument "$%s" is not supported.', $argument->getName())); } $attribute->metadata = $argument; @@ -96,7 +96,7 @@ public function onKernelControllerArguments(ControllerArgumentsEvent $event): vo $request = $event->getRequest(); if (!$type = $argument->metadata->getType()) { - throw new \LogicException(sprintf('Could not resolve the "$%s" controller argument: argument should be typed.', $argument->metadata->getName())); + throw new \LogicException(\sprintf('Could not resolve the "$%s" controller argument: argument should be typed.', $argument->metadata->getName())); } if ($this->validator) { @@ -140,7 +140,7 @@ public function onKernelControllerArguments(ControllerArgumentsEvent $event): vo $payload = match (true) { $argument->metadata->hasDefaultValue() => $argument->metadata->getDefaultValue(), $argument->metadata->isNullable() => null, - default => throw new HttpException($validationFailedCode) + default => throw new HttpException($validationFailedCode), }; } @@ -173,7 +173,7 @@ private function mapRequestPayload(Request $request, string $type, MapRequestPay } if ($attribute->acceptFormat && !\in_array($format, (array) $attribute->acceptFormat, true)) { - throw new HttpException(Response::HTTP_UNSUPPORTED_MEDIA_TYPE, sprintf('Unsupported format, expects "%s", but "%s" given.', implode('", "', (array) $attribute->acceptFormat), $format)); + throw new HttpException(Response::HTTP_UNSUPPORTED_MEDIA_TYPE, \sprintf('Unsupported format, expects "%s", but "%s" given.', implode('", "', (array) $attribute->acceptFormat), $format)); } if ($data = $request->request->all()) { @@ -191,9 +191,9 @@ private function mapRequestPayload(Request $request, string $type, MapRequestPay try { return $this->serializer->deserialize($data, $type, $format, self::CONTEXT_DESERIALIZE + $attribute->serializationContext); } catch (UnsupportedFormatException $e) { - throw new HttpException(Response::HTTP_UNSUPPORTED_MEDIA_TYPE, sprintf('Unsupported format: "%s".', $format), $e); + throw new HttpException(Response::HTTP_UNSUPPORTED_MEDIA_TYPE, \sprintf('Unsupported format: "%s".', $format), $e); } catch (NotEncodableValueException $e) { - throw new HttpException(Response::HTTP_BAD_REQUEST, sprintf('Request payload contains invalid "%s" data.', $format), $e); + throw new HttpException(Response::HTTP_BAD_REQUEST, \sprintf('Request payload contains invalid "%s" data.', $format), $e); } } } diff --git a/Controller/ArgumentResolver/ServiceValueResolver.php b/Controller/ArgumentResolver/ServiceValueResolver.php index 96e0337d6a..fecf59cafe 100644 --- a/Controller/ArgumentResolver/ServiceValueResolver.php +++ b/Controller/ArgumentResolver/ServiceValueResolver.php @@ -83,11 +83,11 @@ public function resolve(Request $request, ArgumentMetadata $argument): array try { return [$this->container->get($controller)->get($argument->getName())]; } catch (RuntimeException $e) { - $what = sprintf('argument $%s of "%s()"', $argument->getName(), $controller); + $what = \sprintf('argument $%s of "%s()"', $argument->getName(), $controller); $message = preg_replace('/service "\.service_locator\.[^"]++"/', $what, $e->getMessage()); if ($e->getMessage() === $message) { - $message = sprintf('Cannot resolve %s: %s', $what, $message); + $message = \sprintf('Cannot resolve %s: %s', $what, $message); } $r = new \ReflectionProperty($e, 'message'); diff --git a/Controller/ArgumentResolver/UidValueResolver.php b/Controller/ArgumentResolver/UidValueResolver.php index 7a12e21ead..afe702300e 100644 --- a/Controller/ArgumentResolver/UidValueResolver.php +++ b/Controller/ArgumentResolver/UidValueResolver.php @@ -46,7 +46,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): array try { return [$uidClass::fromString($value)]; } catch (\InvalidArgumentException $e) { - throw new NotFoundHttpException(sprintf('The uid for the "%s" parameter is invalid.', $argument->getName()), $e); + throw new NotFoundHttpException(\sprintf('The uid for the "%s" parameter is invalid.', $argument->getName()), $e); } } } diff --git a/Controller/ArgumentResolver/VariadicValueResolver.php b/Controller/ArgumentResolver/VariadicValueResolver.php index 4f6cba729e..b4946698d1 100644 --- a/Controller/ArgumentResolver/VariadicValueResolver.php +++ b/Controller/ArgumentResolver/VariadicValueResolver.php @@ -42,7 +42,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): array $values = $request->attributes->get($argument->getName()); if (!\is_array($values)) { - throw new \InvalidArgumentException(sprintf('The action argument "...$%1$s" is required to be an array, the request attribute "%1$s" contains a type of "%2$s" instead.', $argument->getName(), get_debug_type($values))); + throw new \InvalidArgumentException(\sprintf('The action argument "...$%1$s" is required to be an array, the request attribute "%1$s" contains a type of "%2$s" instead.', $argument->getName(), get_debug_type($values))); } return $values; diff --git a/Controller/ContainerControllerResolver.php b/Controller/ContainerControllerResolver.php index 12232d58b5..5cd9edb31c 100644 --- a/Controller/ContainerControllerResolver.php +++ b/Controller/ContainerControllerResolver.php @@ -48,16 +48,16 @@ protected function instantiateController(string $class): object $this->throwExceptionIfControllerWasRemoved($class, $e); if ($e instanceof \ArgumentCountError) { - throw new \InvalidArgumentException(sprintf('Controller "%s" has required constructor arguments and does not exist in the container. Did you forget to define the controller as a service?', $class), 0, $e); + throw new \InvalidArgumentException(\sprintf('Controller "%s" has required constructor arguments and does not exist in the container. Did you forget to define the controller as a service?', $class), 0, $e); } - throw new \InvalidArgumentException(sprintf('Controller "%s" does neither exist as service nor as class.', $class), 0, $e); + throw new \InvalidArgumentException(\sprintf('Controller "%s" does neither exist as service nor as class.', $class), 0, $e); } private function throwExceptionIfControllerWasRemoved(string $controller, \Throwable $previous): void { if ($this->container instanceof Container && isset($this->container->getRemovedIds()[$controller])) { - throw new \InvalidArgumentException(sprintf('Controller "%s" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"?', $controller), 0, $previous); + throw new \InvalidArgumentException(\sprintf('Controller "%s" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"?', $controller), 0, $previous); } } } diff --git a/Controller/ControllerResolver.php b/Controller/ControllerResolver.php index 8424b02cc1..72ece351bf 100644 --- a/Controller/ControllerResolver.php +++ b/Controller/ControllerResolver.php @@ -74,7 +74,7 @@ public function getController(Request $request): callable|false } if (!\is_callable($controller)) { - throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$this->getControllerError($controller)); + throw new \InvalidArgumentException(\sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$this->getControllerError($controller)); } return $this->checkController($request, $controller); @@ -82,7 +82,7 @@ public function getController(Request $request): callable|false if (\is_object($controller)) { if (!\is_callable($controller)) { - throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$this->getControllerError($controller)); + throw new \InvalidArgumentException(\sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$this->getControllerError($controller)); } return $this->checkController($request, $controller); @@ -95,11 +95,11 @@ public function getController(Request $request): callable|false try { $callable = $this->createController($controller); } catch (\InvalidArgumentException $e) { - throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$e->getMessage(), 0, $e); + throw new \InvalidArgumentException(\sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$e->getMessage(), 0, $e); } if (!\is_callable($callable)) { - throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$this->getControllerError($callable)); + throw new \InvalidArgumentException(\sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$this->getControllerError($callable)); } return $this->checkController($request, $callable); @@ -159,19 +159,19 @@ private function getControllerError(mixed $callable): string if (str_contains($callable, '::')) { $callable = explode('::', $callable, 2); } else { - return sprintf('Function "%s" does not exist.', $callable); + return \sprintf('Function "%s" does not exist.', $callable); } } if (\is_object($callable)) { $availableMethods = $this->getClassMethodsWithoutMagicMethods($callable); - $alternativeMsg = $availableMethods ? sprintf(' or use one of the available methods: "%s"', implode('", "', $availableMethods)) : ''; + $alternativeMsg = $availableMethods ? \sprintf(' or use one of the available methods: "%s"', implode('", "', $availableMethods)) : ''; - return sprintf('Controller class "%s" cannot be called without a method name. You need to implement "__invoke"%s.', get_debug_type($callable), $alternativeMsg); + return \sprintf('Controller class "%s" cannot be called without a method name. You need to implement "__invoke"%s.', get_debug_type($callable), $alternativeMsg); } if (!\is_array($callable)) { - return sprintf('Invalid type for controller given, expected string, array or object, got "%s".', get_debug_type($callable)); + return \sprintf('Invalid type for controller given, expected string, array or object, got "%s".', get_debug_type($callable)); } if (!isset($callable[0]) || !isset($callable[1]) || 2 !== \count($callable)) { @@ -181,13 +181,13 @@ private function getControllerError(mixed $callable): string [$controller, $method] = $callable; if (\is_string($controller) && !class_exists($controller)) { - return sprintf('Class "%s" does not exist.', $controller); + return \sprintf('Class "%s" does not exist.', $controller); } $className = \is_object($controller) ? get_debug_type($controller) : $controller; if (method_exists($controller, $method)) { - return sprintf('Method "%s" on class "%s" should be public and non-abstract.', $method, $className); + return \sprintf('Method "%s" on class "%s" should be public and non-abstract.', $method, $className); } $collection = $this->getClassMethodsWithoutMagicMethods($controller); @@ -204,12 +204,12 @@ private function getControllerError(mixed $callable): string asort($alternatives); - $message = sprintf('Expected method "%s" on class "%s"', $method, $className); + $message = \sprintf('Expected method "%s" on class "%s"', $method, $className); if (\count($alternatives) > 0) { - $message .= sprintf(', did you mean "%s"?', implode('", "', $alternatives)); + $message .= \sprintf(', did you mean "%s"?', implode('", "', $alternatives)); } else { - $message .= sprintf('. Available methods: "%s".', implode('", "', $collection)); + $message .= \sprintf('. Available methods: "%s".', implode('", "', $collection)); } return $message; @@ -274,6 +274,6 @@ private function checkController(Request $request, callable $controller): callab return $controller; } - throw new BadRequestException(sprintf('Callable "%s()" is not allowed as a controller. Did you miss tagging it with "#[AsController]" or registering its type with "%s::allowControllers()"?', $name, self::class)); + throw new BadRequestException(\sprintf('Callable "%s()" is not allowed as a controller. Did you miss tagging it with "#[AsController]" or registering its type with "%s::allowControllers()"?', $name, self::class)); } } diff --git a/ControllerMetadata/ArgumentMetadata.php b/ControllerMetadata/ArgumentMetadata.php index dd6c8be86f..d3ca53fa63 100644 --- a/ControllerMetadata/ArgumentMetadata.php +++ b/ControllerMetadata/ArgumentMetadata.php @@ -94,7 +94,7 @@ public function isNullable(): bool public function getDefaultValue(): mixed { if (!$this->hasDefaultValue) { - throw new \LogicException(sprintf('Argument $%s does not have a default value. Use "%s::hasDefaultValue()" to avoid this exception.', $this->name, __CLASS__)); + throw new \LogicException(\sprintf('Argument $%s does not have a default value. Use "%s::hasDefaultValue()" to avoid this exception.', $this->name, __CLASS__)); } return $this->defaultValue; diff --git a/DataCollector/ConfigDataCollector.php b/DataCollector/ConfigDataCollector.php index f9ca5da1d6..ba8fc0c317 100644 --- a/DataCollector/ConfigDataCollector.php +++ b/DataCollector/ConfigDataCollector.php @@ -47,7 +47,7 @@ public function collect(Request $request, Response $response, ?\Throwable $excep $this->data = [ 'token' => $response->headers->get('X-Debug-Token'), 'symfony_version' => Kernel::VERSION, - 'symfony_minor_version' => sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION), + 'symfony_minor_version' => \sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION), 'symfony_lts' => 4 === Kernel::MINOR_VERSION, 'symfony_state' => $this->determineSymfonyState(), 'symfony_eom' => $eom->format('F Y'), diff --git a/DataCollector/DumpDataCollector.php b/DataCollector/DumpDataCollector.php index 0a46a8cd4e..2300acf914 100644 --- a/DataCollector/DumpDataCollector.php +++ b/DataCollector/DumpDataCollector.php @@ -196,7 +196,7 @@ public function getDumps(string $format, int $maxDepthLimit = -1, int $maxItemsP $dumper = new HtmlDumper($data, $this->charset); $dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]); } else { - throw new \InvalidArgumentException(sprintf('Invalid dump format: "%s".', $format)); + throw new \InvalidArgumentException(\sprintf('Invalid dump format: "%s".', $format)); } $dumps = []; @@ -263,9 +263,9 @@ private function doDump(DataDumperInterface $dumper, Data $data, string $name, s $f = strip_tags($this->style('', $file)); $name = strip_tags($this->style('', $name)); if ($fmt && $link = \is_string($fmt) ? strtr($fmt, ['%f' => $file, '%l' => $line]) : $fmt->format($file, $line)) { - $name = sprintf(''.$s.'', strip_tags($this->style('', $link)), $f, $name); + $name = \sprintf(''.$s.'', strip_tags($this->style('', $link)), $f, $name); } else { - $name = sprintf(''.$s.'', $f, $name); + $name = \sprintf(''.$s.'', $f, $name); } } else { $name = $this->style('meta', $name); diff --git a/DataCollector/RequestDataCollector.php b/DataCollector/RequestDataCollector.php index 12951b495c..4792f160c0 100644 --- a/DataCollector/RequestDataCollector.php +++ b/DataCollector/RequestDataCollector.php @@ -452,7 +452,7 @@ public function collectSessionUsage(): void array_splice($trace, 0, $traceEndIndex); // Merge identical backtraces generated by internal call reports - $name = sprintf('%s:%s', $trace[1]['class'] ?? $trace[0]['file'], $trace[0]['line']); + $name = \sprintf('%s:%s', $trace[1]['class'] ?? $trace[0]['file'], $trace[0]['line']); if (!\array_key_exists($name, $this->sessionUsages)) { $this->sessionUsages[$name] = [ 'name' => $name, diff --git a/DependencyInjection/FragmentRendererPass.php b/DependencyInjection/FragmentRendererPass.php index f41d58b81b..9a32b8a4eb 100644 --- a/DependencyInjection/FragmentRendererPass.php +++ b/DependencyInjection/FragmentRendererPass.php @@ -41,10 +41,10 @@ public function process(ContainerBuilder $container) $class = $container->getParameterBag()->resolveValue($def->getClass()); if (!$r = $container->getReflectionClass($class)) { - throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id)); + throw new InvalidArgumentException(\sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id)); } if (!$r->isSubclassOf(FragmentRendererInterface::class)) { - throw new InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, FragmentRendererInterface::class)); + throw new InvalidArgumentException(\sprintf('Service "%s" must implement interface "%s".', $id, FragmentRendererInterface::class)); } foreach ($tags as $tag) { diff --git a/DependencyInjection/RegisterControllerArgumentLocatorsPass.php b/DependencyInjection/RegisterControllerArgumentLocatorsPass.php index 7d13c223a6..e2f50dcba1 100644 --- a/DependencyInjection/RegisterControllerArgumentLocatorsPass.php +++ b/DependencyInjection/RegisterControllerArgumentLocatorsPass.php @@ -73,7 +73,7 @@ public function process(ContainerBuilder $container) $class = $parameterBag->resolveValue($class); if (!$r = $container->getReflectionClass($class)) { - throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id)); + throw new InvalidArgumentException(\sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id)); } $controllerClasses[] = $class; @@ -98,11 +98,11 @@ public function process(ContainerBuilder $container) } foreach (['action', 'argument', 'id'] as $k) { if (!isset($attributes[$k][0])) { - throw new InvalidArgumentException(sprintf('Missing "%s" attribute on tag "controller.service_arguments" %s for service "%s".', $k, json_encode($attributes, \JSON_UNESCAPED_UNICODE), $id)); + throw new InvalidArgumentException(\sprintf('Missing "%s" attribute on tag "controller.service_arguments" %s for service "%s".', $k, json_encode($attributes, \JSON_UNESCAPED_UNICODE), $id)); } } if (!isset($methods[$action = strtolower($attributes['action'])])) { - throw new InvalidArgumentException(sprintf('Invalid "action" attribute on tag "controller.service_arguments" for service "%s": no public "%s()" method found on class "%s".', $id, $attributes['action'], $class)); + throw new InvalidArgumentException(\sprintf('Invalid "action" attribute on tag "controller.service_arguments" for service "%s": no public "%s()" method found on class "%s".', $id, $attributes['action'], $class)); } [$r, $parameters] = $methods[$action]; $found = false; @@ -118,7 +118,7 @@ public function process(ContainerBuilder $container) } if (!$found) { - throw new InvalidArgumentException(sprintf('Invalid "controller.service_arguments" tag for service "%s": method "%s()" has no "%s" argument on class "%s".', $id, $r->name, $attributes['argument'], $class)); + throw new InvalidArgumentException(\sprintf('Invalid "controller.service_arguments" tag for service "%s": method "%s()" has no "%s" argument on class "%s".', $id, $r->name, $attributes['argument'], $class)); } } @@ -140,7 +140,7 @@ public function process(ContainerBuilder $container) if ('?' !== $target[0]) { $invalidBehavior = ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE; } elseif ('' === $target = (string) substr($target, 1)) { - throw new InvalidArgumentException(sprintf('A "controller.service_arguments" tag must have non-empty "id" attributes for service "%s".', $id)); + throw new InvalidArgumentException(\sprintf('A "controller.service_arguments" tag must have non-empty "id" attributes for service "%s".', $id)); } elseif ($p->allowsNull() && !$p->isOptional()) { $invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE; } @@ -191,7 +191,7 @@ public function process(ContainerBuilder $container) } if ($type && !$p->isOptional() && !$p->allowsNull() && !class_exists($type) && !interface_exists($type, false)) { - $message = sprintf('Cannot determine controller argument for "%s::%s()": the $%s argument is type-hinted with the non-existent class or interface: "%s".', $class, $r->name, $p->name, $type); + $message = \sprintf('Cannot determine controller argument for "%s::%s()": the $%s argument is type-hinted with the non-existent class or interface: "%s".', $class, $r->name, $p->name, $type); // see if the type-hint lives in the same namespace as the controller if (0 === strncmp($type, $class, strrpos($class, '\\'))) { diff --git a/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php b/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php index 7a21fe0e59..ef859a611b 100644 --- a/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php +++ b/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php @@ -34,7 +34,7 @@ public function process(ContainerBuilder $container) if (!$argumentLocator->getArgument(0)) { // remove empty argument locators - $reason = sprintf('Removing service-argument resolver for controller "%s": no corresponding services exist for the referenced types.', $controller); + $reason = \sprintf('Removing service-argument resolver for controller "%s": no corresponding services exist for the referenced types.', $controller); } else { // any methods listed for call-at-instantiation cannot be actions $reason = false; @@ -47,7 +47,7 @@ public function process(ContainerBuilder $container) $controllerDef = $container->getDefinition($id); foreach ($controllerDef->getMethodCalls() as [$method]) { if (0 === strcasecmp($action, $method)) { - $reason = sprintf('Removing method "%s" of service "%s" from controller candidates: the method is called at instantiation, thus cannot be an action.', $action, $id); + $reason = \sprintf('Removing method "%s" of service "%s" from controller candidates: the method is called at instantiation, thus cannot be an action.', $action, $id); break; } } diff --git a/DependencyInjection/ResettableServicePass.php b/DependencyInjection/ResettableServicePass.php index da9f8d6320..8479c8d630 100644 --- a/DependencyInjection/ResettableServicePass.php +++ b/DependencyInjection/ResettableServicePass.php @@ -39,7 +39,7 @@ public function process(ContainerBuilder $container) foreach ($tags as $attributes) { if (!isset($attributes['method'])) { - throw new RuntimeException(sprintf('Tag "kernel.reset" requires the "method" attribute to be set on service "%s".', $id)); + throw new RuntimeException(\sprintf('Tag "kernel.reset" requires the "method" attribute to be set on service "%s".', $id)); } if (!isset($methods[$id])) { diff --git a/EventListener/ErrorListener.php b/EventListener/ErrorListener.php index 7aa4875e5a..266d96cf8e 100644 --- a/EventListener/ErrorListener.php +++ b/EventListener/ErrorListener.php @@ -90,7 +90,7 @@ public function logKernelException(ExceptionEvent $event) $e = FlattenException::createFromThrowable($throwable); - $this->logException($throwable, sprintf('Uncaught PHP Exception %s: "%s" at %s line %s', $e->getClass(), $e->getMessage(), basename($e->getFile()), $e->getLine()), $logLevel); + $this->logException($throwable, \sprintf('Uncaught PHP Exception %s: "%s" at %s line %s', $e->getClass(), $e->getMessage(), basename($e->getFile()), $e->getLine()), $logLevel); } /** @@ -118,7 +118,7 @@ public function onKernelException(ExceptionEvent $event) } catch (\Exception $e) { $f = FlattenException::createFromThrowable($e); - $this->logException($e, sprintf('Exception thrown when handling an exception (%s: %s at %s line %s)', $f->getClass(), $f->getMessage(), basename($e->getFile()), $e->getLine())); + $this->logException($e, \sprintf('Exception thrown when handling an exception (%s: %s at %s line %s)', $f->getClass(), $f->getMessage(), basename($e->getFile()), $e->getLine())); $prev = $e; do { diff --git a/EventListener/RouterListener.php b/EventListener/RouterListener.php index f4406ade49..fd8ac1a5c6 100644 --- a/EventListener/RouterListener.php +++ b/EventListener/RouterListener.php @@ -118,15 +118,15 @@ public function onKernelRequest(RequestEvent $event): void unset($parameters['_route'], $parameters['_controller']); $request->attributes->set('_route_params', $parameters); } catch (ResourceNotFoundException $e) { - $message = sprintf('No route found for "%s %s"', $request->getMethod(), $request->getUriForPath($request->getPathInfo())); + $message = \sprintf('No route found for "%s %s"', $request->getMethod(), $request->getUriForPath($request->getPathInfo())); if ($referer = $request->headers->get('referer')) { - $message .= sprintf(' (from "%s")', $referer); + $message .= \sprintf(' (from "%s")', $referer); } throw new NotFoundHttpException($message, $e); } catch (MethodNotAllowedException $e) { - $message = sprintf('No route found for "%s %s": Method Not Allowed (Allow: %s)', $request->getMethod(), $request->getUriForPath($request->getPathInfo()), implode(', ', $e->getAllowedMethods())); + $message = \sprintf('No route found for "%s %s": Method Not Allowed (Allow: %s)', $request->getMethod(), $request->getUriForPath($request->getPathInfo()), implode(', ', $e->getAllowedMethods())); throw new MethodNotAllowedHttpException($e->getAllowedMethods(), $message, $e); } diff --git a/Exception/ResolverNotFoundException.php b/Exception/ResolverNotFoundException.php index 6d9fb8a01f..aa859d5115 100644 --- a/Exception/ResolverNotFoundException.php +++ b/Exception/ResolverNotFoundException.php @@ -18,7 +18,7 @@ class ResolverNotFoundException extends \RuntimeException */ public function __construct(string $name, array $alternatives = []) { - $msg = sprintf('You have requested a non-existent resolver "%s".', $name); + $msg = \sprintf('You have requested a non-existent resolver "%s".', $name); if ($alternatives) { if (1 === \count($alternatives)) { $msg .= ' Did you mean this: "'; diff --git a/Fragment/FragmentHandler.php b/Fragment/FragmentHandler.php index 62b21e6d4e..7452424192 100644 --- a/Fragment/FragmentHandler.php +++ b/Fragment/FragmentHandler.php @@ -73,7 +73,7 @@ public function render(string|ControllerReference $uri, string $renderer = 'inli } if (!isset($this->renderers[$renderer])) { - throw new \InvalidArgumentException(sprintf('The "%s" renderer does not exist.', $renderer)); + throw new \InvalidArgumentException(\sprintf('The "%s" renderer does not exist.', $renderer)); } if (!$request = $this->requestStack->getCurrentRequest()) { @@ -97,7 +97,7 @@ protected function deliver(Response $response): ?string { if (!$response->isSuccessful()) { $responseStatusCode = $response->getStatusCode(); - throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %d).', $this->requestStack->getCurrentRequest()->getUri(), $responseStatusCode), 0, new HttpException($responseStatusCode)); + throw new \RuntimeException(\sprintf('Error when rendering "%s" (Status code is %d).', $this->requestStack->getCurrentRequest()->getUri(), $responseStatusCode), 0, new HttpException($responseStatusCode)); } if (!$response instanceof StreamedResponse) { diff --git a/Fragment/FragmentUriGenerator.php b/Fragment/FragmentUriGenerator.php index 59423293e8..aeb1f71239 100644 --- a/Fragment/FragmentUriGenerator.php +++ b/Fragment/FragmentUriGenerator.php @@ -83,7 +83,7 @@ private function checkNonScalar(array $values): void if (\is_array($value)) { $this->checkNonScalar($value); } elseif (!\is_scalar($value) && null !== $value) { - throw new \LogicException(sprintf('Controller attributes cannot contain non-scalar/non-null values (value for key "%s" is not a scalar or null).', $key)); + throw new \LogicException(\sprintf('Controller attributes cannot contain non-scalar/non-null values (value for key "%s" is not a scalar or null).', $key)); } } } diff --git a/Fragment/HIncludeFragmentRenderer.php b/Fragment/HIncludeFragmentRenderer.php index edcf9938c4..9cb01f321e 100644 --- a/Fragment/HIncludeFragmentRenderer.php +++ b/Fragment/HIncludeFragmentRenderer.php @@ -79,7 +79,7 @@ public function render(string|ControllerReference $uri, Request $request, array if (\count($attributes) > 0) { $flags = \ENT_QUOTES | \ENT_SUBSTITUTE; foreach ($attributes as $attribute => $value) { - $renderedAttributes .= sprintf( + $renderedAttributes .= \sprintf( ' %s="%s"', htmlspecialchars($attribute, $flags, $this->charset, false), htmlspecialchars($value, $flags, $this->charset, false) @@ -87,7 +87,7 @@ public function render(string|ControllerReference $uri, Request $request, array } } - return new Response(sprintf('%s', $uri, $renderedAttributes, $content)); + return new Response(\sprintf('%s', $uri, $renderedAttributes, $content)); } public function getName(): string diff --git a/HttpCache/AbstractSurrogate.php b/HttpCache/AbstractSurrogate.php index 95518bed2b..152aedad08 100644 --- a/HttpCache/AbstractSurrogate.php +++ b/HttpCache/AbstractSurrogate.php @@ -56,7 +56,7 @@ public function hasSurrogateCapability(Request $request): bool return false; } - return str_contains($value, sprintf('%s/1.0', strtoupper($this->getName()))); + return str_contains($value, \sprintf('%s/1.0', strtoupper($this->getName()))); } /** @@ -65,7 +65,7 @@ public function hasSurrogateCapability(Request $request): bool public function addSurrogateCapability(Request $request) { $current = $request->headers->get('Surrogate-Capability'); - $new = sprintf('symfony="%s/1.0"', strtoupper($this->getName())); + $new = \sprintf('symfony="%s/1.0"', strtoupper($this->getName())); $request->headers->set('Surrogate-Capability', $current ? $current.', '.$new : $new); } @@ -76,7 +76,7 @@ public function needsParsing(Response $response): bool return false; } - $pattern = sprintf('#content="[^"]*%s/1.0[^"]*"#', strtoupper($this->getName())); + $pattern = \sprintf('#content="[^"]*%s/1.0[^"]*"#', strtoupper($this->getName())); return (bool) preg_match($pattern, $control); } @@ -89,7 +89,7 @@ public function handle(HttpCache $cache, string $uri, string $alt, bool $ignoreE $response = $cache->handle($subRequest, HttpKernelInterface::SUB_REQUEST, true); if (!$response->isSuccessful() && Response::HTTP_NOT_MODIFIED !== $response->getStatusCode()) { - throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %d).', $subRequest->getUri(), $response->getStatusCode())); + throw new \RuntimeException(\sprintf('Error when rendering "%s" (Status code is %d).', $subRequest->getUri(), $response->getStatusCode())); } return $response->getContent(); @@ -120,12 +120,12 @@ protected function removeFromControl(Response $response) $value = $response->headers->get('Surrogate-Control'); $upperName = strtoupper($this->getName()); - if (sprintf('content="%s/1.0"', $upperName) == $value) { + if (\sprintf('content="%s/1.0"', $upperName) == $value) { $response->headers->remove('Surrogate-Control'); - } elseif (preg_match(sprintf('#,\s*content="%s/1.0"#', $upperName), $value)) { - $response->headers->set('Surrogate-Control', preg_replace(sprintf('#,\s*content="%s/1.0"#', $upperName), '', $value)); - } elseif (preg_match(sprintf('#content="%s/1.0",\s*#', $upperName), $value)) { - $response->headers->set('Surrogate-Control', preg_replace(sprintf('#content="%s/1.0",\s*#', $upperName), '', $value)); + } elseif (preg_match(\sprintf('#,\s*content="%s/1.0"#', $upperName), $value)) { + $response->headers->set('Surrogate-Control', preg_replace(\sprintf('#,\s*content="%s/1.0"#', $upperName), '', $value)); + } elseif (preg_match(\sprintf('#content="%s/1.0",\s*#', $upperName), $value)) { + $response->headers->set('Surrogate-Control', preg_replace(\sprintf('#content="%s/1.0",\s*#', $upperName), '', $value)); } } diff --git a/HttpCache/Esi.php b/HttpCache/Esi.php index e8faf0fdbd..92b41a5dd6 100644 --- a/HttpCache/Esi.php +++ b/HttpCache/Esi.php @@ -44,14 +44,14 @@ public function addSurrogateControl(Response $response) public function renderIncludeTag(string $uri, ?string $alt = null, bool $ignoreErrors = true, string $comment = ''): string { - $html = sprintf('', + $html = \sprintf('', $uri, $ignoreErrors ? ' onerror="continue"' : '', - $alt ? sprintf(' alt="%s"', $alt) : '' + $alt ? \sprintf(' alt="%s"', $alt) : '' ); if (!empty($comment)) { - return sprintf("\n%s", $comment, $html); + return \sprintf("\n%s", $comment, $html); } return $html; diff --git a/HttpCache/HttpCache.php b/HttpCache/HttpCache.php index bce0e99b5e..8d1a3a5791 100644 --- a/HttpCache/HttpCache.php +++ b/HttpCache/HttpCache.php @@ -158,7 +158,7 @@ public function getLog(): string { $log = []; foreach ($this->traces as $request => $traces) { - $log[] = sprintf('%s: %s', $request, implode(', ', $traces)); + $log[] = \sprintf('%s: %s', $request, implode(', ', $traces)); } return implode('; ', $log); diff --git a/HttpCache/ResponseCacheStrategy.php b/HttpCache/ResponseCacheStrategy.php index bf7ec78f20..05670967a5 100644 --- a/HttpCache/ResponseCacheStrategy.php +++ b/HttpCache/ResponseCacheStrategy.php @@ -37,7 +37,7 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface private int $embeddedResponses = 0; private bool $isNotCacheableResponseEmbedded = false; private int $age = 0; - private \DateTimeInterface|null|false $lastModified = null; + private \DateTimeInterface|false|null $lastModified = null; private array $flagDirectives = [ 'no-cache' => null, 'no-store' => null, @@ -228,7 +228,7 @@ private function storeRelativeAgeDirective(string $directive, ?int $value, ?int } if (false !== $this->ageDirectives[$directive]) { - $value = min($value ?? PHP_INT_MAX, $expires ?? PHP_INT_MAX); + $value = min($value ?? \PHP_INT_MAX, $expires ?? \PHP_INT_MAX); $value -= $age; $this->ageDirectives[$directive] = null !== $this->ageDirectives[$directive] ? min($this->ageDirectives[$directive], $value) : $value; } diff --git a/HttpCache/Ssi.php b/HttpCache/Ssi.php index 8cf4e49077..9e0839d63d 100644 --- a/HttpCache/Ssi.php +++ b/HttpCache/Ssi.php @@ -38,7 +38,7 @@ public function addSurrogateControl(Response $response) public function renderIncludeTag(string $uri, ?string $alt = null, bool $ignoreErrors = true, string $comment = ''): string { - return sprintf('', $uri); + return \sprintf('', $uri); } public function process(Request $request, Response $response): Response diff --git a/HttpCache/Store.php b/HttpCache/Store.php index 7f7f1a1a14..473537d85b 100644 --- a/HttpCache/Store.php +++ b/HttpCache/Store.php @@ -45,7 +45,7 @@ public function __construct(string $root, array $options = []) { $this->root = $root; if (!is_dir($this->root) && !@mkdir($this->root, 0777, true) && !is_dir($this->root)) { - throw new \RuntimeException(sprintf('Unable to create the store directory (%s).', $this->root)); + throw new \RuntimeException(\sprintf('Unable to create the store directory (%s).', $this->root)); } $this->keyCache = new \SplObjectStorage(); $this->options = array_merge([ diff --git a/HttpCache/SubRequestHandler.php b/HttpCache/SubRequestHandler.php index 253071f07d..4caf3daf2e 100644 --- a/HttpCache/SubRequestHandler.php +++ b/HttpCache/SubRequestHandler.php @@ -51,16 +51,16 @@ public static function handle(HttpKernelInterface $kernel, Request $request, int $trustedValues = []; foreach (array_reverse($request->getClientIps()) as $ip) { $trustedIps[] = $ip; - $trustedValues[] = sprintf('for="%s"', $ip); + $trustedValues[] = \sprintf('for="%s"', $ip); } if ($ip !== $remoteAddr) { $trustedIps[] = $remoteAddr; - $trustedValues[] = sprintf('for="%s"', $remoteAddr); + $trustedValues[] = \sprintf('for="%s"', $remoteAddr); } // set trusted values, reusing as much as possible the global trusted settings if (Request::HEADER_FORWARDED & $trustedHeaderSet) { - $trustedValues[0] .= sprintf(';host="%s";proto=%s', $request->getHttpHost(), $request->getScheme()); + $trustedValues[0] .= \sprintf(';host="%s";proto=%s', $request->getHttpHost(), $request->getScheme()); $request->headers->set('Forwarded', $v = implode(', ', $trustedValues)); $request->server->set('HTTP_FORWARDED', $v); } diff --git a/HttpClientKernel.php b/HttpClientKernel.php index 7c719e8e61..ebda2750da 100644 --- a/HttpClientKernel.php +++ b/HttpClientKernel.php @@ -36,7 +36,7 @@ final class HttpClientKernel implements HttpKernelInterface public function __construct(?HttpClientInterface $client = null) { if (null === $client && !class_exists(HttpClient::class)) { - throw new \LogicException(sprintf('You cannot use "%s" as the HttpClient component is not installed. Try running "composer require symfony/http-client".', __CLASS__)); + throw new \LogicException(\sprintf('You cannot use "%s" as the HttpClient component is not installed. Try running "composer require symfony/http-client".', __CLASS__)); } $this->client = $client ?? HttpClient::create(); diff --git a/HttpKernel.php b/HttpKernel.php index 6460bebbdd..886fca9cf5 100644 --- a/HttpKernel.php +++ b/HttpKernel.php @@ -162,7 +162,7 @@ private function handleRaw(Request $request, int $type = self::MAIN_REQUEST): Re // load controller if (false === $controller = $this->resolver->getController($request)) { - throw new NotFoundHttpException(sprintf('Unable to find the controller for path "%s". The route is wrongly configured.', $request->getPathInfo())); + throw new NotFoundHttpException(\sprintf('Unable to find the controller for path "%s". The route is wrongly configured.', $request->getPathInfo())); } $event = new ControllerEvent($this, $controller, $request, $type); @@ -188,7 +188,7 @@ private function handleRaw(Request $request, int $type = self::MAIN_REQUEST): Re if ($event->hasResponse()) { $response = $event->getResponse(); } else { - $msg = sprintf('The controller must return a "Symfony\Component\HttpFoundation\Response" object but it returned %s.', $this->varToString($response)); + $msg = \sprintf('The controller must return a "Symfony\Component\HttpFoundation\Response" object but it returned %s.', $this->varToString($response)); // the user may have forgotten to return something if (null === $response) { @@ -278,20 +278,20 @@ private function handleThrowable(\Throwable $e, Request $request, int $type): Re private function varToString(mixed $var): string { if (\is_object($var)) { - return sprintf('an object of type %s', $var::class); + return \sprintf('an object of type %s', $var::class); } if (\is_array($var)) { $a = []; foreach ($var as $k => $v) { - $a[] = sprintf('%s => ...', $k); + $a[] = \sprintf('%s => ...', $k); } - return sprintf('an array ([%s])', mb_substr(implode(', ', $a), 0, 255)); + return \sprintf('an array ([%s])', mb_substr(implode(', ', $a), 0, 255)); } if (\is_resource($var)) { - return sprintf('a resource (%s)', get_resource_type($var)); + return \sprintf('a resource (%s)', get_resource_type($var)); } if (null === $var) { @@ -307,11 +307,11 @@ private function varToString(mixed $var): string } if (\is_string($var)) { - return sprintf('a string ("%s%s")', mb_substr($var, 0, 255), mb_strlen($var) > 255 ? '...' : ''); + return \sprintf('a string ("%s%s")', mb_substr($var, 0, 255), mb_strlen($var) > 255 ? '...' : ''); } if (is_numeric($var)) { - return sprintf('a number (%s)', (string) $var); + return \sprintf('a number (%s)', (string) $var); } return (string) $var; diff --git a/Kernel.php b/Kernel.php index 761461f616..9a9aa07ab0 100644 --- a/Kernel.php +++ b/Kernel.php @@ -89,7 +89,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl public function __construct(string $environment, bool $debug) { if (!$this->environment = $environment) { - throw new \InvalidArgumentException(sprintf('Invalid environment provided to "%s": the environment cannot be empty.', get_debug_type($this))); + throw new \InvalidArgumentException(\sprintf('Invalid environment provided to "%s": the environment cannot be empty.', get_debug_type($this))); } $this->debug = $debug; @@ -216,7 +216,7 @@ public function getBundles(): array public function getBundle(string $name): BundleInterface { if (!isset($this->bundles[$name])) { - throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the "registerBundles()" method of your "%s.php" file?', $name, get_debug_type($this))); + throw new \InvalidArgumentException(\sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the "registerBundles()" method of your "%s.php" file?', $name, get_debug_type($this))); } return $this->bundles[$name]; @@ -225,11 +225,11 @@ public function getBundle(string $name): BundleInterface public function locateResource(string $name): string { if ('@' !== $name[0]) { - throw new \InvalidArgumentException(sprintf('A resource name must start with @ ("%s" given).', $name)); + throw new \InvalidArgumentException(\sprintf('A resource name must start with @ ("%s" given).', $name)); } if (str_contains($name, '..')) { - throw new \RuntimeException(sprintf('File name "%s" contains invalid characters (..).', $name)); + throw new \RuntimeException(\sprintf('File name "%s" contains invalid characters (..).', $name)); } $bundleName = substr($name, 1); @@ -243,7 +243,7 @@ public function locateResource(string $name): string return $file; } - throw new \InvalidArgumentException(sprintf('Unable to find file "%s".', $name)); + throw new \InvalidArgumentException(\sprintf('Unable to find file "%s".', $name)); } public function getEnvironment(): string @@ -265,7 +265,7 @@ public function getProjectDir(): string $r = new \ReflectionObject($this); if (!is_file($dir = $r->getFileName())) { - throw new \LogicException(sprintf('Cannot auto-detect project dir for kernel of class "%s".', $r->name)); + throw new \LogicException(\sprintf('Cannot auto-detect project dir for kernel of class "%s".', $r->name)); } $dir = $rootDir = \dirname($dir); @@ -295,7 +295,7 @@ public function getContainer(): ContainerInterface */ public function setAnnotatedClassCache(array $annotatedClasses): void { - file_put_contents(($this->warmupDir ?: $this->getBuildDir()).'/annotations.map', sprintf('warmupDir ?: $this->getBuildDir()).'/annotations.map', \sprintf('registerBundles() as $bundle) { $name = $bundle->getName(); if (isset($this->bundles[$name])) { - throw new \LogicException(sprintf('Trying to register two bundles with the same name "%s".', $name)); + throw new \LogicException(\sprintf('Trying to register two bundles with the same name "%s".', $name)); } $this->bundles[$name] = $bundle; } @@ -375,7 +375,7 @@ protected function getContainerClass(): string $class = str_replace('\\', '_', $class).ucfirst($this->environment).($this->debug ? 'Debug' : '').'Container'; if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $class)) { - throw new \InvalidArgumentException(sprintf('The environment "%s" contains invalid characters, it can only contain characters allowed in PHP class names.', $this->environment)); + throw new \InvalidArgumentException(\sprintf('The environment "%s" contains invalid characters, it can only contain characters allowed in PHP class names.', $this->environment)); } return $class; @@ -604,10 +604,10 @@ protected function buildContainer(): ContainerBuilder foreach (['cache' => $this->getCacheDir(), 'build' => $this->warmupDir ?: $this->getBuildDir(), 'logs' => $this->getLogDir()] as $name => $dir) { if (!is_dir($dir)) { if (false === @mkdir($dir, 0777, true) && !is_dir($dir)) { - throw new \RuntimeException(sprintf('Unable to create the "%s" directory (%s).', $name, $dir)); + throw new \RuntimeException(\sprintf('Unable to create the "%s" directory (%s).', $name, $dir)); } } elseif (!is_writable($dir)) { - throw new \RuntimeException(sprintf('Unable to write in the "%s" directory (%s).', $name, $dir)); + throw new \RuntimeException(\sprintf('Unable to write in the "%s" directory (%s).', $name, $dir)); } } diff --git a/Log/Logger.php b/Log/Logger.php index 50578a25e7..93c1dbc95b 100644 --- a/Log/Logger.php +++ b/Log/Logger.php @@ -74,13 +74,13 @@ public function __construct(?string $minLevel = null, $output = null, ?callable } if (!isset(self::LEVELS[$minLevel])) { - throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $minLevel)); + throw new InvalidArgumentException(\sprintf('The log level "%s" does not exist.', $minLevel)); } $this->minLevelIndex = self::LEVELS[$minLevel]; $this->formatter = null !== $formatter ? $formatter(...) : $this->format(...); if ($output && false === $this->handle = \is_string($output) ? @fopen($output, 'a') : $output) { - throw new InvalidArgumentException(sprintf('Unable to open "%s".', $output)); + throw new InvalidArgumentException(\sprintf('Unable to open "%s".', $output)); } $this->debug = $debug; } @@ -93,7 +93,7 @@ public function enableDebug(): void public function log($level, $message, array $context = []): void { if (!isset(self::LEVELS[$level])) { - throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level)); + throw new InvalidArgumentException(\sprintf('The log level "%s" does not exist.', $level)); } if (self::LEVELS[$level] < $this->minLevelIndex) { @@ -155,7 +155,7 @@ private function format(string $level, string $message, array $context, bool $pr $message = strtr($message, $replacements); } - $log = sprintf('[%s] %s', $level, $message); + $log = \sprintf('[%s] %s', $level, $message); if ($prefixDate) { $log = date(\DateTimeInterface::RFC3339).' '.$log; } diff --git a/Profiler/FileProfilerStorage.php b/Profiler/FileProfilerStorage.php index d2372c30e3..f1e28bc2b8 100644 --- a/Profiler/FileProfilerStorage.php +++ b/Profiler/FileProfilerStorage.php @@ -33,12 +33,12 @@ class FileProfilerStorage implements ProfilerStorageInterface public function __construct(string $dsn) { if (!str_starts_with($dsn, 'file:')) { - throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use FileStorage with an invalid dsn "%s". The expected format is "file:/path/to/the/storage/folder".', $dsn)); + throw new \RuntimeException(\sprintf('Please check your configuration. You are trying to use FileStorage with an invalid dsn "%s". The expected format is "file:/path/to/the/storage/folder".', $dsn)); } $this->folder = substr($dsn, 5); if (!is_dir($this->folder) && false === @mkdir($this->folder, 0777, true) && !is_dir($this->folder)) { - throw new \RuntimeException(sprintf('Unable to create the storage directory (%s).', $this->folder)); + throw new \RuntimeException(\sprintf('Unable to create the storage directory (%s).', $this->folder)); } } @@ -144,7 +144,7 @@ public function write(Profile $profile): bool // Create directory $dir = \dirname($file); if (!is_dir($dir) && false === @mkdir($dir, 0777, true) && !is_dir($dir)) { - throw new \RuntimeException(sprintf('Unable to create the storage directory (%s).', $dir)); + throw new \RuntimeException(\sprintf('Unable to create the storage directory (%s).', $dir)); } } diff --git a/Profiler/Profile.php b/Profiler/Profile.php index 08e7b65a21..91ae51e958 100644 --- a/Profiler/Profile.php +++ b/Profiler/Profile.php @@ -232,7 +232,7 @@ public function getChildByToken(string $token): ?self public function getCollector(string $name): DataCollectorInterface { if (!isset($this->collectors[$name])) { - throw new \InvalidArgumentException(sprintf('Collector "%s" does not exist.', $name)); + throw new \InvalidArgumentException(\sprintf('Collector "%s" does not exist.', $name)); } return $this->collectors[$name]; diff --git a/Profiler/Profiler.php b/Profiler/Profiler.php index fd5b28531e..65adf0f17d 100644 --- a/Profiler/Profiler.php +++ b/Profiler/Profiler.php @@ -239,7 +239,7 @@ public function has(string $name): bool public function get(string $name): DataCollectorInterface { if (!isset($this->collectors[$name])) { - throw new \InvalidArgumentException(sprintf('Collector "%s" does not exist.', $name)); + throw new \InvalidArgumentException(\sprintf('Collector "%s" does not exist.', $name)); } return $this->collectors[$name]; diff --git a/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php b/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php index 1b4c20672a..033b23a2b3 100644 --- a/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php +++ b/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php @@ -173,7 +173,7 @@ public function testNullPayloadAndNotDefaultOrNullableArgument() try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $this->assertSame(422, $e->getStatusCode()); } @@ -198,7 +198,7 @@ public function testQueryNullPayloadAndNotDefaultOrNullableArgument() try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $this->assertSame(404, $e->getStatusCode()); } @@ -222,7 +222,7 @@ public function testWithoutValidatorAndCouldNotDenormalize() try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $this->assertInstanceOf(PartialDenormalizationException::class, $e->getPrevious()); } @@ -250,12 +250,12 @@ public function testValidationNotPassed() try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $validationFailedException = $e->getPrevious(); $this->assertSame(422, $e->getStatusCode()); $this->assertInstanceOf(ValidationFailedException::class, $validationFailedException); - $this->assertSame(sprintf('This value should be of type %s.', class_exists(InvalidTypeException::class) ? 'string' : 'unknown'), $validationFailedException->getViolations()[0]->getMessage()); + $this->assertSame(\sprintf('This value should be of type %s.', class_exists(InvalidTypeException::class) ? 'string' : 'unknown'), $validationFailedException->getViolations()[0]->getMessage()); } } @@ -281,7 +281,7 @@ public function testValidationNotPerformedWhenPartialDenormalizationReturnsViola try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $validationFailedException = $e->getPrevious(); $this->assertInstanceOf(ValidationFailedException::class, $validationFailedException); @@ -306,7 +306,7 @@ public function testUnsupportedMedia() try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $this->assertSame(415, $e->getStatusCode()); } @@ -419,7 +419,7 @@ public function testQueryStringParameterTypeMismatch() try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $validationFailedException = $e->getPrevious(); $this->assertInstanceOf(ValidationFailedException::class, $validationFailedException); @@ -479,7 +479,7 @@ public function testRequestInputTypeMismatch() try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $validationFailedException = $e->getPrevious(); $this->assertInstanceOf(ValidationFailedException::class, $validationFailedException); @@ -588,7 +588,7 @@ public function testAcceptFormatNotPassed(mixed $acceptFormat, string $contentTy try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $this->assertSame(415, $e->getStatusCode()); $this->assertSame($expectedExceptionMessage, $e->getMessage()); @@ -684,7 +684,7 @@ public function testValidationGroupsNotPassed(string $method, ValueResolver $att try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $validationFailedException = $e->getPrevious(); $this->assertInstanceOf(ValidationFailedException::class, $validationFailedException); @@ -749,7 +749,7 @@ public function testQueryValidationErrorCustomStatusCode() try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $validationFailedException = $e->getPrevious(); $this->assertSame(400, $e->getStatusCode()); @@ -780,12 +780,12 @@ public function testRequestPayloadValidationErrorCustomStatusCode() try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $validationFailedException = $e->getPrevious(); $this->assertSame(400, $e->getStatusCode()); $this->assertInstanceOf(ValidationFailedException::class, $validationFailedException); - $this->assertSame(sprintf('This value should be of type %s.', class_exists(InvalidTypeException::class) ? 'string' : 'unknown'), $validationFailedException->getViolations()[0]->getMessage()); + $this->assertSame(\sprintf('This value should be of type %s.', class_exists(InvalidTypeException::class) ? 'string' : 'unknown'), $validationFailedException->getViolations()[0]->getMessage()); } } } diff --git a/Tests/Controller/ArgumentResolverTest.php b/Tests/Controller/ArgumentResolverTest.php index 5d26396fbe..ba8728eb54 100644 --- a/Tests/Controller/ArgumentResolverTest.php +++ b/Tests/Controller/ArgumentResolverTest.php @@ -432,13 +432,13 @@ public function controllerDisablingResolver(#[ValueResolver(RequestAttributeValu public function controllerTargetingManyResolvers( #[ValueResolver(RequestAttributeValueResolver::class)] #[ValueResolver(DefaultValueResolver::class)] - int $foo + int $foo, ) { } public function controllerTargetingUnknownResolver( #[ValueResolver('foo')] - int $bar + int $bar, ) { } } diff --git a/Tests/Controller/TraceableArgumentResolverTest.php b/Tests/Controller/TraceableArgumentResolverTest.php index 43bbb13e6b..baac744ba8 100644 --- a/Tests/Controller/TraceableArgumentResolverTest.php +++ b/Tests/Controller/TraceableArgumentResolverTest.php @@ -28,7 +28,7 @@ public function testStopwatchEventIsStoppedWhenResolverThrows() $stopwatch = $this->createStub(Stopwatch::class); $stopwatch->method('start')->willReturn($stopwatchEvent); - $resolver = new class() implements ArgumentResolverInterface { + $resolver = new class implements ArgumentResolverInterface { public function getArguments(Request $request, callable $controller): array { throw new \Exception(); diff --git a/Tests/Controller/TraceableControllerResolverTest.php b/Tests/Controller/TraceableControllerResolverTest.php index ecd4a23736..fcdb6bea97 100644 --- a/Tests/Controller/TraceableControllerResolverTest.php +++ b/Tests/Controller/TraceableControllerResolverTest.php @@ -28,7 +28,7 @@ public function testStopwatchEventIsStoppedWhenResolverThrows() $stopwatch = $this->createStub(Stopwatch::class); $stopwatch->method('start')->willReturn($stopwatchEvent); - $resolver = new class() implements ControllerResolverInterface { + $resolver = new class implements ControllerResolverInterface { public function getController(Request $request): callable|false { throw new \Exception(); diff --git a/Tests/DataCollector/ConfigDataCollectorTest.php b/Tests/DataCollector/ConfigDataCollectorTest.php index efee6742ea..00da7a7801 100644 --- a/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/Tests/DataCollector/ConfigDataCollectorTest.php @@ -41,7 +41,7 @@ public function testCollect() $this->assertSame(\extension_loaded('xdebug'), $c->hasXDebug()); $this->assertSame(\extension_loaded('Zend OPcache') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOL), $c->hasZendOpcache()); $this->assertSame(\extension_loaded('apcu') && filter_var(\ini_get('apc.enabled'), \FILTER_VALIDATE_BOOL), $c->hasApcu()); - $this->assertSame(sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION), $c->getSymfonyMinorVersion()); + $this->assertSame(\sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION), $c->getSymfonyMinorVersion()); $this->assertContains($c->getSymfonyState(), ['eol', 'eom', 'dev', 'stable']); $eom = \DateTimeImmutable::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_MAINTENANCE)->format('F Y'); @@ -69,7 +69,7 @@ public function testCollectWithoutKernel() $this->assertSame(\extension_loaded('xdebug'), $c->hasXDebug()); $this->assertSame(\extension_loaded('Zend OPcache') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOL), $c->hasZendOpcache()); $this->assertSame(\extension_loaded('apcu') && filter_var(\ini_get('apc.enabled'), \FILTER_VALIDATE_BOOL), $c->hasApcu()); - $this->assertSame(sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION), $c->getSymfonyMinorVersion()); + $this->assertSame(\sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION), $c->getSymfonyMinorVersion()); $this->assertContains($c->getSymfonyState(), ['eol', 'eom', 'dev', 'stable']); $eom = \DateTimeImmutable::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_MAINTENANCE)->format('F Y'); diff --git a/Tests/DataCollector/RequestDataCollectorTest.php b/Tests/DataCollector/RequestDataCollectorTest.php index 04649f9ef3..65608851de 100644 --- a/Tests/DataCollector/RequestDataCollectorTest.php +++ b/Tests/DataCollector/RequestDataCollectorTest.php @@ -89,7 +89,7 @@ public function testControllerInspection($name, $callable, $expected) $c->collect($request, $response); $c->lateCollect(); - $this->assertSame($expected, $c->getController()->getValue(true), sprintf('Testing: %s', $name)); + $this->assertSame($expected, $c->getController()->getValue(true), \sprintf('Testing: %s', $name)); } public static function provideControllerCallables(): array @@ -118,7 +118,7 @@ public static function provideControllerCallables(): array 'Closure', fn () => 'foo', [ - 'class' => \PHP_VERSION_ID >= 80400 ? sprintf('{closure:%s():%d}', __METHOD__, __LINE__ - 2) : __NAMESPACE__.'\{closure}', + 'class' => \PHP_VERSION_ID >= 80400 ? \sprintf('{closure:%s():%d}', __METHOD__, __LINE__ - 2) : __NAMESPACE__.'\{closure}', 'method' => null, 'file' => __FILE__, 'line' => __LINE__ - 5, @@ -301,7 +301,7 @@ public function testItCollectsTheSessionTraceProperly() $this->assertSame('getMetadataBag', $trace[0]['function']); $this->assertSame(self::class, $class = $trace[1]['class']); - $this->assertSame(sprintf('%s:%s', $class, $line), $usages[0]['name']); + $this->assertSame(\sprintf('%s:%s', $class, $line), $usages[0]['name']); } public function testStatelessCheck() @@ -412,7 +412,7 @@ private function getCookieByName(Response $response, $name) } } - throw new \InvalidArgumentException(sprintf('Cookie named "%s" is not in response', $name)); + throw new \InvalidArgumentException(\sprintf('Cookie named "%s" is not in response', $name)); } /** diff --git a/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php b/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php index 0a8c488edc..f121322bb5 100644 --- a/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php +++ b/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php @@ -679,7 +679,7 @@ public function fooAction( string $apiKey, #[Target('image.storage')] ControllerDummy $service1, - ControllerDummy $service2 + ControllerDummy $service2, ) { } } diff --git a/Tests/EventListener/CacheAttributeListenerTest.php b/Tests/EventListener/CacheAttributeListenerTest.php index 0afae63a0a..1542b35e74 100644 --- a/Tests/EventListener/CacheAttributeListenerTest.php +++ b/Tests/EventListener/CacheAttributeListenerTest.php @@ -227,7 +227,7 @@ public function testEtagNotModifiedResponse(string $expression) $request = $this->createRequest(new Cache(etag: $expression)); $request->attributes->set('id', '12345'); - $request->headers->add(['If-None-Match' => sprintf('"%s"', hash('sha256', $entity->getId()))]); + $request->headers->add(['If-None-Match' => \sprintf('"%s"', hash('sha256', $entity->getId()))]); $listener = new CacheAttributeListener(); $controllerArgumentsEvent = new ControllerArgumentsEvent($this->getKernel(), fn (TestEntity $test) => new Response(), [$entity], $request, null); diff --git a/Tests/EventListener/SessionListenerTest.php b/Tests/EventListener/SessionListenerTest.php index 3064fca51f..fe700c927f 100644 --- a/Tests/EventListener/SessionListenerTest.php +++ b/Tests/EventListener/SessionListenerTest.php @@ -336,7 +336,7 @@ public function testSessionCookieSetWhenOtherNativeVariablesSet() public function testOnlyTriggeredOnMainRequest() { - $listener = new class() extends AbstractSessionListener { + $listener = new class extends AbstractSessionListener { protected function getSession(): ?SessionInterface { return null; diff --git a/Tests/HttpCache/HttpCacheTest.php b/Tests/HttpCache/HttpCacheTest.php index 39f00a0139..afd79e1d59 100644 --- a/Tests/HttpCache/HttpCacheTest.php +++ b/Tests/HttpCache/HttpCacheTest.php @@ -769,7 +769,7 @@ public function testHitBackendOnlyOnceWhenCacheWasLocked() $this->request('GET', '/'); // warm the cache // Use a store that simulates a cache entry being locked upon first attempt - $this->store = new class(sys_get_temp_dir() . '/http_cache') extends Store { + $this->store = new class(sys_get_temp_dir().'/http_cache') extends Store { private bool $hasLock = false; public function lock(Request $request): bool @@ -1418,7 +1418,7 @@ public function testEsiCacheIncludesEmbeddedResponseContentWhenMainResponseFails 'headers' => [ 'Cache-Control' => 's-maxage=10', // stays fresh 'Last-Modified' => 'Mon, 12 Aug 2024 10:05:00 +0000', - ] + ], ], ]); @@ -1475,7 +1475,7 @@ public function testEsiCacheIncludesEmbeddedResponseContentWhenMainResponseFails 'headers' => [ 'Cache-Control' => 's-maxage=0', // goes stale immediately 'Last-Modified' => 'Mon, 12 Aug 2024 10:05:00 +0000', - ] + ], ], ]); @@ -1540,7 +1540,7 @@ public function testEsiCacheIncludesEmbeddedResponseContentWhenMainAndEmbeddedRe 'headers' => [ 'Cache-Control' => 's-maxage=10', 'Last-Modified' => 'Mon, 12 Aug 2024 10:00:00 +0000', - ] + ], ], ]); diff --git a/Tests/HttpCache/HttpCacheTestCase.php b/Tests/HttpCache/HttpCacheTestCase.php index 88f6bed56f..b05d913666 100644 --- a/Tests/HttpCache/HttpCacheTestCase.php +++ b/Tests/HttpCache/HttpCacheTestCase.php @@ -115,7 +115,7 @@ public function request($method, $uri = '/', $server = [], $cookies = [], $esi = $this->kernel->reset(); - if (! $this->store) { + if (!$this->store) { $this->store = $this->createStore(); } @@ -188,6 +188,6 @@ public static function clearDirectory($directory) protected function createStore(): Store { - return new Store(sys_get_temp_dir() . '/http_cache'); + return new Store(sys_get_temp_dir().'/http_cache'); } } diff --git a/Tests/HttpCache/ResponseCacheStrategyTest.php b/Tests/HttpCache/ResponseCacheStrategyTest.php index ef3f495011..a4650643cb 100644 --- a/Tests/HttpCache/ResponseCacheStrategyTest.php +++ b/Tests/HttpCache/ResponseCacheStrategyTest.php @@ -400,14 +400,14 @@ public function testCacheControlMerging(array $expects, array $main, array $surr } elseif ('age' === $key) { $this->assertSame($value, $response->getAge()); } elseif (true === $value) { - $this->assertTrue($response->headers->hasCacheControlDirective($key), sprintf('Cache-Control header must have "%s" flag', $key)); + $this->assertTrue($response->headers->hasCacheControlDirective($key), \sprintf('Cache-Control header must have "%s" flag', $key)); } elseif (false === $value) { $this->assertFalse( $response->headers->hasCacheControlDirective($key), - sprintf('Cache-Control header must NOT have "%s" flag', $key) + \sprintf('Cache-Control header must NOT have "%s" flag', $key) ); } else { - $this->assertSame($value, $response->headers->getCacheControlDirective($key), sprintf('Cache-Control flag "%s" should be "%s"', $key, $value)); + $this->assertSame($value, $response->headers->getCacheControlDirective($key), \sprintf('Cache-Control flag "%s" should be "%s"', $key, $value)); } } } diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index 94c498a0f2..268f8c7d25 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -65,7 +65,7 @@ public function testConstructor() public function testEmptyEnv() { $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage(sprintf('Invalid environment provided to "%s": the environment cannot be empty.', KernelForTest::class)); + $this->expectExceptionMessage(\sprintf('Invalid environment provided to "%s": the environment cannot be empty.', KernelForTest::class)); new KernelForTest('', false); } @@ -321,7 +321,7 @@ public function doStuff() } } EOF -, <<<'EOF' + , <<<'EOF' setParameter('test.extension-registered', true);