Skip to content

Commit 841e07f

Browse files
committed
Simplify if clause and fix assert arguments order
1 parent fc953dd commit 841e07f

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

src/LiveComponent/src/ComponentWithFormTrait.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,7 @@ private function extractFormValues(FormView $formView): array
166166
$values = [];
167167
foreach ($formView->children as $child) {
168168
$name = $child->vars['name'];
169-
if (
170-
(
171-
!\array_key_exists('expanded', $child->vars)
172-
|| !$child->vars['expanded']
173-
)
174-
&& \count($child->children) > 0
175-
) {
169+
if (!($child->vars['expanded'] ?? false) && \count($child->children) > 0) {
176170
$values[$name] = $this->extractFormValues($child);
177171

178172
continue;

src/LiveComponent/tests/Unit/Form/ComponentWithFormTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ public function testFormValues(): void
2323
{
2424
$component = new Component6($this->factory->createBuilder());
2525

26-
$values = $component->getFormValues();
2726
$this->assertSame(
28-
$values,
2927
[
3028
'text' => '',
3129
'textarea' => '',
@@ -35,7 +33,8 @@ public function testFormValues(): void
3533
'checkbox' => null,
3634
'file' => '',
3735
'hidden' => '',
38-
]
36+
],
37+
$component->getFormValues()
3938
);
4039
}
4140
}

0 commit comments

Comments
 (0)