From e2ac4c3c34a8af54a3a9793ab7007600708d7d13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=2E=20Nagy=20Gerg=C5=91?= Date: Fri, 8 Sep 2023 08:55:28 +0200 Subject: [PATCH 1/4] [10.x] Make ComponentAttributeBag JsonSerializable --- src/Illuminate/View/ComponentAttributeBag.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/View/ComponentAttributeBag.php b/src/Illuminate/View/ComponentAttributeBag.php index 1d0a790b4256..a97945f4bb43 100644 --- a/src/Illuminate/View/ComponentAttributeBag.php +++ b/src/Illuminate/View/ComponentAttributeBag.php @@ -11,9 +11,10 @@ use Illuminate\Support\Traits\Conditionable; use Illuminate\Support\Traits\Macroable; use IteratorAggregate; +use JsonSerializable; use Traversable; -class ComponentAttributeBag implements ArrayAccess, Htmlable, IteratorAggregate +class ComponentAttributeBag implements ArrayAccess, Htmlable, IteratorAggregate, JsonSerializable { use Conditionable, Macroable; @@ -455,6 +456,16 @@ public function getIterator(): Traversable return new ArrayIterator($this->attributes); } + /** + * Convert the object into something JSON serializable. + * + * @return array + */ + public function jsonSerialize() + { + return $this->attributes; + } + /** * Implode the attributes into a single HTML ready string. * From 0df28855194067adfb899ef1fa0b086a94f14f28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=2E=20Nagy=20Gerg=C5=91?= Date: Fri, 8 Sep 2023 10:07:33 +0200 Subject: [PATCH 2/4] Fix return type --- src/Illuminate/View/ComponentAttributeBag.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/View/ComponentAttributeBag.php b/src/Illuminate/View/ComponentAttributeBag.php index a97945f4bb43..1af8b6c2cc1c 100644 --- a/src/Illuminate/View/ComponentAttributeBag.php +++ b/src/Illuminate/View/ComponentAttributeBag.php @@ -459,7 +459,7 @@ public function getIterator(): Traversable /** * Convert the object into something JSON serializable. * - * @return array + * @return mixed */ public function jsonSerialize() { From 399265d1e36e88b9afdf14a749ba3b9a1a6c2624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=2E=20Nagy=20Gerg=C5=91?= Date: Fri, 8 Sep 2023 10:15:05 +0200 Subject: [PATCH 3/4] Explicit mixed return type --- src/Illuminate/View/ComponentAttributeBag.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/View/ComponentAttributeBag.php b/src/Illuminate/View/ComponentAttributeBag.php index 1af8b6c2cc1c..6493d581fcfc 100644 --- a/src/Illuminate/View/ComponentAttributeBag.php +++ b/src/Illuminate/View/ComponentAttributeBag.php @@ -461,7 +461,7 @@ public function getIterator(): Traversable * * @return mixed */ - public function jsonSerialize() + public function jsonSerialize(): mixed { return $this->attributes; } From 64e5d6b72cbd6b6884508eb521939a8d76ec6640 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 8 Sep 2023 07:12:25 -0500 Subject: [PATCH 4/4] Update ComponentAttributeBag.php --- src/Illuminate/View/ComponentAttributeBag.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/View/ComponentAttributeBag.php b/src/Illuminate/View/ComponentAttributeBag.php index 6493d581fcfc..812b9829551a 100644 --- a/src/Illuminate/View/ComponentAttributeBag.php +++ b/src/Illuminate/View/ComponentAttributeBag.php @@ -14,7 +14,7 @@ use JsonSerializable; use Traversable; -class ComponentAttributeBag implements ArrayAccess, Htmlable, IteratorAggregate, JsonSerializable +class ComponentAttributeBag implements ArrayAccess, IteratorAggregate, JsonSerializable, Htmlable { use Conditionable, Macroable; @@ -457,7 +457,7 @@ public function getIterator(): Traversable } /** - * Convert the object into something JSON serializable. + * Convert the object into a JSON serializable form. * * @return mixed */