Skip to content

Commit c8a1d0c

Browse files
Make tests pass
1 parent d3c519d commit c8a1d0c

File tree

6 files changed

+35
-29
lines changed

6 files changed

+35
-29
lines changed

src/Symfony/Component/Form/ChoiceList/Factory/CachingFactoryDecorator.php

+15-15
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ public function getDecoratedFactory()
8282
/**
8383
* {@inheritdoc}
8484
*
85-
* @param callable|Cache\ChoiceValue|null $value The callable or static option for
86-
* generating the choice values
87-
* @param callable|Cache\ChoiceFilter|null $filter The callable or static option for
88-
* filtering the choices
85+
* @param callable|string|Cache\ChoiceValue|null $value The callable or static option for
86+
* generating the choice values
87+
* @param callable|string|Cache\ChoiceFilter|null $filter The callable or static option for
88+
* filtering the choices
8989
*/
90-
public function createListFromChoices(iterable $choices, callable|Cache\ChoiceValue $value = null, callable|Cache\ChoiceFilter $filter = null)
90+
public function createListFromChoices(iterable $choices, callable|string|Cache\ChoiceValue $value = null, callable|string|Cache\ChoiceFilter $filter = null)
9191
{
9292
if ($choices instanceof \Traversable) {
9393
$choices = iterator_to_array($choices);
@@ -125,12 +125,12 @@ public function createListFromChoices(iterable $choices, callable|Cache\ChoiceVa
125125
*
126126
* @param ChoiceLoaderInterface|Cache\ChoiceLoader $loader The loader or static loader to load
127127
* the choices lazily
128-
* @param callable|Cache\ChoiceValue|null $value The callable or static option for
128+
* @param callable|string|Cache\ChoiceValue|null $value The callable or static option for
129129
* generating the choice values
130-
* @param callable|Cache\ChoiceFilter|null $filter The callable or static option for
130+
* @param callable|string|Cache\ChoiceFilter|null $filter The callable or static option for
131131
* filtering the choices
132132
*/
133-
public function createListFromLoader(ChoiceLoaderInterface $loader, callable|Cache\ChoiceValue $value = null, callable|Cache\ChoiceFilter $filter = null)
133+
public function createListFromLoader(ChoiceLoaderInterface|Cache\ChoiceLoader $loader, callable|string|Cache\ChoiceValue $value = null, callable|string|Cache\ChoiceFilter $filter = null)
134134
{
135135
$cache = true;
136136

@@ -168,14 +168,14 @@ public function createListFromLoader(ChoiceLoaderInterface $loader, callable|Cac
168168
/**
169169
* {@inheritdoc}
170170
*
171-
* @param array|callable|Cache\PreferredChoice|null $preferredChoices The preferred choices
172-
* @param callable|false|Cache\ChoiceLabel|null $label The option or static option generating the choice labels
173-
* @param callable|Cache\ChoiceFieldName|null $index The option or static option generating the view indices
174-
* @param callable|Cache\GroupBy|null $groupBy The option or static option generating the group names
175-
* @param array|callable|Cache\ChoiceAttr|null $attr The option or static option generating the HTML attributes
176-
* @param array|callable|Cache\ChoiceTranslationParameters $labelTranslationParameters The parameters used to translate the choice labels
171+
* @param array|callable|string|Cache\PreferredChoice|null $preferredChoices The preferred choices
172+
* @param callable|false|string|Cache\ChoiceLabel|null $label The option or static option generating the choice labels
173+
* @param callable|string|Cache\ChoiceFieldName|null $index The option or static option generating the view indices
174+
* @param callable|string|Cache\GroupBy|null $groupBy The option or static option generating the group names
175+
* @param array|callable|string|Cache\ChoiceAttr|null $attr The option or static option generating the HTML attributes
176+
* @param array|callable|string|Cache\ChoiceTranslationParameters $labelTranslationParameters The parameters used to translate the choice labels
177177
*/
178-
public function createView(ChoiceListInterface $list, array|callable|Cache\PreferredChoice $preferredChoices = null, callable|false|Cache\ChoiceLabel $label = null, callable|Cache\ChoiceFieldName $index = null, callable|Cache\GroupBy $groupBy = null, array|callable|Cache\ChoiceAttr $attr = null, array|callable|Cache\ChoiceTranslationParameters $labelTranslationParameters = [])
178+
public function createView(ChoiceListInterface $list, array|callable|string|Cache\PreferredChoice $preferredChoices = null, callable|false|string|Cache\ChoiceLabel $label = null, callable|string|Cache\ChoiceFieldName $index = null, callable|string|Cache\GroupBy $groupBy = null, array|callable|string|Cache\ChoiceAttr $attr = null, array|callable|string|Cache\ChoiceTranslationParameters $labelTranslationParameters = [])
179179
{
180180
$cache = true;
181181

src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php

+11-3
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,18 @@ private static function resolveValidationGroups(string|GroupSequence|array|calla
259259
return (array) $groups;
260260
}
261261

262-
private static function getConstraintsInGroups(array $constraints, string $group): array
262+
private static function getConstraintsInGroups(array $constraints, string|array $group): array
263263
{
264-
return array_filter($constraints, static function (Constraint $constraint) use ($group) {
265-
return \in_array($group, $constraint->groups, true);
264+
$groups = (array) $group;
265+
266+
return array_filter($constraints, static function (Constraint $constraint) use ($groups) {
267+
foreach ($groups as $group) {
268+
if (\in_array($group, $constraint->groups, true)) {
269+
return true;
270+
}
271+
}
272+
273+
return false;
266274
});
267275
}
268276
}

src/Symfony/Component/Form/Form.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ public function handleRequest(mixed $request = null)
495495
/**
496496
* {@inheritdoc}
497497
*/
498-
public function submit(string|array|null $submittedData, bool $clearMissing = true)
498+
public function submit(mixed $submittedData, bool $clearMissing = true)
499499
{
500500
if ($this->submitted) {
501501
throw new AlreadySubmittedException('A form can only be submitted once.');

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

-6
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,6 @@ public function testNoSetName()
5454
$this->assertFalse(method_exists($this->builder, 'setName'));
5555
}
5656

57-
public function testAddNameNoStringAndNoInteger()
58-
{
59-
$this->expectException(UnexpectedTypeException::class);
60-
$this->builder->add(true);
61-
}
62-
6357
public function testAddWithGuessFluent()
6458
{
6559
$this->builder = new FormBuilder('name', 'stdClass', $this->dispatcher, $this->factory);

src/Symfony/Component/Form/Util/OptionsResolverWrapper.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@ public function addAllowedValues(string $option, mixed $allowedValues): self
6767
}
6868

6969
/**
70+
* @param string|array $allowedTypes
71+
*
7072
* @return $this
7173
*/
72-
public function setAllowedTypes(string $option, string|array $allowedTypes): self
74+
public function setAllowedTypes(string $option, $allowedTypes): self
7375
{
7476
try {
7577
parent::setAllowedTypes($option, $allowedTypes);
@@ -81,9 +83,11 @@ public function setAllowedTypes(string $option, string|array $allowedTypes): sel
8183
}
8284

8385
/**
86+
* @param string|array $allowedTypes
87+
*
8488
* @return $this
8589
*/
86-
public function addAllowedTypes(string $option, string|array $allowedTypes): self
90+
public function addAllowedTypes(string $option, $allowedTypes): self
8791
{
8892
try {
8993
parent::addAllowedTypes($option, $allowedTypes);

src/Symfony/Component/Validator/Constraints/GroupSequence.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class GroupSequence
5757
/**
5858
* The groups in the sequence.
5959
*
60-
* @var string[]|string[][]|GroupSequence[]
60+
* @var array<string|string[]|GroupSequence>
6161
*/
6262
public $groups;
6363

@@ -80,7 +80,7 @@ class GroupSequence
8080
/**
8181
* Creates a new group sequence.
8282
*
83-
* @param string[] $groups The groups in the sequence
83+
* @param array<string|string[]|GroupSequence> $groups The groups in the sequence
8484
*/
8585
public function __construct(array $groups)
8686
{

0 commit comments

Comments
 (0)