Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[DependencyInjection] Add nice exception when using non-scalar parame…
…ter as array key
  • Loading branch information
wouterj committed Jul 28, 2022
commit f5a802ab857ee3d450879f9a487a3ca096a5d79c
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,13 @@ public function resolveValue(mixed $value, array $resolving = []): mixed
{
if (\is_array($value)) {
$args = [];
foreach ($value as $k => $v) {
$args[\is_string($k) ? $this->resolveValue($k, $resolving) : $k] = $this->resolveValue($v, $resolving);
foreach ($value as $key => $v) {
$resolvedKey = \is_string($key) ? $this->resolveValue($key, $resolving) : $key;
if (!\is_scalar($resolvedKey) && !$resolvedKey instanceof \Stringable) {
throw new RuntimeException(sprintf('Array keys must be a scalar-value, but found key "%s" to resolve to type "%s".', $key, get_debug_type($resolvedKey)));
}

$args[$resolvedKey] = $this->resolveValue($v, $resolving);
}

return $args;
Expand Down