Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf5a802a

Browse files
committed
[DependencyInjection] Add nice exception when using non-scalar parameter as array key
1 parentfa7703b commitf5a802a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

‎src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,13 @@ public function resolveValue(mixed $value, array $resolving = []): mixed
163163
{
164164
if (\is_array($value)) {
165165
$args = [];
166-
foreach ($valueas$k =>$v) {
167-
$args[\is_string($k) ?$this->resolveValue($k,$resolving) :$k] =$this->resolveValue($v,$resolving);
166+
foreach ($valueas$key =>$v) {
167+
$resolvedKey =\is_string($key) ?$this->resolveValue($key,$resolving) :$key;
168+
if (!\is_scalar($resolvedKey) && !$resolvedKeyinstanceof \Stringable) {
169+
thrownewRuntimeException(sprintf('Array keys must be a scalar-value, but found key "%s" to resolve to type "%s".',$key,get_debug_type($resolvedKey)));
170+
}
171+
172+
$args[$resolvedKey] =$this->resolveValue($v,$resolving);
168173
}
169174

170175
return$args;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp