From 66a2fbc2ed5d7e20f760e13466cdb7f967454cd5 Mon Sep 17 00:00:00 2001 From: "Ralph J. Smit" <59207045+ralphjsmit@users.noreply.github.com> Date: Mon, 12 May 2025 20:03:39 +0200 Subject: [PATCH] PhpStan --- .../support/src/Components/ViewComponent.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/packages/support/src/Components/ViewComponent.php b/packages/support/src/Components/ViewComponent.php index f30d7c5b0f..f51aac9961 100644 --- a/packages/support/src/Components/ViewComponent.php +++ b/packages/support/src/Components/ViewComponent.php @@ -6,6 +6,7 @@ use Closure; use Exception; use Illuminate\Contracts\Support\Htmlable; use Illuminate\Contracts\View\View; +use Illuminate\Support\Arr; use Illuminate\View\ComponentAttributeBag; abstract class ViewComponent extends Component implements Htmlable @@ -21,7 +22,7 @@ abstract class ViewComponent extends Component implements Htmlable protected string | Closure | null $defaultView = null; /** - * @var array + * @var array */ protected array $viewData = []; @@ -65,7 +66,7 @@ abstract class ViewComponent extends Component implements Htmlable } /** - * @param array $data + * @param array $data */ public function viewData(array $data): static { @@ -102,17 +103,15 @@ abstract class ViewComponent extends Component implements Htmlable } /** - * @return array + * @return array */ public function getViewData(): array { - return collect($this->viewData) - ->flatMap(function (mixed $value, string | int $key) { - return is_numeric($key) - ? $this->evaluate($value) - : [$key => $this->evaluate($value)]; - }) - ->all(); + return Arr::mapWithKeys($this->viewData, function (mixed $value, string | int $key) { + return is_numeric($key) + ? $this->evaluate($value) + : [$key => $this->evaluate($value)]; + }); } public function toHtml(): string