Skip to content

Commit 9561b4a

Browse files
committed
CS Fixes: Not double split with one array argument
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.
1 parent b09dfd9 commit 9561b4a

File tree

9 files changed

+82
-105
lines changed

9 files changed

+82
-105
lines changed

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

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

151151
public function testEncodePasswordEmptySaltOutput()
152152
{
153-
$this->passwordEncoderCommandTester->execute(
154-
[
155-
'command' => 'security:encode-password',
156-
'password' => 'p@ssw0rd',
157-
'user-class' => 'Symfony\Component\Security\Core\User\User',
158-
'--empty-salt' => true,
159-
]
160-
);
153+
$this->passwordEncoderCommandTester->execute([
154+
'command' => 'security:encode-password',
155+
'password' => 'p@ssw0rd',
156+
'user-class' => 'Symfony\Component\Security\Core\User\User',
157+
'--empty-salt' => true,
158+
]);
161159

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

src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveNamedArgumentsPassTest.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -180,16 +180,14 @@ public function testVariadics()
180180
$container = new ContainerBuilder();
181181

182182
$definition = $container->register(NamedArgumentsVariadicsDummy::class, NamedArgumentsVariadicsDummy::class);
183-
$definition->setArguments(
184-
[
185-
'$class' => new \stdClass(),
186-
'$variadics' => [
187-
new Reference('foo'),
188-
new Reference('bar'),
189-
new Reference('baz'),
190-
],
191-
]
192-
);
183+
$definition->setArguments([
184+
'$class' => new \stdClass(),
185+
'$variadics' => [
186+
new Reference('foo'),
187+
new Reference('bar'),
188+
new Reference('baz'),
189+
],
190+
]);
193191

194192
$pass = new ResolveNamedArgumentsPass();
195193
$pass->process($container);

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: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,7 @@ protected function setUp()
9595
$this->obj2 = (object) ['label' => 'B', 'index' => 'x', 'value' => 'b', 'preferred' => true, 'group' => 'Group 1', 'attr' => ['attr1' => 'value1']];
9696
$this->obj3 = (object) ['label' => 'C', 'index' => 'y', 'value' => 1, 'preferred' => true, 'group' => 'Group 2', 'attr' => ['attr2' => 'value2']];
9797
$this->obj4 = (object) ['label' => 'D', 'index' => 'z', 'value' => 2, 'preferred' => false, 'group' => 'Group 2', 'attr' => []];
98-
$this->list = new ArrayChoiceList(
99-
['A' => $this->obj1, 'B' => $this->obj2, 'C' => $this->obj3, 'D' => $this->obj4]
100-
);
98+
$this->list = new ArrayChoiceList(['A' => $this->obj1, 'B' => $this->obj2, 'C' => $this->obj3, 'D' => $this->obj4]);
10199
$this->factory = new DefaultChoiceListFactory();
102100
}
103101

@@ -111,9 +109,7 @@ public function testCreateFromChoicesEmpty()
111109

112110
public function testCreateFromChoicesFlat()
113111
{
114-
$list = $this->factory->createListFromChoices(
115-
['A' => $this->obj1, 'B' => $this->obj2, 'C' => $this->obj3, 'D' => $this->obj4]
116-
);
112+
$list = $this->factory->createListFromChoices(['A' => $this->obj1, 'B' => $this->obj2, 'C' => $this->obj3, 'D' => $this->obj4]);
117113

118114
$this->assertObjectListWithGeneratedValues($list);
119115
}
@@ -149,12 +145,10 @@ function ($object) { return $object->value; }
149145

150146
public function testCreateFromChoicesGrouped()
151147
{
152-
$list = $this->factory->createListFromChoices(
153-
[
154-
'Group 1' => ['A' => $this->obj1, 'B' => $this->obj2],
155-
'Group 2' => ['C' => $this->obj3, 'D' => $this->obj4],
156-
]
157-
);
148+
$list = $this->factory->createListFromChoices([
149+
'Group 1' => ['A' => $this->obj1, 'B' => $this->obj2],
150+
'Group 2' => ['C' => $this->obj3, 'D' => $this->obj4],
151+
]);
158152

159153
$this->assertObjectListWithGeneratedValues($list);
160154
}

src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1841,12 +1841,11 @@ public function testCustomChoiceTypeDoesNotInheritChoiceLabels()
18411841
{
18421842
$builder = $this->factory->createBuilder();
18431843
$builder->add('choice', static::TESTED_TYPE, [
1844-
'choices' => [
1845-
'1' => '1',
1846-
'2' => '2',
1847-
],
1848-
]
1849-
);
1844+
'choices' => [
1845+
'1' => '1',
1846+
'2' => '2',
1847+
],
1848+
]);
18501849
$builder->add('subChoice', 'Symfony\Component\Form\Tests\Fixtures\ChoiceSubType');
18511850
$form = $builder->getForm();
18521851

src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,16 @@ protected function tearDown()
3838

3939
public function testOutput()
4040
{
41-
$command = new DebugCommand(
42-
[
43-
'command_bus' => [
44-
DummyCommand::class => [DummyCommandHandler::class],
45-
MultipleBusesMessage::class => [MultipleBusesMessageHandler::class],
46-
],
47-
'query_bus' => [
48-
DummyQuery::class => [DummyQueryHandler::class],
49-
MultipleBusesMessage::class => [MultipleBusesMessageHandler::class],
50-
],
51-
]
52-
);
41+
$command = new DebugCommand([
42+
'command_bus' => [
43+
DummyCommand::class => [DummyCommandHandler::class],
44+
MultipleBusesMessage::class => [MultipleBusesMessageHandler::class],
45+
],
46+
'query_bus' => [
47+
DummyQuery::class => [DummyQueryHandler::class],
48+
MultipleBusesMessage::class => [MultipleBusesMessageHandler::class],
49+
],
50+
]);
5351

5452
$tester = new CommandTester($command);
5553
$tester->execute([], ['decorated' => false]);

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -851,13 +851,11 @@ public function testResolveFailsWithCorrectLevelsButWrongScalar()
851851
$this->resolver->setDefined('foo');
852852
$this->resolver->setAllowedTypes('foo', 'int[][]');
853853

854-
$this->resolver->resolve(
855-
[
856-
'foo' => [
857-
[1.2],
858-
],
859-
]
860-
);
854+
$this->resolver->resolve([
855+
'foo' => [
856+
[1.2],
857+
],
858+
]);
861859
}
862860

863861
/**

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

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,9 @@ public function testNullIsValid()
5454
{
5555
$this->validator->validate(
5656
null,
57-
new Choice(
58-
[
59-
'choices' => ['foo', 'bar'],
60-
]
61-
)
57+
new Choice([
58+
'choices' => ['foo', 'bar'],
59+
])
6260
);
6361

6462
$this->assertNoViolation();
@@ -100,13 +98,11 @@ public function testValidChoiceCallbackFunction()
10098

10199
public function testValidChoiceCallbackClosure()
102100
{
103-
$constraint = new Choice(
104-
[
105-
'callback' => function () {
106-
return ['foo', 'bar'];
107-
},
108-
]
109-
);
101+
$constraint = new Choice([
102+
'callback' => function () {
103+
return ['foo', 'bar'];
104+
},
105+
]);
110106

111107
$this->validator->validate('bar', $constraint);
112108

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,10 @@ public function getInvalidEmails()
168168
*/
169169
public function testInvalidHtml5Emails($email)
170170
{
171-
$constraint = new Email(
172-
[
173-
'message' => 'myMessage',
174-
'mode' => Email::VALIDATION_MODE_HTML5,
175-
]
176-
);
171+
$constraint = new Email([
172+
'message' => 'myMessage',
173+
'mode' => Email::VALIDATION_MODE_HTML5,
174+
]);
177175

178176
$this->validator->validate($email, $constraint);
179177

0 commit comments

Comments
 (0)