Skip to content

Commit 6ce530c

Browse files
committed
Prefix all sprintf() calls
1 parent 69d8812 commit 6ce530c

File tree

1,351 files changed

+4191
-4189
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,351 files changed

+4191
-4189
lines changed

.php-cs-fixer.dist.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
'@Symfony:risky' => true,
3131
'protected_to_private' => false,
3232
'header_comment' => ['header' => $fileHeaderComment],
33+
// TODO: Remove once the "compiler_optimized" set includes "sprintf"
34+
'native_function_invocation' => ['include' => ['@compiler_optimized', 'sprintf'], 'scope' => 'namespaced', 'strict' => true],
3335
'nullable_type_declaration' => true,
3436
'trailing_comma_in_multiline' => ['elements' => ['arrays', 'match', 'parameters']],
3537
])

src/Symfony/Bridge/Doctrine/ArgumentResolver/EntityValueResolver.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): array
5757
$message = '';
5858
if (null !== $options->expr) {
5959
if (null === $object = $this->findViaExpression($manager, $request, $options)) {
60-
$message = sprintf(' The expression "%s" returned null.', $options->expr);
60+
$message = \sprintf(' The expression "%s" returned null.', $options->expr);
6161
}
6262
// find by identifier?
6363
} elseif (false === $object = $this->find($manager, $request, $options, $argument)) {
@@ -73,7 +73,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): array
7373
}
7474

7575
if (null === $object && !$argument->isNullable()) {
76-
throw new NotFoundHttpException($options->message ?? (sprintf('"%s" object not found by "%s".', $options->class, self::class).$message));
76+
throw new NotFoundHttpException($options->message ?? (\sprintf('"%s" object not found by "%s".', $options->class, self::class).$message));
7777
}
7878

7979
return [$object];
@@ -126,7 +126,7 @@ private function getIdentifier(Request $request, MapEntity $options, ArgumentMet
126126
foreach ($options->id as $field) {
127127
// Convert "%s_uuid" to "foobar_uuid"
128128
if (str_contains($field, '%s')) {
129-
$field = sprintf($field, $argument->getName());
129+
$field = \sprintf($field, $argument->getName());
130130
}
131131

132132
$id[$field] = $request->attributes->get($field);
@@ -214,7 +214,7 @@ private function getCriteria(Request $request, MapEntity $options, ObjectManager
214214
private function findViaExpression(ObjectManager $manager, Request $request, MapEntity $options): object|iterable|null
215215
{
216216
if (!$this->expressionLanguage) {
217-
throw new \LogicException(sprintf('You cannot use the "%s" if the ExpressionLanguage component is not available. Try running "composer require symfony/expression-language".', __CLASS__));
217+
throw new \LogicException(\sprintf('You cannot use the "%s" if the ExpressionLanguage component is not available. Try running "composer require symfony/expression-language".', __CLASS__));
218218
}
219219

220220
$repository = $manager->getRepository($options->class);

src/Symfony/Bridge/Doctrine/CacheWarmer/ProxyCacheWarmer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ public function warmUp(string $cacheDir, ?string $buildDir = null): array
4646
// we need the directory no matter the proxy cache generation strategy
4747
if (!is_dir($proxyCacheDir = $em->getConfiguration()->getProxyDir())) {
4848
if (false === @mkdir($proxyCacheDir, 0777, true) && !is_dir($proxyCacheDir)) {
49-
throw new \RuntimeException(sprintf('Unable to create the Doctrine Proxy directory "%s".', $proxyCacheDir));
49+
throw new \RuntimeException(\sprintf('Unable to create the Doctrine Proxy directory "%s".', $proxyCacheDir));
5050
}
5151
} elseif (!is_writable($proxyCacheDir)) {
52-
throw new \RuntimeException(sprintf('The Doctrine Proxy directory "%s" is not writeable for the current system user.', $proxyCacheDir));
52+
throw new \RuntimeException(\sprintf('The Doctrine Proxy directory "%s" is not writeable for the current system user.', $proxyCacheDir));
5353
}
5454

5555
// if proxies are autogenerated we don't need to generate them in the cache warmer

src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ private function initializeSubscribers(): void
193193
continue;
194194
}
195195

196-
throw new \InvalidArgumentException(sprintf('Using Doctrine subscriber "%s" is not allowed. Register it as a listener instead, using e.g. the #[AsDoctrineListener] or #[AsDocumentListener] attribute.', \is_object($listener) ? get_debug_type($listener) : $listener));
196+
throw new \InvalidArgumentException(\sprintf('Using Doctrine subscriber "%s" is not allowed. Register it as a listener instead, using e.g. the #[AsDoctrineListener] or #[AsDocumentListener] attribute.', \is_object($listener) ? get_debug_type($listener) : $listener));
197197
}
198198
}
199199

src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ protected function getCasters(): array
126126
return [Caster::PREFIX_VIRTUAL.'__toString()' => (string) $o->getObject()];
127127
}
128128

129-
return [Caster::PREFIX_VIRTUAL.'' => sprintf('Object of class "%s" could not be converted to string.', $o->getClass())];
129+
return [Caster::PREFIX_VIRTUAL.'' => \sprintf('Object of class "%s" could not be converted to string.', $o->getClass())];
130130
},
131131
];
132132
}
@@ -214,7 +214,7 @@ private function sanitizeParam(mixed $var, ?\Throwable $error): array
214214
}
215215

216216
if (\is_resource($var)) {
217-
return [sprintf('/* Resource(%s) */', get_resource_type($var)), false, false];
217+
return [\sprintf('/* Resource(%s) */', get_resource_type($var)), false, false];
218218
}
219219

220220
return [$var, true, true];

src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ protected function loadMappingInformation(array $objectManager, ContainerBuilder
8383
}
8484

8585
if (null === $bundle) {
86-
throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled.', $mappingName));
86+
throw new \InvalidArgumentException(\sprintf('Bundle "%s" does not exist or it is not enabled.', $mappingName));
8787
}
8888

8989
$mappingConfig = $this->getMappingDriverBundleConfigDefaults($mappingConfig, $bundle, $container, $bundleMetadata['path']);
@@ -123,7 +123,7 @@ protected function setMappingDriverConfig(array $mappingConfig, string $mappingN
123123
{
124124
$mappingDirectory = $mappingConfig['dir'];
125125
if (!is_dir($mappingDirectory)) {
126-
throw new \InvalidArgumentException(sprintf('Invalid Doctrine mapping path given. Cannot load Doctrine mapping/bundle named "%s".', $mappingName));
126+
throw new \InvalidArgumentException(\sprintf('Invalid Doctrine mapping path given. Cannot load Doctrine mapping/bundle named "%s".', $mappingName));
127127
}
128128

129129
$this->drivers[$mappingConfig['type']][$mappingConfig['prefix']] = realpath($mappingDirectory) ?: $mappingDirectory;
@@ -218,15 +218,15 @@ protected function registerMappingDrivers(array $objectManager, ContainerBuilder
218218
protected function assertValidMappingConfiguration(array $mappingConfig, string $objectManagerName): void
219219
{
220220
if (!$mappingConfig['type'] || !$mappingConfig['dir'] || !$mappingConfig['prefix']) {
221-
throw new \InvalidArgumentException(sprintf('Mapping definitions for Doctrine manager "%s" require at least the "type", "dir" and "prefix" options.', $objectManagerName));
221+
throw new \InvalidArgumentException(\sprintf('Mapping definitions for Doctrine manager "%s" require at least the "type", "dir" and "prefix" options.', $objectManagerName));
222222
}
223223

224224
if (!is_dir($mappingConfig['dir'])) {
225-
throw new \InvalidArgumentException(sprintf('Specified non-existing directory "%s" as Doctrine mapping source.', $mappingConfig['dir']));
225+
throw new \InvalidArgumentException(\sprintf('Specified non-existing directory "%s" as Doctrine mapping source.', $mappingConfig['dir']));
226226
}
227227

228228
if (!\in_array($mappingConfig['type'], ['xml', 'yml', 'php', 'staticphp', 'attribute'])) {
229-
throw new \InvalidArgumentException(sprintf('Can only configure "xml", "yml", "php", "staticphp" or "attribute" through the DoctrineBundle. Use your own bundle to configure other metadata drivers. You can register them by adding a new driver to the "%s" service definition.', $this->getObjectManagerElementName($objectManagerName.'_metadata_driver')));
229+
throw new \InvalidArgumentException(\sprintf('Can only configure "xml", "yml", "php", "staticphp" or "attribute" through the DoctrineBundle. Use your own bundle to configure other metadata drivers. You can register them by adding a new driver to the "%s" service definition.', $this->getObjectManagerElementName($objectManagerName.'_metadata_driver')));
230230
}
231231
}
232232

@@ -297,8 +297,8 @@ protected function loadCacheDriver(string $cacheName, string $objectManagerName,
297297
$memcachedInstance->addMethodCall('addServer', [
298298
$memcachedHost, $memcachedPort,
299299
]);
300-
$container->setDefinition($this->getObjectManagerElementName(sprintf('%s_memcached_instance', $objectManagerName)), $memcachedInstance);
301-
$cacheDef->addMethodCall('setMemcached', [new Reference($this->getObjectManagerElementName(sprintf('%s_memcached_instance', $objectManagerName)))]);
300+
$container->setDefinition($this->getObjectManagerElementName(\sprintf('%s_memcached_instance', $objectManagerName)), $memcachedInstance);
301+
$cacheDef->addMethodCall('setMemcached', [new Reference($this->getObjectManagerElementName(\sprintf('%s_memcached_instance', $objectManagerName)))]);
302302
break;
303303
case 'redis':
304304
$redisClass = !empty($cacheDriver['class']) ? $cacheDriver['class'] : '%'.$this->getObjectManagerElementName('cache.redis.class').'%';
@@ -310,19 +310,19 @@ protected function loadCacheDriver(string $cacheName, string $objectManagerName,
310310
$redisInstance->addMethodCall('connect', [
311311
$redisHost, $redisPort,
312312
]);
313-
$container->setDefinition($this->getObjectManagerElementName(sprintf('%s_redis_instance', $objectManagerName)), $redisInstance);
314-
$cacheDef->addMethodCall('setRedis', [new Reference($this->getObjectManagerElementName(sprintf('%s_redis_instance', $objectManagerName)))]);
313+
$container->setDefinition($this->getObjectManagerElementName(\sprintf('%s_redis_instance', $objectManagerName)), $redisInstance);
314+
$cacheDef->addMethodCall('setRedis', [new Reference($this->getObjectManagerElementName(\sprintf('%s_redis_instance', $objectManagerName)))]);
315315
break;
316316
case 'apc':
317317
case 'apcu':
318318
case 'array':
319319
case 'xcache':
320320
case 'wincache':
321321
case 'zenddata':
322-
$cacheDef = new Definition('%'.$this->getObjectManagerElementName(sprintf('cache.%s.class', $cacheDriver['type'])).'%');
322+
$cacheDef = new Definition('%'.$this->getObjectManagerElementName(\sprintf('cache.%s.class', $cacheDriver['type'])).'%');
323323
break;
324324
default:
325-
throw new \InvalidArgumentException(sprintf('"%s" is an unrecognized Doctrine cache driver.', $cacheDriver['type']));
325+
throw new \InvalidArgumentException(\sprintf('"%s" is an unrecognized Doctrine cache driver.', $cacheDriver['type']));
326326
}
327327

328328
if (!isset($cacheDriver['namespace'])) {
@@ -414,7 +414,7 @@ private function validateAutoMapping(array $managerConfigs): ?string
414414
}
415415

416416
if (null !== $autoMappedManager) {
417-
throw new \LogicException(sprintf('You cannot enable "auto_mapping" on more than one manager at the same time (found in "%s" and "%s"").', $autoMappedManager, $name));
417+
throw new \LogicException(\sprintf('You cannot enable "auto_mapping" on more than one manager at the same time (found in "%s" and "%s"").', $autoMappedManager, $name));
418418
}
419419

420420
$autoMappedManager = $name;

src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ private function addTaggedServices(ContainerBuilder $container): array
7575
? [$container->getParameterBag()->resolveValue($tag['connection'])]
7676
: array_keys($this->connections);
7777
if (!isset($tag['event'])) {
78-
throw new InvalidArgumentException(sprintf('Doctrine event listener "%s" must specify the "event" attribute.', $id));
78+
throw new InvalidArgumentException(\sprintf('Doctrine event listener "%s" must specify the "event" attribute.', $id));
7979
}
8080
foreach ($connections as $con) {
8181
if (!isset($this->connections[$con])) {
82-
throw new RuntimeException(sprintf('The Doctrine connection "%s" referenced in service "%s" does not exist. Available connections names: "%s".', $con, $id, implode('", "', array_keys($this->connections))));
82+
throw new RuntimeException(\sprintf('The Doctrine connection "%s" referenced in service "%s" does not exist. Available connections names: "%s".', $con, $id, implode('", "', array_keys($this->connections))));
8383
}
8484

8585
if (!isset($managerDefs[$con])) {
@@ -110,7 +110,7 @@ private function addTaggedServices(ContainerBuilder $container): array
110110
private function getEventManagerDef(ContainerBuilder $container, string $name): Definition
111111
{
112112
if (!isset($this->eventManagers[$name])) {
113-
$this->eventManagers[$name] = $container->getDefinition(sprintf($this->managerTemplate, $name));
113+
$this->eventManagers[$name] = $container->getDefinition(\sprintf($this->managerTemplate, $name));
114114
}
115115

116116
return $this->eventManagers[$name];

src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterMappingsPass.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function process(ContainerBuilder $container): void
108108
*/
109109
protected function getChainDriverServiceName(ContainerBuilder $container): string
110110
{
111-
return sprintf($this->driverPattern, $this->getManagerName($container));
111+
return \sprintf($this->driverPattern, $this->getManagerName($container));
112112
}
113113

114114
/**
@@ -130,7 +130,7 @@ protected function getDriver(ContainerBuilder $container): Definition|Reference
130130
*/
131131
private function getConfigurationServiceName(ContainerBuilder $container): string
132132
{
133-
return sprintf($this->configurationPattern, $this->getManagerName($container));
133+
return \sprintf($this->configurationPattern, $this->getManagerName($container));
134134
}
135135

136136
/**
@@ -152,7 +152,7 @@ private function getManagerName(ContainerBuilder $container): string
152152
}
153153
}
154154

155-
throw new InvalidArgumentException(sprintf('Could not find the manager name parameter in the container. Tried the following parameter names: "%s".', implode('", "', $this->managerParameters)));
155+
throw new InvalidArgumentException(\sprintf('Could not find the manager name parameter in the container. Tried the following parameter names: "%s".', implode('", "', $this->managerParameters)));
156156
}
157157

158158
/**

src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct(
4141
private readonly ?EntityLoaderInterface $objectLoader = null,
4242
) {
4343
if ($idReader && !$idReader->isSingleId()) {
44-
throw new \InvalidArgumentException(sprintf('The "$idReader" argument of "%s" must be null when the query cannot be optimized because of composite id fields.', __METHOD__));
44+
throw new \InvalidArgumentException(\sprintf('The "$idReader" argument of "%s" must be null when the query cannot be optimized because of composite id fields.', __METHOD__));
4545
}
4646

4747
$this->class = $manager->getClassMetadata($class)->getName();

src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function getIdValue(?object $object = null): string
8383
}
8484

8585
if (!$this->om->contains($object)) {
86-
throw new RuntimeException(sprintf('Entity of type "%s" passed to the choice field must be managed. Maybe you forget to persist it in the entity manager?', get_debug_type($object)));
86+
throw new RuntimeException(\sprintf('Entity of type "%s" passed to the choice field must be managed. Maybe you forget to persist it in the entity manager?', get_debug_type($object)));
8787
}
8888

8989
$this->om->initializeObject($object);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy