From b90a139faeafeb6d5a85ef8222c07e5b704db3b0 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 8 Mar 2024 14:32:02 -0600 Subject: [PATCH] use loop --- .../View/Compilers/ComponentTagCompiler.php | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/Illuminate/View/Compilers/ComponentTagCompiler.php b/src/Illuminate/View/Compilers/ComponentTagCompiler.php index d4babc4e683f..02bd4b7b1003 100644 --- a/src/Illuminate/View/Compilers/ComponentTagCompiler.php +++ b/src/Illuminate/View/Compilers/ComponentTagCompiler.php @@ -792,22 +792,24 @@ protected function attributesToString(array $attributes, $escapeBound = true) */ protected function attributesToStringWithExistingComponentData(array $attributes, $escapeBound = true) { - return collect($attributes) - ->map(function (string $value, string $attribute) use ($escapeBound) { - if ( - (! $escapeBound) || - (! isset($this->boundAttributes[$attribute])) || - ($value === 'true') || - is_numeric($value) - ) { - return "'{$attribute}' => {$value}"; - } + $results = []; - return "'{$attribute}' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(".( - ($attribute === 'attributes') ? $value : ('$componentData[\'data\'][\''.Str::camel($attribute).'\'] ?? null') - ).')'; - }) - ->implode(','); + foreach ($attributes as $attribute => $value) { + if (! $escapeBound || + ! isset($this->boundAttributes[$attribute]) || + $value === 'true' || + is_numeric($value)) { + $results[] = "'{$attribute}' => {$value}"; + + continue; + } + + $results[] = "'{$attribute}' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(".( + ($attribute === 'attributes') ? $value : ('$componentData[\'data\'][\''.Str::camel($attribute).'\'] ?? null') + ).')'; + } + + return implode(',', $results); } /**