Skip to content

Commit 0312392

Browse files
committed
-
1 parent 02de755 commit 0312392

File tree

1 file changed

+58
-50
lines changed

1 file changed

+58
-50
lines changed

src/Symfony/Component/Form/Tests/FormConfigTest.php

Lines changed: 58 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,22 @@
2222
*/
2323
class FormConfigTest extends TestCase
2424
{
25-
public static function provideInvalidFormInputName(): iterable
25+
public static function provideInvalidFormInputName()
2626
{
27-
yield ['isindex'];
28-
29-
yield ['#'];
30-
yield ['a#'];
31-
yield ['a$'];
32-
yield ['a%'];
33-
yield ['a '];
34-
yield ["a\t"];
35-
yield ["a\n"];
36-
// Periods are allowed by the HTML4 spec, but disallowed by us
37-
// because they break the generated property paths
38-
yield ['a.'];
27+
return [
28+
['isindex'],
29+
['#'],
30+
['a#'],
31+
['a$'],
32+
['a%'],
33+
['a '],
34+
["a\t"],
35+
["a\n"],
36+
37+
// Periods are allowed by the HTML4 spec, but disallowed by us
38+
// because they break the generated property paths
39+
['a.'],
40+
];
3941
}
4042

4143
/**
@@ -49,44 +51,50 @@ public function testInvalidFormInputName(string $name)
4951
new FormConfigBuilder($name, null, new EventDispatcher());
5052
}
5153

52-
public static function provideValidFormInputName(): iterable
54+
public static function provideValidFormInputName()
5355
{
54-
yield ['z0'];
55-
yield ['A0'];
56-
yield ['A9'];
57-
yield ['Z0'];
58-
yield ['a-'];
59-
yield ['a_'];
60-
yield ['a:'];
61-
// Contrary to the HTML4 spec, we allow names starting with a
62-
// number, otherwise naming fields by collection indices is not
63-
// possible.
64-
// For root forms, leading digits will be stripped from the
65-
// "id" attribute to produce valid HTML4.
66-
yield ['0'];
67-
yield ['9'];
68-
// Contrary to the HTML4 spec, we allow names starting with an
69-
// underscore, since this is already a widely used practice in
70-
// Symfony.
71-
// For root forms, leading underscores will be stripped from the
72-
// "id" attribute to produce valid HTML4.
73-
yield ['_'];
74-
// Integers are allowed
75-
yield [0];
76-
yield [123];
77-
// NULL is allowed
78-
yield [null];
79-
80-
// Allowed in HTML 5 specification
81-
// See: https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-name
82-
yield ['_charset_'];
83-
yield ['-x'];
84-
yield [':x'];
85-
yield ['isINDEX'];
86-
87-
// This value shouldn't be allowed.
88-
// However, many tests in Form component require empty name
89-
yield [''];
56+
return [
57+
['z0'],
58+
['A0'],
59+
['A9'],
60+
['Z0'],
61+
['a-'],
62+
['a_'],
63+
['a:'],
64+
65+
// Contrary to the HTML4 spec, we allow names starting with a
66+
// number, otherwise naming fields by collection indices is not
67+
// possible.
68+
// For root forms, leading digits will be stripped from the
69+
// "id" attribute to produce valid HTML4.
70+
['0'],
71+
['9'],
72+
73+
// Contrary to the HTML4 spec, we allow names starting with an
74+
// underscore, since this is already a widely used practice in
75+
// Symfony.
76+
// For root forms, leading underscores will be stripped from the
77+
// "id" attribute to produce valid HTML4.
78+
['_'],
79+
80+
// Integers are allowed
81+
[0],
82+
[123],
83+
84+
// NULL is allowed
85+
[null],
86+
87+
// Allowed in HTML 5 specification
88+
// See: https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-name
89+
['_charset_'],
90+
['-x'],
91+
[':x'],
92+
['isINDEX'],
93+
94+
// This value shouldn't be allowed.
95+
// However, many tests in Form component require empty name
96+
[''],
97+
];
9098
}
9199

92100
/**

0 commit comments

Comments
 (0)