diff --git a/src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php b/src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php index f0f2b65ac3f15..0df9e60d3c489 100644 --- a/src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php +++ b/src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php @@ -109,7 +109,7 @@ public function getConnections() public function getQueryCount() { - return array_sum(array_map('count', $this->data['queries'])); + return array_sum(array_map(count(...), $this->data['queries'])); } public function getQueries() diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php index f6e924af0f11e..5b78be3431364 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php @@ -821,7 +821,7 @@ public function testChoicesForValuesOptimization() $field->submit(1); $unitOfWorkIdentityMap = $this->em->getUnitOfWork()->getIdentityMap(); - $managedEntitiesNames = array_map('strval', $unitOfWorkIdentityMap['Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity']); + $managedEntitiesNames = array_map(strval(...), $unitOfWorkIdentityMap['Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity']); $this->assertContains((string) $entity1, $managedEntitiesNames); $this->assertNotContains((string) $entity2, $managedEntitiesNames); diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php index bb39b00288a99..e581831146424 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php @@ -86,7 +86,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } } - uasort($serviceIds, 'strnatcmp'); + uasort($serviceIds, strnatcmp(...)); $io->title('Autowirable Types'); $io->text('The following classes & interfaces can be used as type-hints when autowiring:'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php index a4f34ce4dc6d9..f2c1860c27204 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php @@ -397,7 +397,7 @@ private function extractMessages(string $locale, array $transPaths, string $pref private function filterDuplicateTransPaths(array $transPaths): array { - $transPaths = array_filter(array_map('realpath', $transPaths)); + $transPaths = array_filter(array_map(realpath(...), $transPaths)); sort($transPaths); diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 772c8fe1ffeb7..b09a44ff153e9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -122,7 +122,7 @@ public function getConfigTreeBuilder(): TreeBuilder ->fixXmlConfig('trusted_header') ->performNoDeepMerging() ->defaultValue(['x-forwarded-for', 'x-forwarded-port', 'x-forwarded-proto']) - ->beforeNormalization()->ifString()->then(function ($v) { return $v ? array_map('trim', explode(',', $v)) : []; })->end() + ->beforeNormalization()->ifString()->then(function ($v) { return $v ? array_map(trim(...), explode(',', $v)) : []; })->end() ->enumPrototype() ->values([ 'forwarded', @@ -1937,7 +1937,7 @@ private function addHttpClientRetrySection() ->arrayNode('methods') ->beforeNormalization() ->ifArray() - ->then(fn ($v) => array_map('strtoupper', $v)) + ->then(fn ($v) => array_map(strtoupper(...), $v)) ->end() ->prototype('scalar')->end() ->info('A list of HTTP methods that triggers a retry for this status code. When empty, all methods are retried') diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 551f02dc66299..0e2c39454ec06 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -1132,7 +1132,7 @@ private function registerRouterConfiguration(array $config, ContainerBuilder $co } if ($enabledLocales) { - $enabledLocales = implode('|', array_map('preg_quote', $enabledLocales)); + $enabledLocales = implode('|', array_map(preg_quote(...), $enabledLocales)); $container->getDefinition('routing.loader')->replaceArgument(2, ['_locale' => $enabledLocales]); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Secrets/SodiumVault.php b/src/Symfony/Bundle/FrameworkBundle/Secrets/SodiumVault.php index b6bb058b3f170..55ee4646a602e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Secrets/SodiumVault.php +++ b/src/Symfony/Bundle/FrameworkBundle/Secrets/SodiumVault.php @@ -84,7 +84,7 @@ public function seal(string $name, string $value): void $list = $this->list(); $list[$name] = null; - uksort($list, 'strnatcmp'); + uksort($list, strnatcmp(...)); file_put_contents($this->pathPrefix.'list.php', sprintf("lastMessage = sprintf('Secret "%s" encrypted in "%s"; you can commit it.', $name, $this->getPrettyPath(\dirname($this->pathPrefix).\DIRECTORY_SEPARATOR)); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index e3416357c162b..af1668b7867fb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -1093,7 +1093,7 @@ public function testTranslator() $this->assertArrayHasKey('cache_dir', $options); $this->assertSame($container->getParameter('kernel.cache_dir').'/translations', $options['cache_dir']); - $files = array_map('realpath', $options['resource_files']['en']); + $files = array_map(realpath(...), $options['resource_files']['en']); $ref = new \ReflectionClass(Validation::class); $this->assertContains( strtr(\dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', \DIRECTORY_SEPARATOR), diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php index 7f2fe5b7c4bb2..f03cbae50bc20 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php @@ -547,7 +547,7 @@ public function testCacheValidityWithContainerParameters($parameter) $this->assertTrue($cache->isFresh()); } finally { if (is_dir($cacheDir)) { - array_map('unlink', glob($cacheDir.\DIRECTORY_SEPARATOR.'*')); + array_map(unlink(...), glob($cacheDir.\DIRECTORY_SEPARATOR.'*')); rmdir($cacheDir); } } diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php index 5e67e2bb6a612..6908d05dcbb91 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php @@ -924,7 +924,7 @@ private function createExpression(ContainerBuilder $container, string $expressio private function createRequestMatcher(ContainerBuilder $container, string $path = null, string $host = null, int $port = null, array $methods = [], array $ips = null, array $attributes = []): Reference { if ($methods) { - $methods = array_map('strtoupper', $methods); + $methods = array_map(strtoupper(...), $methods); } if ($ips) { diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php index 8c521c8a03414..08d2344194ea7 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php @@ -122,7 +122,7 @@ public function testFirewalls() foreach (array_keys($arguments[1]->getValues()) as $contextId) { $contextDef = $container->getDefinition($contextId); $arguments = $contextDef->getArguments(); - $listeners[] = array_map('strval', $arguments[0]->getValues()); + $listeners[] = array_map(strval(...), $arguments[0]->getValues()); $configDef = $container->getDefinition((string) $arguments[3]); $configs[] = array_values($configDef->getArguments()); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php index 227d126db33e2..5b1191bc00cfe 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php @@ -739,7 +739,7 @@ public function testConfigureCustomAuthenticator(array $firewall, array $expecte $container->compile(); - $this->assertEquals($expectedAuthenticators, array_map('strval', $container->getDefinition('security.authenticator.manager.main')->getArgument(0))); + $this->assertEquals($expectedAuthenticators, array_map(strval(...), $container->getDefinition('security.authenticator.manager.main')->getArgument(0))); } public function provideConfigureCustomAuthenticatorData() @@ -844,7 +844,7 @@ public function testConfigureCustomFirewallListener() /** @var IteratorArgument $listenersIteratorArgument */ $listenersIteratorArgument = $container->getDefinition('security.firewall.map.context.main')->getArgument(0); - $firewallListeners = array_map('strval', $listenersIteratorArgument->getValues()); + $firewallListeners = array_map(strval(...), $listenersIteratorArgument->getValues()); $this->assertContains('custom_firewall_listener_id', $firewallListeners); } diff --git a/src/Symfony/Component/Cache/Marshaller/DeflateMarshaller.php b/src/Symfony/Component/Cache/Marshaller/DeflateMarshaller.php index 35237de688415..8b1bd61214a10 100644 --- a/src/Symfony/Component/Cache/Marshaller/DeflateMarshaller.php +++ b/src/Symfony/Component/Cache/Marshaller/DeflateMarshaller.php @@ -33,7 +33,7 @@ public function __construct(MarshallerInterface $marshaller) public function marshall(array $values, ?array &$failed): array { - return array_map('gzdeflate', $this->marshaller->marshall($values, $failed)); + return array_map(gzdeflate(...), $this->marshaller->marshall($values, $failed)); } public function unmarshall(string $value): mixed diff --git a/src/Symfony/Component/Cache/Tests/LockRegistryTest.php b/src/Symfony/Component/Cache/Tests/LockRegistryTest.php index 30ff6774047a5..798da8f76bdbf 100644 --- a/src/Symfony/Component/Cache/Tests/LockRegistryTest.php +++ b/src/Symfony/Component/Cache/Tests/LockRegistryTest.php @@ -23,7 +23,7 @@ public function testFiles() } $lockFiles = LockRegistry::setFiles([]); LockRegistry::setFiles($lockFiles); - $expected = array_map('realpath', glob(__DIR__.'/../Adapter/*')); + $expected = array_map(realpath(...), glob(__DIR__.'/../Adapter/*')); $this->assertSame($expected, $lockFiles); } } diff --git a/src/Symfony/Component/Cache/Tests/Traits/RedisProxiesTest.php b/src/Symfony/Component/Cache/Tests/Traits/RedisProxiesTest.php index 27fabf700af8a..7ee7dbe81e305 100644 --- a/src/Symfony/Component/Cache/Tests/Traits/RedisProxiesTest.php +++ b/src/Symfony/Component/Cache/Tests/Traits/RedisProxiesTest.php @@ -43,7 +43,7 @@ public function testRedis5Proxy($class) EOPHP; } - uksort($methods, 'strnatcmp'); + uksort($methods, strnatcmp(...)); $proxy .= implode('', $methods)."}\n"; $this->assertStringEqualsFile(\dirname(__DIR__, 2)."/Traits/{$class}5Proxy.php", $proxy); @@ -80,7 +80,7 @@ public function testRedis6Proxy($class, $stub) EOPHP; } - uksort($methods, 'strnatcmp'); + uksort($methods, strnatcmp(...)); $proxy .= implode('', $methods)."}\n"; $this->assertStringEqualsFile(\dirname(__DIR__, 2)."/Traits/{$class}6Proxy.php", $proxy); diff --git a/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php b/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php index eb8fce4385e6b..2038af75c8729 100644 --- a/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php +++ b/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php @@ -107,7 +107,7 @@ private function writeNode(NodeInterface $node, int $depth = 0, bool $root = fal FloatNode::class, IntegerNode::class => 'numeric value', BooleanNode::class => 'true|false', - EnumNode::class => implode('|', array_unique(array_map('json_encode', $prototype->getValues()))), + EnumNode::class => implode('|', array_unique(array_map(json_encode(...), $prototype->getValues()))), default => 'value', }; } @@ -149,7 +149,7 @@ private function writeNode(NodeInterface $node, int $depth = 0, bool $root = fal } if ($child instanceof EnumNode) { - $comments[] = 'One of '.implode('; ', array_unique(array_map('json_encode', $child->getValues()))); + $comments[] = 'One of '.implode('; ', array_unique(array_map(json_encode(...), $child->getValues()))); } if (\count($comments)) { diff --git a/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php b/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php index 04cb38c20b451..9342febb81825 100644 --- a/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php +++ b/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php @@ -98,7 +98,7 @@ private function writeNode(NodeInterface $node, NodeInterface $parentNode = null } } } elseif ($node instanceof EnumNode) { - $comments[] = 'One of '.implode('; ', array_unique(array_map('json_encode', $node->getValues()))); + $comments[] = 'One of '.implode('; ', array_unique(array_map(json_encode(...), $node->getValues()))); $default = $node->hasDefaultValue() ? Inline::dump($node->getDefaultValue()) : '~'; } elseif (VariableNode::class === $node::class && \is_array($example)) { // If there is an array example, we are sure we dont need to print a default value diff --git a/src/Symfony/Component/Config/Definition/EnumNode.php b/src/Symfony/Component/Config/Definition/EnumNode.php index ebb78daa28508..bab44e6a86754 100644 --- a/src/Symfony/Component/Config/Definition/EnumNode.php +++ b/src/Symfony/Component/Config/Definition/EnumNode.php @@ -48,7 +48,7 @@ protected function finalizeValue(mixed $value): mixed $value = parent::finalizeValue($value); if (!\in_array($value, $this->values, true)) { - $ex = new InvalidConfigurationException(sprintf('The value %s is not allowed for path "%s". Permissible values: %s', json_encode($value), $this->getPath(), implode(', ', array_map('json_encode', $this->values)))); + $ex = new InvalidConfigurationException(sprintf('The value %s is not allowed for path "%s". Permissible values: %s', json_encode($value), $this->getPath(), implode(', ', array_map(json_encode(...), $this->values)))); $ex->setPath($this->getPath()); throw $ex; diff --git a/src/Symfony/Component/Config/Resource/GlobResource.php b/src/Symfony/Component/Config/Resource/GlobResource.php index fde1dcb87d274..c79b800d89502 100644 --- a/src/Symfony/Component/Config/Resource/GlobResource.php +++ b/src/Symfony/Component/Config/Resource/GlobResource.php @@ -148,7 +148,7 @@ public function getIterator(): \Traversable ), \RecursiveIteratorIterator::LEAVES_ONLY )); - uksort($files, 'strnatcmp'); + uksort($files, strnatcmp(...)); foreach ($files as $path => $info) { if ($info->isFile()) { diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index 40c7035af4875..9facb4e4fe0f2 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -613,7 +613,7 @@ public function getNamespaces(): array public function findNamespace(string $namespace): string { $allNamespaces = $this->getNamespaces(); - $expr = implode('[^:]*:', array_map('preg_quote', explode(':', $namespace))).'[^:]*'; + $expr = implode('[^:]*:', array_map(preg_quote(...), explode(':', $namespace))).'[^:]*'; $namespaces = preg_grep('{^'.$expr.'}', $allNamespaces); if (empty($namespaces)) { @@ -669,7 +669,7 @@ public function find(string $name) } $allCommands = $this->commandLoader ? array_merge($this->commandLoader->getNames(), array_keys($this->commands)) : array_keys($this->commands); - $expr = implode('[^:]*:', array_map('preg_quote', explode(':', $name))).'[^:]*'; + $expr = implode('[^:]*:', array_map(preg_quote(...), explode(':', $name))).'[^:]*'; $commands = preg_grep('{^'.$expr.'}', $allCommands); if (empty($commands)) { diff --git a/src/Symfony/Component/Console/Question/Question.php b/src/Symfony/Component/Console/Question/Question.php index 58b09c3543456..5349eb144aa6c 100644 --- a/src/Symfony/Component/Console/Question/Question.php +++ b/src/Symfony/Component/Console/Question/Question.php @@ -267,7 +267,7 @@ public function getNormalizer(): ?callable protected function isAssoc(array $array) { - return (bool) \count(array_filter(array_keys($array), 'is_string')); + return (bool) \count(array_filter(array_keys($array), is_string(...))); } public function isTrimmable(): bool diff --git a/src/Symfony/Component/Console/Tester/CommandCompletionTester.php b/src/Symfony/Component/Console/Tester/CommandCompletionTester.php index ade7327529c32..8817ce215a56c 100644 --- a/src/Symfony/Component/Console/Tester/CommandCompletionTester.php +++ b/src/Symfony/Component/Console/Tester/CommandCompletionTester.php @@ -51,6 +51,6 @@ public function complete(array $input): array $options[] = '--'.$option->getName(); } - return array_map('strval', array_merge($options, $suggestions->getValueSuggestions())); + return array_map(strval(...), array_merge($options, $suggestions->getValueSuggestions())); } } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php index 671435291ad4f..1803596d006f9 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php @@ -589,7 +589,7 @@ private function createTypeAlternatives(ContainerBuilder $container, TypedRefere return sprintf(' Available autowiring aliases for this %s are: "$%s".', class_exists($type, false) ? 'class' : 'interface', implode('", "$', $autowiringAliases)); } - if (!$container->has($type) && false !== $key = array_search(strtolower($type), array_map('strtolower', $servicesAndAliases))) { + if (!$container->has($type) && false !== $key = array_search(strtolower($type), array_map(strtolower(...), $servicesAndAliases))) { return sprintf(' Did you mean "%s"?', $servicesAndAliases[$key]); } elseif (isset($this->ambiguousServiceTypes[$type])) { $message = sprintf('one of these existing services: "%s"', implode('", "', $this->ambiguousServiceTypes[$type])); diff --git a/src/Symfony/Component/DependencyInjection/Container.php b/src/Symfony/Component/DependencyInjection/Container.php index ff10702229dc6..c42c5baac7a0e 100644 --- a/src/Symfony/Component/DependencyInjection/Container.php +++ b/src/Symfony/Component/DependencyInjection/Container.php @@ -298,7 +298,7 @@ public function reset() */ public function getServiceIds(): array { - return array_map('strval', array_unique(array_merge(['service_container'], array_keys($this->fileMap), array_keys($this->methodMap), array_keys($this->aliases), array_keys($this->services)))); + return array_map(strval(...), array_unique(array_merge(['service_container'], array_keys($this->fileMap), array_keys($this->methodMap), array_keys($this->aliases), array_keys($this->services)))); } /** diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index 519277f984496..28547e3409719 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -775,7 +775,7 @@ public function compile(bool $resolveEnvPlaceholders = false) public function getServiceIds(): array { - return array_map('strval', array_unique(array_merge(array_keys($this->getDefinitions()), array_keys($this->aliasDefinitions), parent::getServiceIds()))); + return array_map(strval(...), array_unique(array_merge(array_keys($this->getDefinitions()), array_keys($this->aliasDefinitions), parent::getServiceIds()))); } /** diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index bbe04d7c75011..388fa8e28dc81 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -449,7 +449,7 @@ private function processAnonymousServices(\DOMDocument $xml, string $file, \DOMN } // resolve definitions - uksort($definitions, 'strnatcmp'); + uksort($definitions, strnatcmp(...)); foreach (array_reverse($definitions) as $id => [$domElement, $file]) { if (null !== $definition = $this->parseDefinition($domElement, $file, new Definition())) { $this->setDefinition($id, $definition); @@ -668,7 +668,7 @@ public function validateSchema(\DOMDocument $dom): bool $locationstart = ''; } $drive = '\\' === \DIRECTORY_SEPARATOR ? array_shift($parts).'/' : ''; - $location = $locationstart.$drive.implode('/', array_map('rawurlencode', $parts)); + $location = $locationstart.$drive.implode('/', array_map(rawurlencode(...), $parts)); $imports .= sprintf(' '."\n", $namespace, $location); } diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php index 97656011d3fbd..a8f7a0260f53d 100644 --- a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php +++ b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php @@ -70,7 +70,7 @@ public function get(string $name): array|bool|string|int|float|\UnitEnum|null $nonNestedAlternative = null; if (!\count($alternatives) && str_contains($name, '.')) { - $namePartsLength = array_map('strlen', explode('.', $name)); + $namePartsLength = array_map(strlen(...), explode('.', $name)); $key = substr($name, 0, -1 * (1 + array_pop($namePartsLength))); while (\count($namePartsLength)) { if ($this->has($key)) { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php index 2404e8c0de234..dbe3aff141c9d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php @@ -767,7 +767,7 @@ public function testPrototype() sort($ids); $this->assertSame([Prototype\Foo::class, Prototype\Sub\Bar::class, 'service_container'], $ids); - $resources = array_map('strval', $container->getResources()); + $resources = array_map(strval(...), $container->getResources()); $fixturesDir = \dirname(__DIR__).\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR; $this->assertContains((string) new FileResource($fixturesDir.'xml'.\DIRECTORY_SEPARATOR.'services_prototype.xml'), $resources); @@ -802,7 +802,7 @@ public function testPrototypeExcludeWithArray(string $fileName) sort($ids); $this->assertSame([Prototype\Foo::class, Prototype\Sub\Bar::class, 'service_container'], $ids); - $resources = array_map('strval', $container->getResources()); + $resources = array_map(strval(...), $container->getResources()); $fixturesDir = \dirname(__DIR__).\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR; $this->assertContains((string) new FileResource($fixturesDir.'xml'.\DIRECTORY_SEPARATOR.$fileName), $resources); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php index 48006a5842a7f..f5381405cef6b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php @@ -531,7 +531,7 @@ public function testPrototype() sort($ids); $this->assertSame([Prototype\Foo::class, Prototype\Sub\Bar::class, 'service_container'], $ids); - $resources = array_map('strval', $container->getResources()); + $resources = array_map(strval(...), $container->getResources()); $fixturesDir = \dirname(__DIR__).\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR; $this->assertContains((string) new FileResource($fixturesDir.'yaml'.\DIRECTORY_SEPARATOR.'services_prototype.yml'), $resources); diff --git a/src/Symfony/Component/ErrorHandler/Tests/ErrorEnhancer/ClassNotFoundErrorEnhancerTest.php b/src/Symfony/Component/ErrorHandler/Tests/ErrorEnhancer/ClassNotFoundErrorEnhancerTest.php index 1ca2f162b9eb1..7d061f7b4dfc3 100644 --- a/src/Symfony/Component/ErrorHandler/Tests/ErrorEnhancer/ClassNotFoundErrorEnhancerTest.php +++ b/src/Symfony/Component/ErrorHandler/Tests/ErrorEnhancer/ClassNotFoundErrorEnhancerTest.php @@ -53,7 +53,7 @@ public function testEnhance(string $originalMessage, string $enhancedMessage, $a // Unregister all autoloaders to ensure the custom provided // autoloader is the only one to be used during the test run. $autoloaders = spl_autoload_functions(); - array_map('spl_autoload_unregister', $autoloaders); + array_map(spl_autoload_unregister(...), $autoloaders); spl_autoload_register($autoloader); } @@ -62,7 +62,7 @@ public function testEnhance(string $originalMessage, string $enhancedMessage, $a } finally { if ($autoloader) { spl_autoload_unregister($autoloader); - array_map('spl_autoload_register', $autoloaders); + array_map(spl_autoload_register(...), $autoloaders); } } diff --git a/src/Symfony/Component/ExpressionLanguage/Resources/bin/generate_operator_regex.php b/src/Symfony/Component/ExpressionLanguage/Resources/bin/generate_operator_regex.php index 179810e1f6410..9ef67b708c4da 100644 --- a/src/Symfony/Component/ExpressionLanguage/Resources/bin/generate_operator_regex.php +++ b/src/Symfony/Component/ExpressionLanguage/Resources/bin/generate_operator_regex.php @@ -14,7 +14,7 @@ } $operators = ['not', '!', 'or', '||', '&&', 'and', '|', '^', '&', '==', '===', '!=', '!==', '<', '>', '>=', '<=', 'not in', 'in', '..', '+', '-', '~', '*', '/', '%', 'contains', 'starts with', 'ends with', 'matches', '**']; -$operators = array_combine($operators, array_map('strlen', $operators)); +$operators = array_combine($operators, array_map(strlen(...), $operators)); arsort($operators); $regex = []; diff --git a/src/Symfony/Component/Finder/Tests/FinderTest.php b/src/Symfony/Component/Finder/Tests/FinderTest.php index 796cf7c47ddae..eff082738a0f6 100644 --- a/src/Symfony/Component/Finder/Tests/FinderTest.php +++ b/src/Symfony/Component/Finder/Tests/FinderTest.php @@ -1138,7 +1138,7 @@ public function testGetIterator() $finder = $this->buildFinder(); $a = iterator_to_array($finder->directories()->in(self::$tmpDir)); - $a = array_values(array_map('strval', $a)); + $a = array_values(array_map(strval(...), $a)); sort($a); $this->assertEquals($expected, $a, 'implements the \IteratorAggregate interface'); } diff --git a/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php b/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php index 8c25c19ccf49e..4ba9313bf425d 100644 --- a/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php +++ b/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php @@ -95,7 +95,7 @@ public function getChoices(): array public function getValues(): array { - return array_map('strval', array_keys($this->choices)); + return array_map(strval(...), array_keys($this->choices)); } public function getStructuredValues(): array diff --git a/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php b/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php index c417b84ac5755..87e29eb956b44 100644 --- a/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php +++ b/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php @@ -263,7 +263,7 @@ private static function addChoiceViewsGroupedByCallable(callable $groupBy, $choi return; } - $groupLabels = \is_array($groupLabels) ? array_map('strval', $groupLabels) : [(string) $groupLabels]; + $groupLabels = \is_array($groupLabels) ? array_map(strval(...), $groupLabels) : [(string) $groupLabels]; foreach ($groupLabels as $groupLabel) { // Initialize the group views if necessary. Unnecessarily built group diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Loader/FilterChoiceLoaderDecoratorTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Loader/FilterChoiceLoaderDecoratorTest.php index 5a41e5aff3415..f22071d2c6e14 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Loader/FilterChoiceLoaderDecoratorTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Loader/FilterChoiceLoaderDecoratorTest.php @@ -78,7 +78,7 @@ public function testLoadValuesForChoices() public function testLoadChoicesForValues() { $evenChoices = [1 => 2, 3 => 4]; - $values = array_map('strval', range(1, 4)); + $values = array_map(strval(...), range(1, 4)); $filter = fn ($choice) => 0 === $choice % 2; diff --git a/src/Symfony/Component/HttpClient/AmpHttpClient.php b/src/Symfony/Component/HttpClient/AmpHttpClient.php index 8542932d59549..7878b0acead8a 100644 --- a/src/Symfony/Component/HttpClient/AmpHttpClient.php +++ b/src/Symfony/Component/HttpClient/AmpHttpClient.php @@ -137,7 +137,7 @@ public function request(string $method, string $url, array $options = []): Respo if ('' !== $request->getUri()->getUserInfo() && !$request->hasHeader('authorization')) { $auth = explode(':', $request->getUri()->getUserInfo(), 2); - $auth = array_map('rawurldecode', $auth) + [1 => '']; + $auth = array_map(rawurldecode(...), $auth) + [1 => '']; $request->setHeader('Authorization', 'Basic '.base64_encode(implode(':', $auth))); } diff --git a/src/Symfony/Component/HttpClient/Response/CurlResponse.php b/src/Symfony/Component/HttpClient/Response/CurlResponse.php index 66881d9e95ad7..76649c703b06d 100644 --- a/src/Symfony/Component/HttpClient/Response/CurlResponse.php +++ b/src/Symfony/Component/HttpClient/Response/CurlResponse.php @@ -386,7 +386,7 @@ private static function parseHeaderLine($ch, string $data, array &$info, array & } if (\function_exists('openssl_x509_read') && $certinfo = curl_getinfo($ch, \CURLINFO_CERTINFO)) { - $info['peer_certificate_chain'] = array_map('openssl_x509_read', array_column($certinfo, 'Cert')); + $info['peer_certificate_chain'] = array_map(openssl_x509_read(...), array_column($certinfo, 'Cert')); } if (300 <= $info['http_code'] && $info['http_code'] < 400) { diff --git a/src/Symfony/Component/HttpFoundation/HeaderBag.php b/src/Symfony/Component/HttpFoundation/HeaderBag.php index 0883024b3b50b..f8b3392e783e8 100644 --- a/src/Symfony/Component/HttpFoundation/HeaderBag.php +++ b/src/Symfony/Component/HttpFoundation/HeaderBag.php @@ -46,7 +46,7 @@ public function __toString(): string } ksort($headers); - $max = max(array_map('strlen', array_keys($headers))) + 1; + $max = max(array_map(strlen(...), array_keys($headers))) + 1; $content = ''; foreach ($headers as $name => $values) { $name = ucwords($name, '-'); diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index 56d74874c1319..4c49d0b7eca3b 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -1619,7 +1619,7 @@ public function getCharsets(): array return $this->charsets; } - return $this->charsets = array_map('strval', array_keys(AcceptHeader::fromString($this->headers->get('Accept-Charset'))->all())); + return $this->charsets = array_map(strval(...), array_keys(AcceptHeader::fromString($this->headers->get('Accept-Charset'))->all())); } /** @@ -1633,7 +1633,7 @@ public function getEncodings(): array return $this->encodings; } - return $this->encodings = array_map('strval', array_keys(AcceptHeader::fromString($this->headers->get('Accept-Encoding'))->all())); + return $this->encodings = array_map(strval(...), array_keys(AcceptHeader::fromString($this->headers->get('Accept-Encoding'))->all())); } /** @@ -1647,7 +1647,7 @@ public function getAcceptableContentTypes(): array return $this->acceptableContentTypes; } - return $this->acceptableContentTypes = array_map('strval', array_keys(AcceptHeader::fromString($this->headers->get('Accept'))->all())); + return $this->acceptableContentTypes = array_map(strval(...), array_keys(AcceptHeader::fromString($this->headers->get('Accept'))->all())); } /** diff --git a/src/Symfony/Component/HttpFoundation/RequestMatcher.php b/src/Symfony/Component/HttpFoundation/RequestMatcher.php index 28cdd20c55f32..d2472b8672ec7 100644 --- a/src/Symfony/Component/HttpFoundation/RequestMatcher.php +++ b/src/Symfony/Component/HttpFoundation/RequestMatcher.php @@ -72,7 +72,7 @@ public function __construct(string $path = null, string $host = null, string|arr */ public function matchScheme(string|array|null $scheme) { - $this->schemes = null !== $scheme ? array_map('strtolower', (array) $scheme) : []; + $this->schemes = null !== $scheme ? array_map(strtolower(...), (array) $scheme) : []; } /** @@ -130,7 +130,7 @@ public function matchIps(string|array|null $ips) */ public function matchMethod(string|array|null $method) { - $this->methods = null !== $method ? array_map('strtoupper', (array) $method) : []; + $this->methods = null !== $method ? array_map(strtoupper(...), (array) $method) : []; } /** diff --git a/src/Symfony/Component/HttpFoundation/RequestMatcher/MethodRequestMatcher.php b/src/Symfony/Component/HttpFoundation/RequestMatcher/MethodRequestMatcher.php index b37f6e3c87f96..04f0171c778c2 100644 --- a/src/Symfony/Component/HttpFoundation/RequestMatcher/MethodRequestMatcher.php +++ b/src/Symfony/Component/HttpFoundation/RequestMatcher/MethodRequestMatcher.php @@ -32,7 +32,7 @@ class MethodRequestMatcher implements RequestMatcherInterface */ public function __construct(array|string $methods) { - $this->methods = array_reduce(array_map('strtoupper', (array) $methods), static fn (array $methods, string $method) => array_merge($methods, preg_split('/\s*,\s*/', $method)), []); + $this->methods = array_reduce(array_map(strtoupper(...), (array) $methods), static fn (array $methods, string $method) => array_merge($methods, preg_split('/\s*,\s*/', $method)), []); } public function matches(Request $request): bool diff --git a/src/Symfony/Component/HttpFoundation/RequestMatcher/SchemeRequestMatcher.php b/src/Symfony/Component/HttpFoundation/RequestMatcher/SchemeRequestMatcher.php index 9c9cd58b983cc..7276f0864cc78 100644 --- a/src/Symfony/Component/HttpFoundation/RequestMatcher/SchemeRequestMatcher.php +++ b/src/Symfony/Component/HttpFoundation/RequestMatcher/SchemeRequestMatcher.php @@ -32,7 +32,7 @@ class SchemeRequestMatcher implements RequestMatcherInterface */ public function __construct(array|string $schemes) { - $this->schemes = array_reduce(array_map('strtolower', (array) $schemes), static fn (array $schemes, string $scheme) => array_merge($schemes, preg_split('/\s*,\s*/', $scheme)), []); + $this->schemes = array_reduce(array_map(strtolower(...), (array) $schemes), static fn (array $schemes, string $scheme) => array_merge($schemes, preg_split('/\s*,\s*/', $scheme)), []); } public function matches(Request $request): bool diff --git a/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php b/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php index 9e8c5793a7668..bfd7c6a59e216 100644 --- a/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php +++ b/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php @@ -87,7 +87,7 @@ public function all(string $key = null): array if (null !== $key) { $key = strtr($key, self::UPPER, self::LOWER); - return 'set-cookie' !== $key ? $headers[$key] ?? [] : array_map('strval', $this->getCookies()); + return 'set-cookie' !== $key ? $headers[$key] ?? [] : array_map(strval(...), $this->getCookies()); } foreach ($this->getCookies() as $cookie) { diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php index a5257b4172549..dbf90f7e0d270 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php @@ -438,7 +438,7 @@ private function buildDsnFromUrl(string $dsnOrUrl): string return $dsnOrUrl; // If the URL is not valid, let's assume it might be a DSN already. } - $params = array_map('rawurldecode', $params); + $params = array_map(rawurldecode(...), $params); // Override the default username and password. Values passed through options will still win over these in the constructor. if (isset($params['user'])) { diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockFileSessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockFileSessionStorageTest.php index 3f994cb2a7f9f..675fdb297b23e 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockFileSessionStorageTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockFileSessionStorageTest.php @@ -41,7 +41,7 @@ protected function setUp(): void protected function tearDown(): void { - array_map('unlink', glob($this->sessionDir.'/*')); + array_map(unlink(...), glob($this->sessionDir.'/*')); if (is_dir($this->sessionDir)) { @rmdir($this->sessionDir); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php index 717c6773cd658..e66eab89d5e46 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php @@ -45,7 +45,7 @@ protected function setUp(): void protected function tearDown(): void { session_write_close(); - array_map('unlink', glob($this->savePath.'/*')); + array_map(unlink(...), glob($this->savePath.'/*')); if (is_dir($this->savePath)) { @rmdir($this->savePath); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php index c0c667545243b..701557db5d576 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php @@ -41,7 +41,7 @@ protected function setUp(): void protected function tearDown(): void { session_write_close(); - array_map('unlink', glob($this->savePath.'/*')); + array_map(unlink(...), glob($this->savePath.'/*')); if (is_dir($this->savePath)) { @rmdir($this->savePath); } diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index ef3a92baf8a64..7d276159cd911 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -681,7 +681,7 @@ protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container 'inline_factories' => $inlineFactories, 'inline_class_loader' => $inlineClassLoader, 'build_time' => $container->hasParameter('kernel.container_build_time') ? $container->getParameter('kernel.container_build_time') : time(), - 'preload_classes' => array_map('get_class', $this->bundles), + 'preload_classes' => array_map(get_class(...), $this->bundles), ]); $rootCode = array_pop($content); @@ -741,7 +741,7 @@ private function preBoot(): ContainerInterface } if ($container->hasParameter('kernel.trusted_proxies') && $container->hasParameter('kernel.trusted_headers') && $trustedProxies = $container->getParameter('kernel.trusted_proxies')) { - Request::setTrustedProxies(\is_array($trustedProxies) ? $trustedProxies : array_map('trim', explode(',', $trustedProxies)), $container->getParameter('kernel.trusted_headers')); + Request::setTrustedProxies(\is_array($trustedProxies) ? $trustedProxies : array_map(trim(...), explode(',', $trustedProxies)), $container->getParameter('kernel.trusted_headers')); } return $container; diff --git a/src/Symfony/Component/Intl/Data/Bundle/Writer/TextBundleWriter.php b/src/Symfony/Component/Intl/Data/Bundle/Writer/TextBundleWriter.php index f9e577777406b..0e56a52df67d6 100644 --- a/src/Symfony/Component/Intl/Data/Bundle/Writer/TextBundleWriter.php +++ b/src/Symfony/Component/Intl/Data/Bundle/Writer/TextBundleWriter.php @@ -73,7 +73,7 @@ private function writeResource($file, mixed $value, int $indentation, bool $requ } if (\is_array($value)) { - $intValues = \count($value) === \count(array_filter($value, 'is_int')); + $intValues = \count($value) === \count(array_filter($value, is_int(...))); // check that the keys are 0-indexed and ascending $intKeys = array_is_list($value); diff --git a/src/Symfony/Component/Intl/Resources/emoji/build.php b/src/Symfony/Component/Intl/Resources/emoji/build.php index fb1a6c045fe2b..0ecce10d9c88c 100755 --- a/src/Symfony/Component/Intl/Resources/emoji/build.php +++ b/src/Symfony/Component/Intl/Resources/emoji/build.php @@ -80,7 +80,7 @@ public static function buildRules(array $emojisCodePoints): Generator $emoji = $result->getAttribute('cp'); $name = $result->textContent; $parts = preg_split('//u', $emoji, -1, \PREG_SPLIT_NO_EMPTY); - $emojiCodePoints = implode(' ', array_map('dechex', array_map('mb_ord', $parts))); + $emojiCodePoints = implode(' ', array_map(dechex(...), array_map(mb_ord(...), $parts))); if (!array_key_exists($emojiCodePoints, $emojisCodePoints)) { $ignored[] = [ 'locale' => $locale, diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php index ea4fb6b48d185..c0e58ecb2a6ec 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php @@ -121,7 +121,7 @@ protected function configureOptions(OptionsResolver $resolver) $resolver->setDefault('referrals', false); $resolver->setAllowedTypes('referrals', 'bool'); $resolver->setDefault('options', function (OptionsResolver $options, Options $parent) { - $options->setDefined(array_map('strtolower', array_keys((new \ReflectionClass(ConnectionOptions::class))->getConstants()))); + $options->setDefined(array_map(strtolower(...), array_keys((new \ReflectionClass(ConnectionOptions::class))->getConstants()))); if (true === $parent['debug']) { $options->setDefault('debug_level', 7); diff --git a/src/Symfony/Component/Mailer/EventListener/MessengerTransportListener.php b/src/Symfony/Component/Mailer/EventListener/MessengerTransportListener.php index 8cf8cc800d103..b9fc8ff9275ab 100644 --- a/src/Symfony/Component/Mailer/EventListener/MessengerTransportListener.php +++ b/src/Symfony/Component/Mailer/EventListener/MessengerTransportListener.php @@ -35,7 +35,7 @@ public function onMessage(MessageEvent $event): void } $names = $message->getHeaders()->get('X-Bus-Transport')->getBody(); - $names = array_map('trim', explode(',', $names)); + $names = array_map(trim(...), explode(',', $names)); $event->addStamp(new TransportNamesStamp($names)); $message->getHeaders()->remove('X-Bus-Transport'); } diff --git a/src/Symfony/Component/Mailer/Transport/RoundRobinTransport.php b/src/Symfony/Component/Mailer/Transport/RoundRobinTransport.php index c5587bb2a3585..84ebfcb67c7df 100644 --- a/src/Symfony/Component/Mailer/Transport/RoundRobinTransport.php +++ b/src/Symfony/Component/Mailer/Transport/RoundRobinTransport.php @@ -65,7 +65,7 @@ public function send(RawMessage $message, Envelope $envelope = null): ?SentMessa public function __toString(): string { - return $this->getNameSymbol().'('.implode(' ', array_map('strval', $this->transports)).')'; + return $this->getNameSymbol().'('.implode(' ', array_map(strval(...), $this->transports)).')'; } /** diff --git a/src/Symfony/Component/Mailer/Transport/Smtp/EsmtpTransport.php b/src/Symfony/Component/Mailer/Transport/Smtp/EsmtpTransport.php index 0dfe9d1905547..c9ba1f261288b 100644 --- a/src/Symfony/Component/Mailer/Transport/Smtp/EsmtpTransport.php +++ b/src/Symfony/Component/Mailer/Transport/Smtp/EsmtpTransport.php @@ -174,7 +174,7 @@ private function handleAuth(array $modes): void $authNames = []; $errors = []; - $modes = array_map('strtolower', $modes); + $modes = array_map(strtolower(...), $modes); foreach ($this->authenticators as $authenticator) { if (!\in_array(strtolower($authenticator->getAuthKeyword()), $modes, true)) { continue; diff --git a/src/Symfony/Component/Mime/CharacterStream.php b/src/Symfony/Component/Mime/CharacterStream.php index 21d7bc5f01737..79f1106cc6413 100644 --- a/src/Symfony/Component/Mime/CharacterStream.php +++ b/src/Symfony/Component/Mime/CharacterStream.php @@ -135,7 +135,7 @@ public function read(int $length): ?string public function readBytes(int $length): ?array { if (null !== $read = $this->read($length)) { - return array_map('ord', str_split($read, 1)); + return array_map(ord(...), str_split($read, 1)); } return null; diff --git a/src/Symfony/Component/Notifier/Bridge/Twitter/TwitterTransport.php b/src/Symfony/Component/Notifier/Bridge/Twitter/TwitterTransport.php index b5f450b92eae5..ee2de7ac321e4 100644 --- a/src/Symfony/Component/Notifier/Bridge/Twitter/TwitterTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Twitter/TwitterTransport.php @@ -95,7 +95,7 @@ public function request(string $method, string $url, array $options): ResponseIn $oauth['oauth_signature'] = base64_encode(hash_hmac( 'sha1', - implode('&', array_map('rawurlencode', [ + implode('&', array_map(rawurlencode(...), [ $method, $url, implode('&', array_map(fn ($k) => rawurlencode($k).'='.rawurlencode($sign[$k]), array_keys($sign))), diff --git a/src/Symfony/Component/Notifier/Transport/RoundRobinTransport.php b/src/Symfony/Component/Notifier/Transport/RoundRobinTransport.php index cb5fd4bd997e0..7f689b256c10d 100644 --- a/src/Symfony/Component/Notifier/Transport/RoundRobinTransport.php +++ b/src/Symfony/Component/Notifier/Transport/RoundRobinTransport.php @@ -48,7 +48,7 @@ public function __construct(array $transports, int $retryPeriod = 60) public function __toString(): string { - return implode(' '.$this->getNameSymbol().' ', array_map('strval', $this->transports)); + return implode(' '.$this->getNameSymbol().' ', array_map(strval(...), $this->transports)); } public function supports(MessageInterface $message): bool diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 3c70be2a2a162..d0a7dcc730181 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -302,10 +302,10 @@ public function start(callable $callback = null, array $env = []) $descriptors = $this->getDescriptors(); if ($this->env) { - $env += '\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($this->env, $env, 'strcasecmp') : $this->env; + $env += '\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($this->env, $env, strcasecmp(...)) : $this->env; } - $env += '\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($this->getDefaultEnv(), $env, 'strcasecmp') : $this->getDefaultEnv(); + $env += '\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($this->getDefaultEnv(), $env, strcasecmp(...)) : $this->getDefaultEnv(); if (\is_array($commandline = $this->commandline)) { $commandline = implode(' ', array_map($this->escapeArgument(...), $commandline)); @@ -1581,8 +1581,8 @@ private function replacePlaceholders(string $commandline, array $env) private function getDefaultEnv(): array { $env = getenv(); - $env = ('\\' === \DIRECTORY_SEPARATOR ? array_intersect_ukey($env, $_SERVER, 'strcasecmp') : array_intersect_key($env, $_SERVER)) ?: $env; + $env = ('\\' === \DIRECTORY_SEPARATOR ? array_intersect_ukey($env, $_SERVER, strcasecmp(...)) : array_intersect_key($env, $_SERVER)) ?: $env; - return $_ENV + ('\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($env, $_ENV, 'strcasecmp') : $env); + return $_ENV + ('\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($env, $_ENV, strcasecmp(...)) : $env); } } diff --git a/src/Symfony/Component/Routing/Exception/MethodNotAllowedException.php b/src/Symfony/Component/Routing/Exception/MethodNotAllowedException.php index 0e4381bb6d997..5f3b8ecda8d11 100644 --- a/src/Symfony/Component/Routing/Exception/MethodNotAllowedException.php +++ b/src/Symfony/Component/Routing/Exception/MethodNotAllowedException.php @@ -27,7 +27,7 @@ class MethodNotAllowedException extends \RuntimeException implements ExceptionIn */ public function __construct(array $allowedMethods, string $message = '', int $code = 0, \Throwable $previous = null) { - $this->allowedMethods = array_map('strtoupper', $allowedMethods); + $this->allowedMethods = array_map(strtoupper(...), $allowedMethods); parent::__construct($message, $code, $previous); } diff --git a/src/Symfony/Component/Routing/Route.php b/src/Symfony/Component/Routing/Route.php index dc0554be902c1..108dce0c85031 100644 --- a/src/Symfony/Component/Routing/Route.php +++ b/src/Symfony/Component/Routing/Route.php @@ -164,7 +164,7 @@ public function getSchemes(): array */ public function setSchemes(string|array $schemes): static { - $this->schemes = array_map('strtolower', (array) $schemes); + $this->schemes = array_map(strtolower(...), (array) $schemes); $this->compiled = null; return $this; @@ -199,7 +199,7 @@ public function getMethods(): array */ public function setMethods(string|array $methods): static { - $this->methods = array_map('strtoupper', (array) $methods); + $this->methods = array_map(strtoupper(...), (array) $methods); $this->compiled = null; return $this; diff --git a/src/Symfony/Component/Routing/Tests/RouterTest.php b/src/Symfony/Component/Routing/Tests/RouterTest.php index 0d87d26b4f8c3..f54d628fa7530 100644 --- a/src/Symfony/Component/Routing/Tests/RouterTest.php +++ b/src/Symfony/Component/Routing/Tests/RouterTest.php @@ -42,7 +42,7 @@ protected function setUp(): void protected function tearDown(): void { if (is_dir($this->cacheDir)) { - array_map('unlink', glob($this->cacheDir.\DIRECTORY_SEPARATOR.'*')); + array_map(unlink(...), glob($this->cacheDir.\DIRECTORY_SEPARATOR.'*')); @rmdir($this->cacheDir); } diff --git a/src/Symfony/Component/Security/Core/User/InMemoryUser.php b/src/Symfony/Component/Security/Core/User/InMemoryUser.php index ca9884174f10f..4a5b56636307d 100644 --- a/src/Symfony/Component/Security/Core/User/InMemoryUser.php +++ b/src/Symfony/Component/Security/Core/User/InMemoryUser.php @@ -90,8 +90,8 @@ public function isEqualTo(UserInterface $user): bool return false; } - $currentRoles = array_map('strval', (array) $this->getRoles()); - $newRoles = array_map('strval', (array) $user->getRoles()); + $currentRoles = array_map(strval(...), (array) $this->getRoles()); + $newRoles = array_map(strval(...), (array) $user->getRoles()); $rolesChanged = \count($currentRoles) !== \count($newRoles) || \count($currentRoles) !== \count(array_intersect($currentRoles, $newRoles)); if ($rolesChanged) { return false; diff --git a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php index c7ad4a4a416ad..e460fe2c7b275 100644 --- a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php @@ -300,7 +300,7 @@ private static function hasUserChanged(UserInterface $originalUser, TokenInterfa } } - $userRoles = array_map('strval', (array) $refreshedUser->getRoles()); + $userRoles = array_map(strval(...), (array) $refreshedUser->getRoles()); if ($refreshedToken instanceof SwitchUserToken) { $userRoles[] = 'ROLE_PREVIOUS_ADMIN'; diff --git a/src/Symfony/Component/Serializer/DataCollector/SerializerDataCollector.php b/src/Symfony/Component/Serializer/DataCollector/SerializerDataCollector.php index 9dd1752fad1e7..03b722602d278 100644 --- a/src/Symfony/Component/Serializer/DataCollector/SerializerDataCollector.php +++ b/src/Symfony/Component/Serializer/DataCollector/SerializerDataCollector.php @@ -50,7 +50,7 @@ public function getData(): Data|array public function getHandledCount(): int { - return array_sum(array_map('count', $this->data)); + return array_sum(array_map(count(...), $this->data)); } public function getTotalTime(): float diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/Features/CacheableObjectAttributesTestTrait.php b/src/Symfony/Component/Serializer/Tests/Normalizer/Features/CacheableObjectAttributesTestTrait.php index 296a9dee8b7d2..43969b8e195b7 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/Features/CacheableObjectAttributesTestTrait.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/Features/CacheableObjectAttributesTestTrait.php @@ -48,7 +48,7 @@ public function testObjectCollectionNormalization() */ public function testReversedObjectCollectionNormalization() { - [$collection, $expectedArray] = array_map('array_reverse', $this->getObjectCollectionWithExpectedArray()); + [$collection, $expectedArray] = array_map(array_reverse(...), $this->getObjectCollectionWithExpectedArray()); $this->assertCollectionNormalizedProperly($collection, $expectedArray); } diff --git a/src/Symfony/Component/String/AbstractUnicodeString.php b/src/Symfony/Component/String/AbstractUnicodeString.php index 0d8db3a2757e5..5a7bd54cb36be 100644 --- a/src/Symfony/Component/String/AbstractUnicodeString.php +++ b/src/Symfony/Component/String/AbstractUnicodeString.php @@ -405,7 +405,7 @@ public function trimPrefix($prefix): static $prefix = $prefix->string; } - $prefix = implode('|', array_map('preg_quote', (array) $prefix)); + $prefix = implode('|', array_map(preg_quote(...), (array) $prefix)); $str->string = preg_replace("{^(?:$prefix)}iuD", '', $this->string); return $str; @@ -438,7 +438,7 @@ public function trimSuffix($suffix): static $suffix = $suffix->string; } - $suffix = implode('|', array_map('preg_quote', (array) $suffix)); + $suffix = implode('|', array_map(preg_quote(...), (array) $suffix)); $str->string = preg_replace("{(?:$suffix)$}iuD", '', $this->string); return $str; diff --git a/src/Symfony/Component/String/LazyString.php b/src/Symfony/Component/String/LazyString.php index 9523b8cdb2248..9661e29f279b6 100644 --- a/src/Symfony/Component/String/LazyString.php +++ b/src/Symfony/Component/String/LazyString.php @@ -26,7 +26,7 @@ class LazyString implements \Stringable, \JsonSerializable public static function fromCallable(callable|array $callback, mixed ...$arguments): static { if (\is_array($callback) && !\is_callable($callback) && !(($callback[0] ?? null) instanceof \Closure || 2 < \count($callback))) { - throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a callable or a [Closure, method] lazy-callable, "%s" given.', __METHOD__, '['.implode(', ', array_map('get_debug_type', $callback)).']')); + throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a callable or a [Closure, method] lazy-callable, "%s" given.', __METHOD__, '['.implode(', ', array_map(get_debug_type(...), $callback)).']')); } $lazyString = new static(); diff --git a/src/Symfony/Component/Translation/Dumper/MoFileDumper.php b/src/Symfony/Component/Translation/Dumper/MoFileDumper.php index 9ded5f4ef3855..67c7a8334502f 100644 --- a/src/Symfony/Component/Translation/Dumper/MoFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/MoFileDumper.php @@ -28,7 +28,7 @@ public function formatCatalogue(MessageCatalogue $messages, string $domain, arra $size = 0; foreach ($messages->all($domain) as $source => $target) { - $offsets[] = array_map('strlen', [$sources, $source, $targets, $target]); + $offsets[] = array_map(strlen(...), [$sources, $source, $targets, $target]); $sources .= "\0".$source; $targets .= "\0".$target; ++$size; diff --git a/src/Symfony/Component/Translation/Loader/PoFileLoader.php b/src/Symfony/Component/Translation/Loader/PoFileLoader.php index 9f7f125d4d8e2..b9e544ccbe1b5 100644 --- a/src/Symfony/Component/Translation/Loader/PoFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/PoFileLoader.php @@ -82,7 +82,7 @@ protected function loadResource(string $resource): array $item = $defaults; $flags = []; } elseif (str_starts_with($line, '#,')) { - $flags = array_map('trim', explode(',', substr($line, 2))); + $flags = array_map(trim(...), explode(',', substr($line, 2))); } elseif (str_starts_with($line, 'msgid "')) { // We start a new msg so save previous // TODO: this fails when comments or contexts are added diff --git a/src/Symfony/Component/Translation/Resources/bin/translation-status.php b/src/Symfony/Component/Translation/Resources/bin/translation-status.php index 21ef604723a84..82add02aabc96 100644 --- a/src/Symfony/Component/Translation/Resources/bin/translation-status.php +++ b/src/Symfony/Component/Translation/Resources/bin/translation-status.php @@ -209,7 +209,7 @@ function printTable($translations, $verboseOutput, bool $includeCompletedLanguag return; } - $longestLocaleNameLength = max(array_map('strlen', array_keys($translations))); + $longestLocaleNameLength = max(array_map(strlen(...), array_keys($translations))); foreach ($translations as $locale => $translation) { if (!$includeCompletedLanguages && $translation['is_completed']) { diff --git a/src/Symfony/Component/Translation/Util/XliffUtils.php b/src/Symfony/Component/Translation/Util/XliffUtils.php index 335c34beb56f3..45a073a4e9b3e 100644 --- a/src/Symfony/Component/Translation/Util/XliffUtils.php +++ b/src/Symfony/Component/Translation/Util/XliffUtils.php @@ -161,7 +161,7 @@ private static function fixXmlLocation(string $schemaSource, string $xmlUri): st } $drive = '\\' === \DIRECTORY_SEPARATOR ? array_shift($parts).'/' : ''; - $newPath = $locationstart.$drive.implode('/', array_map('rawurlencode', $parts)); + $newPath = $locationstart.$drive.implode('/', array_map(rawurlencode(...), $parts)); return str_replace($xmlUri, $newPath, $schemaSource); } diff --git a/src/Symfony/Component/VarExporter/ProxyHelper.php b/src/Symfony/Component/VarExporter/ProxyHelper.php index c323f0b2cd9b0..635e91bfcfd8d 100644 --- a/src/Symfony/Component/VarExporter/ProxyHelper.php +++ b/src/Symfony/Component/VarExporter/ProxyHelper.php @@ -307,7 +307,7 @@ public static function exportType(\ReflectionFunctionAbstract|\ReflectionPropert private static function exportPropertyScopes(string $parent): string { $propertyScopes = Hydrator::$propertyScopes[$parent] ??= Hydrator::getPropertyScopes($parent); - uksort($propertyScopes, 'strnatcmp'); + uksort($propertyScopes, strnatcmp(...)); $propertyScopes = VarExporter::export($propertyScopes); $propertyScopes = str_replace(VarExporter::export($parent), 'parent::class', $propertyScopes); $propertyScopes = preg_replace("/(?|(,)\n( ) |\n |,\n (\]))/", '$1$2', $propertyScopes);