diff --git a/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php index 539ef1697fbb1..a422bcc0407e3 100644 --- a/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php @@ -366,7 +366,7 @@ private function getTagVersions(array $tagsByKey, bool $persistTags): array (self::$saveTags)($this->tags, $newTags); } - while ($now > ($this->knownTagVersions[$tag = array_key_first($this->knownTagVersions)][0] ?? \INF)) { + while ($now > ($this->knownTagVersions[$tag = array_key_first($this->knownTagVersions) ?? ''][0] ?? \INF)) { unset($this->knownTagVersions[$tag]); } diff --git a/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php index ec0e12ab6fdf0..e4938352c3234 100644 --- a/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php @@ -331,7 +331,7 @@ public function normalizeKeys(bool $bool): static public function append(NodeDefinition $node): static { - $this->children[$node->name] = $node->setParent($this); + $this->children[$node->name ?? ''] = $node->setParent($this); return $this; } diff --git a/src/Symfony/Component/Console/Input/ArgvInput.php b/src/Symfony/Component/Console/Input/ArgvInput.php index a33092aee81e1..b5f8666897047 100644 --- a/src/Symfony/Component/Console/Input/ArgvInput.php +++ b/src/Symfony/Component/Console/Input/ArgvInput.php @@ -176,7 +176,7 @@ private function parseArgument(string $token): void } else { $all = $this->definition->getArguments(); $symfonyCommandName = null; - if (($inputArgument = $all[$key = array_key_first($all)] ?? null) && 'command' === $inputArgument->getName()) { + if (($inputArgument = $all[$key = array_key_first($all) ?? ''] ?? null) && 'command' === $inputArgument->getName()) { $symfonyCommandName = $this->arguments['command'] ?? null; unset($all[$key]); } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php index 99652624004a3..e542a2f4970ae 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php @@ -79,7 +79,7 @@ public function __construct(bool $autoload = false, array $skippedIds = []) protected function processValue(mixed $value, bool $isRoot = false): mixed { - if (isset($this->skippedIds[$this->currentId])) { + if (isset($this->skippedIds[$this->currentId ?? ''])) { return $value; } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/DefinitionErrorExceptionPass.php b/src/Symfony/Component/DependencyInjection/Compiler/DefinitionErrorExceptionPass.php index 204401cd2c8ee..251f26ef23b4d 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/DefinitionErrorExceptionPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/DefinitionErrorExceptionPass.php @@ -69,9 +69,9 @@ protected function processValue(mixed $value, bool $isRoot = false): mixed ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE === $value->getInvalidBehavior() || ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $value->getInvalidBehavior() ) { - $this->sourceReferences[$targetId][$this->currentId] ??= true; + $this->sourceReferences[$targetId][$this->currentId ?? ''] ??= true; } else { - $this->sourceReferences[$targetId][$this->currentId] = false; + $this->sourceReferences[$targetId][$this->currentId ?? ''] = false; } return $value; @@ -81,7 +81,7 @@ protected function processValue(mixed $value, bool $isRoot = false): mixed return parent::processValue($value, $isRoot); } - $this->erroredDefinitions[$this->currentId] = $value; + $this->erroredDefinitions[$this->currentId ?? ''] = $value; return parent::processValue($value); } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php index 9b75fea390dd5..0909cf3f9198a 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php @@ -146,7 +146,7 @@ protected function processValue(mixed $value, bool $isRoot = false): mixed $this->container->log($this, \sprintf('Inlined service "%s" to "%s".', $id, $this->currentId)); $this->inlinedIds[$id] = $definition->isPublic() || !$definition->isShared(); - $this->notInlinedIds[$this->currentId] = true; + $this->notInlinedIds[$this->currentId ?? ''] = true; if ($definition->isShared()) { return $definition; diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ResolveBindingsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ResolveBindingsPass.php index 404709585fe33..9fa6178226ca7 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ResolveBindingsPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ResolveBindingsPass.php @@ -121,10 +121,10 @@ protected function processValue(mixed $value, bool $isRoot = false): mixed foreach ($bindings as $key => $binding) { [$bindingValue, $bindingId, $used, $bindingType, $file] = $binding->getValues(); if ($used) { - $this->usedBindings[$bindingId] = true; - unset($this->unusedBindings[$bindingId]); - } elseif (!isset($this->usedBindings[$bindingId])) { - $this->unusedBindings[$bindingId] = [$key, $this->currentId, $bindingType, $file]; + $this->usedBindings[$bindingId ?? ''] = true; + unset($this->unusedBindings[$bindingId ?? '']); + } elseif (!isset($this->usedBindings[$bindingId ?? ''])) { + $this->unusedBindings[$bindingId ?? ''] = [$key, $this->currentId, $bindingType, $file]; } if (preg_match('/^(?:(?:array|bool|float|int|string|iterable|([^ $]++)) )\$/', $key, $m)) { @@ -263,8 +263,8 @@ private function getBindingValue(BoundArgument $binding): mixed { [$bindingValue, $bindingId] = $binding->getValues(); - $this->usedBindings[$bindingId] = true; - unset($this->unusedBindings[$bindingId]); + $this->usedBindings[$bindingId ?? ''] = true; + unset($this->unusedBindings[$bindingId ?? '']); return $bindingValue; } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ResolveHotPathPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ResolveHotPathPass.php index 705bb837b907c..59d87b3946637 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ResolveHotPathPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ResolveHotPathPass.php @@ -51,7 +51,7 @@ protected function processValue(mixed $value, bool $isRoot = false): mixed return $value->clearTag('container.hot_path'); } - $this->resolvedIds[$this->currentId] = true; + $this->resolvedIds[$this->currentId ?? ''] = true; if (!$value->hasTag('container.hot_path')) { return $value; diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index fdbd290baf88f..bca4356310716 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -207,7 +207,7 @@ public function registerExtension(ExtensionInterface $extension) $this->extensions[$extension->getAlias()] = $extension; if (false !== $extension->getNamespace()) { - $this->extensionsByNs[$extension->getNamespace()] = $extension; + $this->extensionsByNs[$extension->getNamespace() ?? ''] = $extension; } } diff --git a/src/Symfony/Component/Form/Tests/Fixtures/FixedDataTransformer.php b/src/Symfony/Component/Form/Tests/Fixtures/FixedDataTransformer.php index f3121fc1039da..2a1451c5af5b6 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/FixedDataTransformer.php +++ b/src/Symfony/Component/Form/Tests/Fixtures/FixedDataTransformer.php @@ -25,6 +25,7 @@ public function __construct(array $mapping) public function transform($value): mixed { + $value ??= ''; if (!\array_key_exists($value, $this->mapping)) { throw new TransformationFailedException(sprintf('No mapping for value "%s"', $value)); } diff --git a/src/Symfony/Component/Form/Tests/Fixtures/FixedFilterListener.php b/src/Symfony/Component/Form/Tests/Fixtures/FixedFilterListener.php index ece653e87b878..891540c1acae1 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/FixedFilterListener.php +++ b/src/Symfony/Component/Form/Tests/Fixtures/FixedFilterListener.php @@ -50,8 +50,8 @@ public function preSetData(FormEvent $event) { $data = $event->getData(); - if (isset($this->mapping['preSetData'][$data])) { - $event->setData($this->mapping['preSetData'][$data]); + if (isset($this->mapping['preSetData'][$data ?? ''])) { + $event->setData($this->mapping['preSetData'][$data ?? '']); } } diff --git a/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php b/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php index 8db8dce4e7516..562f75c9a8ca7 100644 --- a/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php +++ b/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php @@ -174,7 +174,7 @@ public function getCacheControlDirective(string $key): bool|string|null */ public function setCookie(Cookie $cookie) { - $this->cookies[$cookie->getDomain()][$cookie->getPath()][$cookie->getName()] = $cookie; + $this->cookies[$cookie->getDomain() ?? ''][$cookie->getPath()][$cookie->getName()] = $cookie; $this->headerNames['set-cookie'] = 'Set-Cookie'; } @@ -187,13 +187,13 @@ public function removeCookie(string $name, ?string $path = '/', ?string $domain { $path ??= '/'; - unset($this->cookies[$domain][$path][$name]); + unset($this->cookies[$domain ?? ''][$path][$name]); - if (empty($this->cookies[$domain][$path])) { - unset($this->cookies[$domain][$path]); + if (empty($this->cookies[$domain ?? ''][$path])) { + unset($this->cookies[$domain ?? ''][$path]); - if (empty($this->cookies[$domain])) { - unset($this->cookies[$domain]); + if (empty($this->cookies[$domain ?? ''])) { + unset($this->cookies[$domain ?? '']); } } diff --git a/src/Symfony/Component/Security/Http/Logout/LogoutUrlGenerator.php b/src/Symfony/Component/Security/Http/Logout/LogoutUrlGenerator.php index 1126a0543ecbd..8550c28c6f99d 100644 --- a/src/Symfony/Component/Security/Http/Logout/LogoutUrlGenerator.php +++ b/src/Symfony/Component/Security/Http/Logout/LogoutUrlGenerator.php @@ -146,8 +146,8 @@ private function getListener(?string $key): array } // Fetch from injected current firewall information, if possible - if (isset($this->listeners[$this->currentFirewallName])) { - return $this->listeners[$this->currentFirewallName]; + if (isset($this->listeners[$this->currentFirewallName ?? ''])) { + return $this->listeners[$this->currentFirewallName ?? '']; } foreach ($this->listeners as $listener) { diff --git a/src/Symfony/Component/Serializer/Serializer.php b/src/Symfony/Component/Serializer/Serializer.php index f1caf7d954e5e..0aa24cf579af9 100644 --- a/src/Symfony/Component/Serializer/Serializer.php +++ b/src/Symfony/Component/Serializer/Serializer.php @@ -281,8 +281,8 @@ private function getNormalizer(mixed $data, ?string $format, array $context): ?N $genericType = '*'; } - if (!isset($this->normalizerCache[$format][$type])) { - $this->normalizerCache[$format][$type] = []; + if (!isset($this->normalizerCache[$format ?? ''][$type])) { + $this->normalizerCache[$format ?? ''][$type] = []; foreach ($this->normalizers as $k => $normalizer) { if (!$normalizer instanceof NormalizerInterface) { @@ -293,9 +293,9 @@ private function getNormalizer(mixed $data, ?string $format, array $context): ?N trigger_deprecation('symfony/serializer', '6.3', '"%s" should implement "NormalizerInterface::getSupportedTypes(?string $format): array".', $normalizer::class); if (!$normalizer instanceof CacheableSupportsMethodInterface || !$normalizer->hasCacheableSupportsMethod()) { - $this->normalizerCache[$format][$type][$k] = false; + $this->normalizerCache[$format ?? ''][$type][$k] = false; } elseif ($normalizer->supportsNormalization($data, $format, $context)) { - $this->normalizerCache[$format][$type][$k] = true; + $this->normalizerCache[$format ?? ''][$type][$k] = true; break; } @@ -313,7 +313,7 @@ private function getNormalizer(mixed $data, ?string $format, array $context): ?N if (null === $isCacheable) { unset($supportedTypes['*'], $supportedTypes['object']); - } elseif ($this->normalizerCache[$format][$type][$k] = $isCacheable && $normalizer->supportsNormalization($data, $format, $context)) { + } elseif ($this->normalizerCache[$format ?? ''][$type][$k] = $isCacheable && $normalizer->supportsNormalization($data, $format, $context)) { break 2; } @@ -324,13 +324,13 @@ private function getNormalizer(mixed $data, ?string $format, array $context): ?N continue; } - if ($this->normalizerCache[$format][$type][$k] ??= $isCacheable && $normalizer->supportsNormalization($data, $format, $context)) { + if ($this->normalizerCache[$format ?? ''][$type][$k] ??= $isCacheable && $normalizer->supportsNormalization($data, $format, $context)) { break; } } } - foreach ($this->normalizerCache[$format][$type] as $k => $cached) { + foreach ($this->normalizerCache[$format ?? ''][$type] as $k => $cached) { $normalizer = $this->normalizers[$k]; if ($cached || $normalizer->supportsNormalization($data, $format, $context)) { return $normalizer; @@ -350,8 +350,8 @@ private function getNormalizer(mixed $data, ?string $format, array $context): ?N */ private function getDenormalizer(mixed $data, string $class, ?string $format, array $context): ?DenormalizerInterface { - if (!isset($this->denormalizerCache[$format][$class])) { - $this->denormalizerCache[$format][$class] = []; + if (!isset($this->denormalizerCache[$format ?? ''][$class])) { + $this->denormalizerCache[$format ?? ''][$class] = []; $genericType = class_exists($class) || interface_exists($class, false) ? 'object' : '*'; foreach ($this->normalizers as $k => $normalizer) { @@ -363,9 +363,9 @@ private function getDenormalizer(mixed $data, string $class, ?string $format, ar trigger_deprecation('symfony/serializer', '6.3', '"%s" should implement "DenormalizerInterface::getSupportedTypes(?string $format): array".', $normalizer::class); if (!$normalizer instanceof CacheableSupportsMethodInterface || !$normalizer->hasCacheableSupportsMethod()) { - $this->denormalizerCache[$format][$class][$k] = false; + $this->denormalizerCache[$format ?? ''][$class][$k] = false; } elseif ($normalizer->supportsDenormalization(null, $class, $format, $context)) { - $this->denormalizerCache[$format][$class][$k] = true; + $this->denormalizerCache[$format ?? ''][$class][$k] = true; break; } @@ -386,7 +386,7 @@ private function getDenormalizer(mixed $data, string $class, ?string $format, ar if (null === $isCacheable) { unset($supportedTypes['*'], $supportedTypes['object']); - } elseif ($this->denormalizerCache[$format][$class][$k] = $isCacheable && $normalizer->supportsDenormalization(null, $class, $format, $context)) { + } elseif ($this->denormalizerCache[$format ?? ''][$class][$k] = $isCacheable && $normalizer->supportsDenormalization(null, $class, $format, $context)) { break 2; } @@ -397,13 +397,13 @@ private function getDenormalizer(mixed $data, string $class, ?string $format, ar continue; } - if ($this->denormalizerCache[$format][$class][$k] ??= $isCacheable && $normalizer->supportsDenormalization(null, $class, $format, $context)) { + if ($this->denormalizerCache[$format ?? ''][$class][$k] ??= $isCacheable && $normalizer->supportsDenormalization(null, $class, $format, $context)) { break; } } } - foreach ($this->denormalizerCache[$format][$class] as $k => $cached) { + foreach ($this->denormalizerCache[$format ?? ''][$class] as $k => $cached) { $normalizer = $this->normalizers[$k]; if ($cached || $normalizer->supportsDenormalization($data, $class, $format, $context)) { return $normalizer; diff --git a/src/Symfony/Component/String/Slugger/AsciiSlugger.php b/src/Symfony/Component/String/Slugger/AsciiSlugger.php index d0c338682ecb3..d4d4e942a68a5 100644 --- a/src/Symfony/Component/String/Slugger/AsciiSlugger.php +++ b/src/Symfony/Component/String/Slugger/AsciiSlugger.php @@ -131,8 +131,8 @@ public function slug(string $string, string $separator = '-', ?string $locale = if (\is_array($this->symbolsMap)) { $map = null; - if (isset($this->symbolsMap[$locale])) { - $map = $this->symbolsMap[$locale]; + if (isset($this->symbolsMap[$locale ?? ''])) { + $map = $this->symbolsMap[$locale ?? '']; } else { $parent = self::getParentLocale($locale); if ($parent && isset($this->symbolsMap[$parent])) { diff --git a/src/Symfony/Component/Translation/DependencyInjection/TranslatorPathsPass.php b/src/Symfony/Component/Translation/DependencyInjection/TranslatorPathsPass.php index 1756e3c8c58f2..b6112e5b3a523 100644 --- a/src/Symfony/Component/Translation/DependencyInjection/TranslatorPathsPass.php +++ b/src/Symfony/Component/Translation/DependencyInjection/TranslatorPathsPass.php @@ -96,10 +96,10 @@ protected function processValue(mixed $value, bool $isRoot = false): mixed $class = $this->definitions[$i]->getClass(); if (ServiceLocator::class === $class) { - if (!isset($this->controllers[$this->currentId])) { + if (!isset($this->controllers[$this->currentId ?? ''])) { continue; } - foreach ($this->controllers[$this->currentId] as $class => $_) { + foreach ($this->controllers[$this->currentId ?? ''] as $class => $_) { $this->paths[$class] = true; } } else {