Skip to content

Commit fc3e83d

Browse files
committed
use the empty string instead of null as an array offset
1 parent b04eb43 commit fc3e83d

File tree

16 files changed

+45
-44
lines changed

16 files changed

+45
-44
lines changed

src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ private function getTagVersions(array $tagsByKey, bool $persistTags): array
366366
(self::$saveTags)($this->tags, $newTags);
367367
}
368368

369-
while ($now > ($this->knownTagVersions[$tag = array_key_first($this->knownTagVersions)][0] ?? \INF)) {
369+
while ($now > ($this->knownTagVersions[$tag = array_key_first($this->knownTagVersions) ?? ''][0] ?? \INF)) {
370370
unset($this->knownTagVersions[$tag]);
371371
}
372372

src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ public function normalizeKeys(bool $bool): static
331331

332332
public function append(NodeDefinition $node): static
333333
{
334-
$this->children[$node->name] = $node->setParent($this);
334+
$this->children[$node->name ?? ''] = $node->setParent($this);
335335

336336
return $this;
337337
}

src/Symfony/Component/Console/Input/ArgvInput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ private function parseArgument(string $token): void
176176
} else {
177177
$all = $this->definition->getArguments();
178178
$symfonyCommandName = null;
179-
if (($inputArgument = $all[$key = array_key_first($all)] ?? null) && 'command' === $inputArgument->getName()) {
179+
if (($inputArgument = $all[$key = array_key_first($all) ?? ''] ?? null) && 'command' === $inputArgument->getName()) {
180180
$symfonyCommandName = $this->arguments['command'] ?? null;
181181
unset($all[$key]);
182182
}

src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function __construct(bool $autoload = false, array $skippedIds = [])
7979

8080
protected function processValue(mixed $value, bool $isRoot = false): mixed
8181
{
82-
if (isset($this->skippedIds[$this->currentId])) {
82+
if (isset($this->skippedIds[$this->currentId ?? ''])) {
8383
return $value;
8484
}
8585

src/Symfony/Component/DependencyInjection/Compiler/DefinitionErrorExceptionPass.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ protected function processValue(mixed $value, bool $isRoot = false): mixed
6969
ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE === $value->getInvalidBehavior()
7070
|| ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $value->getInvalidBehavior()
7171
) {
72-
$this->sourceReferences[$targetId][$this->currentId] ??= true;
72+
$this->sourceReferences[$targetId][$this->currentId ?? ''] ??= true;
7373
} else {
74-
$this->sourceReferences[$targetId][$this->currentId] = false;
74+
$this->sourceReferences[$targetId][$this->currentId ?? ''] = false;
7575
}
7676

7777
return $value;
@@ -81,7 +81,7 @@ protected function processValue(mixed $value, bool $isRoot = false): mixed
8181
return parent::processValue($value, $isRoot);
8282
}
8383

84-
$this->erroredDefinitions[$this->currentId] = $value;
84+
$this->erroredDefinitions[$this->currentId ?? ''] = $value;
8585

8686
return parent::processValue($value);
8787
}

src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ protected function processValue(mixed $value, bool $isRoot = false): mixed
146146

147147
$this->container->log($this, \sprintf('Inlined service "%s" to "%s".', $id, $this->currentId));
148148
$this->inlinedIds[$id] = $definition->isPublic() || !$definition->isShared();
149-
$this->notInlinedIds[$this->currentId] = true;
149+
$this->notInlinedIds[$this->currentId ?? ''] = true;
150150

151151
if ($definition->isShared()) {
152152
return $definition;

src/Symfony/Component/DependencyInjection/Compiler/ResolveBindingsPass.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ protected function processValue(mixed $value, bool $isRoot = false): mixed
121121
foreach ($bindings as $key => $binding) {
122122
[$bindingValue, $bindingId, $used, $bindingType, $file] = $binding->getValues();
123123
if ($used) {
124-
$this->usedBindings[$bindingId] = true;
125-
unset($this->unusedBindings[$bindingId]);
126-
} elseif (!isset($this->usedBindings[$bindingId])) {
127-
$this->unusedBindings[$bindingId] = [$key, $this->currentId, $bindingType, $file];
124+
$this->usedBindings[$bindingId ?? ''] = true;
125+
unset($this->unusedBindings[$bindingId ?? '']);
126+
} elseif (!isset($this->usedBindings[$bindingId ?? ''])) {
127+
$this->unusedBindings[$bindingId ?? ''] = [$key, $this->currentId, $bindingType, $file];
128128
}
129129

130130
if (preg_match('/^(?:(?:array|bool|float|int|string|iterable|([^ $]++)) )\$/', $key, $m)) {
@@ -263,8 +263,8 @@ private function getBindingValue(BoundArgument $binding): mixed
263263
{
264264
[$bindingValue, $bindingId] = $binding->getValues();
265265

266-
$this->usedBindings[$bindingId] = true;
267-
unset($this->unusedBindings[$bindingId]);
266+
$this->usedBindings[$bindingId ?? ''] = true;
267+
unset($this->unusedBindings[$bindingId ?? '']);
268268

269269
return $bindingValue;
270270
}

src/Symfony/Component/DependencyInjection/Compiler/ResolveHotPathPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ protected function processValue(mixed $value, bool $isRoot = false): mixed
5151
return $value->clearTag('container.hot_path');
5252
}
5353

54-
$this->resolvedIds[$this->currentId] = true;
54+
$this->resolvedIds[$this->currentId ?? ''] = true;
5555

5656
if (!$value->hasTag('container.hot_path')) {
5757
return $value;

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public function registerExtension(ExtensionInterface $extension)
207207
$this->extensions[$extension->getAlias()] = $extension;
208208

209209
if (false !== $extension->getNamespace()) {
210-
$this->extensionsByNs[$extension->getNamespace()] = $extension;
210+
$this->extensionsByNs[$extension->getNamespace() ?? ''] = $extension;
211211
}
212212
}
213213

src/Symfony/Component/Form/Tests/Fixtures/FixedDataTransformer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function __construct(array $mapping)
2525

2626
public function transform($value): mixed
2727
{
28+
$value = $value ?? '';
2829
if (!\array_key_exists($value, $this->mapping)) {
2930
throw new TransformationFailedException(sprintf('No mapping for value "%s"', $value));
3031
}

0 commit comments

Comments
 (0)