Skip to content

Commit 32c448f

Browse files
committed
minor symfony#31064 CS Fixes: Not double split with one array argument (rubenrua)
This PR was merged into the 3.4 branch. Discussion ---------- CS Fixes: Not double split with one array argument | Q | A | ------------- | --- | Branch? | 3.4 (master from symfony#31063) | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | None | License | MIT | Doc PR | None Keep to use the same CS in all the Symfony code base. Use: ```php $resolver->setDefaults([ 'compound' => false ]); ``` Instead of: ```php $resolver->setDefaults( [ 'compound' => false, ] ); ``` Keep the double split when the method has two or more arguments. I miss a PSR with this rule. Commits ------- a56bf55 CS Fixes: Not double split with one array argument
2 parents f7cd81d + a56bf55 commit 32c448f

File tree

6 files changed

+74
-92
lines changed

6 files changed

+74
-92
lines changed

src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,12 @@ public function testEncodePasswordOutput()
126126

127127
public function testEncodePasswordEmptySaltOutput()
128128
{
129-
$this->passwordEncoderCommandTester->execute(
130-
[
131-
'command' => 'security:encode-password',
132-
'password' => 'p@ssw0rd',
133-
'user-class' => 'Symfony\Component\Security\Core\User\User',
134-
'--empty-salt' => true,
135-
]
136-
);
129+
$this->passwordEncoderCommandTester->execute([
130+
'command' => 'security:encode-password',
131+
'password' => 'p@ssw0rd',
132+
'user-class' => 'Symfony\Component\Security\Core\User\User',
133+
'--empty-salt' => true,
134+
]);
137135

138136
$this->assertContains('Password encoding succeeded', $this->passwordEncoderCommandTester->getDisplay());
139137
$this->assertContains(' Encoded password p@ssw0rd', $this->passwordEncoderCommandTester->getDisplay());

src/Symfony/Component/Form/Extension/Core/Type/DateIntervalType.php

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -205,38 +205,36 @@ public function configureOptions(OptionsResolver $resolver)
205205
}));
206206
};
207207

208-
$resolver->setDefaults(
209-
[
210-
'with_years' => true,
211-
'with_months' => true,
212-
'with_days' => true,
213-
'with_weeks' => false,
214-
'with_hours' => false,
215-
'with_minutes' => false,
216-
'with_seconds' => false,
217-
'with_invert' => false,
218-
'years' => range(0, 100),
219-
'months' => range(0, 12),
220-
'weeks' => range(0, 52),
221-
'days' => range(0, 31),
222-
'hours' => range(0, 24),
223-
'minutes' => range(0, 60),
224-
'seconds' => range(0, 60),
225-
'widget' => 'choice',
226-
'input' => 'dateinterval',
227-
'placeholder' => $placeholderDefault,
228-
'by_reference' => true,
229-
'error_bubbling' => false,
230-
// If initialized with a \DateInterval object, FormType initializes
231-
// this option to "\DateInterval". Since the internal, normalized
232-
// representation is not \DateInterval, but an array, we need to unset
233-
// this option.
234-
'data_class' => null,
235-
'compound' => $compound,
236-
'empty_data' => $emptyData,
237-
'labels' => [],
238-
]
239-
);
208+
$resolver->setDefaults([
209+
'with_years' => true,
210+
'with_months' => true,
211+
'with_days' => true,
212+
'with_weeks' => false,
213+
'with_hours' => false,
214+
'with_minutes' => false,
215+
'with_seconds' => false,
216+
'with_invert' => false,
217+
'years' => range(0, 100),
218+
'months' => range(0, 12),
219+
'weeks' => range(0, 52),
220+
'days' => range(0, 31),
221+
'hours' => range(0, 24),
222+
'minutes' => range(0, 60),
223+
'seconds' => range(0, 60),
224+
'widget' => 'choice',
225+
'input' => 'dateinterval',
226+
'placeholder' => $placeholderDefault,
227+
'by_reference' => true,
228+
'error_bubbling' => false,
229+
// If initialized with a \DateInterval object, FormType initializes
230+
// this option to "\DateInterval". Since the internal, normalized
231+
// representation is not \DateInterval, but an array, we need to unset
232+
// this option.
233+
'data_class' => null,
234+
'compound' => $compound,
235+
'empty_data' => $emptyData,
236+
'labels' => [],
237+
]);
240238
$resolver->setNormalizer('placeholder', $placeholderNormalizer);
241239
$resolver->setNormalizer('labels', $labelsNormalizer);
242240

src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,10 @@ function ($object) { return $object->value; }
144144

145145
public function testCreateFromChoicesGrouped()
146146
{
147-
$list = $this->factory->createListFromChoices(
148-
[
149-
'Group 1' => ['A' => $this->obj1, 'B' => $this->obj2],
150-
'Group 2' => ['C' => $this->obj3, 'D' => $this->obj4],
151-
]
152-
);
147+
$list = $this->factory->createListFromChoices([
148+
'Group 1' => ['A' => $this->obj1, 'B' => $this->obj2],
149+
'Group 2' => ['C' => $this->obj3, 'D' => $this->obj4],
150+
]);
153151

154152
$this->assertObjectListWithGeneratedValues($list);
155153
}

src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -531,13 +531,11 @@ public function testResolveFailsWithCorrectLevelsButWrongScalar()
531531
$this->resolver->setDefined('foo');
532532
$this->resolver->setAllowedTypes('foo', 'int[][]');
533533

534-
$this->resolver->resolve(
535-
[
536-
'foo' => [
537-
[1.2],
538-
],
539-
]
540-
);
534+
$this->resolver->resolve([
535+
'foo' => [
536+
[1.2],
537+
],
538+
]);
541539
}
542540

543541
/**
@@ -1598,13 +1596,11 @@ public function testNestedArrays()
15981596
1, 2,
15991597
],
16001598
],
1601-
], $this->resolver->resolve(
1602-
[
1603-
'foo' => [
1604-
[1, 2],
1605-
],
1606-
]
1607-
));
1599+
], $this->resolver->resolve([
1600+
'foo' => [
1601+
[1, 2],
1602+
],
1603+
]));
16081604
}
16091605

16101606
public function testNested2Arrays()
@@ -1644,17 +1640,15 @@ public function testNestedArraysException()
16441640
$this->resolver->setDefined('foo');
16451641
$this->resolver->setAllowedTypes('foo', 'float[][][][]');
16461642

1647-
$this->resolver->resolve(
1648-
[
1649-
'foo' => [
1643+
$this->resolver->resolve([
1644+
'foo' => [
1645+
[
16501646
[
1651-
[
1652-
[1, 2],
1653-
],
1647+
[1, 2],
16541648
],
16551649
],
1656-
]
1657-
);
1650+
],
1651+
]);
16581652
}
16591653

16601654
/**

src/Symfony/Component/Translation/Tests/Dumper/YamlFileDumperTest.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ class YamlFileDumperTest extends TestCase
2020
public function testTreeFormatCatalogue()
2121
{
2222
$catalogue = new MessageCatalogue('en');
23-
$catalogue->add(
24-
[
25-
'foo.bar1' => 'value1',
26-
'foo.bar2' => 'value2',
27-
]);
23+
$catalogue->add([
24+
'foo.bar1' => 'value1',
25+
'foo.bar2' => 'value2',
26+
]);
2827

2928
$dumper = new YamlFileDumper();
3029

@@ -34,11 +33,10 @@ public function testTreeFormatCatalogue()
3433
public function testLinearFormatCatalogue()
3534
{
3635
$catalogue = new MessageCatalogue('en');
37-
$catalogue->add(
38-
[
39-
'foo.bar1' => 'value1',
40-
'foo.bar2' => 'value2',
41-
]);
36+
$catalogue->add([
37+
'foo.bar1' => 'value1',
38+
'foo.bar2' => 'value2',
39+
]);
4240

4341
$dumper = new YamlFileDumper();
4442

src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,10 @@ public function testNullIsValid()
5555
{
5656
$this->validator->validate(
5757
null,
58-
new Choice(
59-
[
60-
'choices' => ['foo', 'bar'],
61-
'strict' => true,
62-
]
63-
)
58+
new Choice([
59+
'choices' => ['foo', 'bar'],
60+
'strict' => true,
61+
])
6462
);
6563

6664
$this->assertNoViolation();
@@ -102,14 +100,12 @@ public function testValidChoiceCallbackFunction()
102100

103101
public function testValidChoiceCallbackClosure()
104102
{
105-
$constraint = new Choice(
106-
[
107-
'strict' => true,
108-
'callback' => function () {
109-
return ['foo', 'bar'];
110-
},
111-
]
112-
);
103+
$constraint = new Choice([
104+
'strict' => true,
105+
'callback' => function () {
106+
return ['foo', 'bar'];
107+
},
108+
]);
113109

114110
$this->validator->validate('bar', $constraint);
115111

0 commit comments

Comments
 (0)