Skip to content

Commit

Permalink
Merge branch '4.4' into 5.2
Browse files Browse the repository at this point in the history
* 4.4:
  [Form] Fix 'invalid_message' use in multiple ChoiceType
  [Form] fix some type annotations
  • Loading branch information
nicolas-grekas committed Jul 19, 2021
2 parents 24ec4e0 + a239f68 commit 5514f15
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 79 deletions.
4 changes: 2 additions & 2 deletions src/Symfony/Component/Form/Button.php
Expand Up @@ -365,8 +365,8 @@ public function handleRequest($request = null)
/**
* Submits data to the button.
*
* @param string|null $submittedData Not used
* @param bool $clearMissing Not used
* @param array|string|null $submittedData Not used
* @param bool $clearMissing Not used
*
* @return $this
*
Expand Down
48 changes: 0 additions & 48 deletions src/Symfony/Component/Form/ButtonBuilder.php
Expand Up @@ -67,8 +67,6 @@ public function __construct(?string $name, array $options = [])
/**
* Unsupported method.
*
* This method should not be invoked.
*
* @throws BadMethodCallException
*/
public function add($child, string $type = null, array $options = [])
Expand All @@ -79,8 +77,6 @@ public function add($child, string $type = null, array $options = [])
/**
* Unsupported method.
*
* This method should not be invoked.
*
* @throws BadMethodCallException
*/
public function create(string $name, string $type = null, array $options = [])
Expand All @@ -91,8 +87,6 @@ public function create(string $name, string $type = null, array $options = [])
/**
* Unsupported method.
*
* This method should not be invoked.
*
* @throws BadMethodCallException
*/
public function get(string $name)
Expand All @@ -103,8 +97,6 @@ public function get(string $name)
/**
* Unsupported method.
*
* This method should not be invoked.
*
* @throws BadMethodCallException
*/
public function remove(string $name)
Expand Down Expand Up @@ -145,8 +137,6 @@ public function getForm()
/**
* Unsupported method.
*
* This method should not be invoked.
*
* @throws BadMethodCallException
*/
public function addEventListener(string $eventName, callable $listener, int $priority = 0)
Expand All @@ -157,8 +147,6 @@ public function addEventListener(string $eventName, callable $listener, int $pri
/**
* Unsupported method.
*
* This method should not be invoked.
*
* @throws BadMethodCallException
*/
public function addEventSubscriber(EventSubscriberInterface $subscriber)
Expand All @@ -169,8 +157,6 @@ public function addEventSubscriber(EventSubscriberInterface $subscriber)
/**
* Unsupported method.
*
* This method should not be invoked.
*
* @throws BadMethodCallException
*/
public function addViewTransformer(DataTransformerInterface $viewTransformer, bool $forcePrepend = false)
Expand All @@ -181,8 +167,6 @@ public function addViewTransformer(DataTransformerInterface $viewTransformer, bo
/**
* Unsupported method.
*
* This method should not be invoked.
*
* @throws BadMethodCallException
*/
public function resetViewTransformers()
Expand All @@ -193,8 +177,6 @@ public function resetViewTransformers()
/**
* Unsupported method.
*
* This method should not be invoked.
*
* @throws BadMethodCallException
*/
public function addModelTransformer(DataTransformerInterface $modelTransformer, bool $forceAppend = false)
Expand All @@ -205,8 +187,6 @@ public function addModelTransformer(DataTransformerInterface $modelTransformer,
/**
* Unsupported method.
*
* This method should not be invoked.
*
* @throws BadMethodCallException
*/
public function resetModelTransformers()
Expand Down Expand Up @@ -237,8 +217,6 @@ public function setAttributes(array $attributes)
/**
* Unsupported method.
*
* This method should not be invoked.
*
* @throws BadMethodCallException
*/
public function setDataMapper(DataMapperInterface $dataMapper = null)
Expand All @@ -261,10 +239,6 @@ public function setDisabled(bool $disabled)
/**
* Unsupported method.
*
* This method should not be invoked.
*
* @param mixed $emptyData
*
* @throws BadMethodCallException
*/
public function setEmptyData($emptyData)
Expand All @@ -275,8 +249,6 @@ public function setEmptyData($emptyData)
/**
* Unsupported method.
*
* This method should not be invoked.
*
* @throws BadMethodCallException
*/
public function setErrorBubbling(bool $errorBubbling)
Expand All @@ -287,8 +259,6 @@ public function setErrorBubbling(bool $errorBubbling)
/**
* Unsupported method.
*
* This method should not be invoked.
*
* @throws BadMethodCallException
*/
public function setRequired(bool $required)
Expand All @@ -299,10 +269,6 @@ public function setRequired(bool $required)
/**
* Unsupported method.
*
* This method should not be invoked.
*
* @param null $propertyPath
*
* @throws BadMethodCallException
*/
public function setPropertyPath($propertyPath)
Expand All @@ -313,8 +279,6 @@ public function setPropertyPath($propertyPath)
/**
* Unsupported method.
*
* This method should not be invoked.
*
* @throws BadMethodCallException
*/
public function setMapped(bool $mapped)
Expand All @@ -325,8 +289,6 @@ public function setMapped(bool $mapped)
/**
* Unsupported method.
*
* This method should not be invoked.
*
* @throws BadMethodCallException
*/
public function setByReference(bool $byReference)
Expand All @@ -337,8 +299,6 @@ public function setByReference(bool $byReference)
/**
* Unsupported method.
*
* This method should not be invoked.
*
* @throws BadMethodCallException
*/
public function setCompound(bool $compound)
Expand All @@ -361,10 +321,6 @@ public function setType(ResolvedFormTypeInterface $type)
/**
* Unsupported method.
*
* This method should not be invoked.
*
* @param mixed $data
*
* @throws BadMethodCallException
*/
public function setData($data)
Expand All @@ -375,8 +331,6 @@ public function setData($data)
/**
* Unsupported method.
*
* This method should not be invoked.
*
* @throws BadMethodCallException
*/
public function setDataLocked(bool $locked)
Expand All @@ -387,8 +341,6 @@ public function setDataLocked(bool $locked)
/**
* Unsupported method.
*
* This method should not be invoked.
*
* @throws BadMethodCallException
*/
public function setFormFactory(FormFactoryInterface $formFactory)
Expand Down
Expand Up @@ -18,6 +18,7 @@
use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
use Symfony\Component\PropertyAccess\PropertyPath;
use Symfony\Component\PropertyAccess\PropertyPathInterface;

/**
* Adds property path support to a choice list factory.
Expand Down Expand Up @@ -59,12 +60,10 @@ public function getDecoratedFactory()
/**
* {@inheritdoc}
*
* @param callable|string|PropertyPath|null $value The callable or path for
* generating the choice values
* @param callable|string|PropertyPath|null $filter The callable or path for
* filtering the choices
* @param mixed $value
* @param mixed $filter
*
* @return ChoiceListInterface The choice list
* @return ChoiceListInterface
*/
public function createListFromChoices(iterable $choices, $value = null/*, $filter = null*/)
{
Expand All @@ -74,7 +73,7 @@ public function createListFromChoices(iterable $choices, $value = null/*, $filte
$value = new PropertyPath($value);
}

if ($value instanceof PropertyPath) {
if ($value instanceof PropertyPathInterface) {
$accessor = $this->propertyAccessor;
$value = function ($choice) use ($accessor, $value) {
// The callable may be invoked with a non-object/array value
Expand Down Expand Up @@ -102,12 +101,10 @@ public function createListFromChoices(iterable $choices, $value = null/*, $filte
/**
* {@inheritdoc}
*
* @param callable|string|PropertyPath|null $value The callable or path for
* generating the choice values
* @param callable|string|PropertyPath|null $filter The callable or path for
* filtering the choices
* @param mixed $value
* @param mixed $filter
*
* @return ChoiceListInterface The choice list
* @return ChoiceListInterface
*/
public function createListFromLoader(ChoiceLoaderInterface $loader, $value = null/*, $filter = null*/)
{
Expand All @@ -117,7 +114,7 @@ public function createListFromLoader(ChoiceLoaderInterface $loader, $value = nul
$value = new PropertyPath($value);
}

if ($value instanceof PropertyPath) {
if ($value instanceof PropertyPathInterface) {
$accessor = $this->propertyAccessor;
$value = function ($choice) use ($accessor, $value) {
// The callable may be invoked with a non-object/array value
Expand Down Expand Up @@ -145,13 +142,13 @@ public function createListFromLoader(ChoiceLoaderInterface $loader, $value = nul
/**
* {@inheritdoc}
*
* @param array|callable|string|PropertyPath|null $preferredChoices The preferred choices
* @param callable|string|PropertyPath|null $label The callable or path generating the choice labels
* @param callable|string|PropertyPath|null $index The callable or path generating the view indices
* @param callable|string|PropertyPath|null $groupBy The callable or path generating the group names
* @param array|callable|string|PropertyPath|null $attr The callable or path generating the HTML attributes
* @param mixed $preferredChoices
* @param mixed $label
* @param mixed $index
* @param mixed $groupBy
* @param mixed $attr
*
* @return ChoiceListView The choice list view
* @return ChoiceListView
*/
public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, $index = null, $groupBy = null, $attr = null)
{
Expand All @@ -161,7 +158,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
$label = new PropertyPath($label);
}

if ($label instanceof PropertyPath) {
if ($label instanceof PropertyPathInterface) {
$label = function ($choice) use ($accessor, $label) {
return $accessor->getValue($choice, $label);
};
Expand All @@ -171,7 +168,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
$preferredChoices = new PropertyPath($preferredChoices);
}

if ($preferredChoices instanceof PropertyPath) {
if ($preferredChoices instanceof PropertyPathInterface) {
$preferredChoices = function ($choice) use ($accessor, $preferredChoices) {
try {
return $accessor->getValue($choice, $preferredChoices);
Expand All @@ -186,7 +183,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
$index = new PropertyPath($index);
}

if ($index instanceof PropertyPath) {
if ($index instanceof PropertyPathInterface) {
$index = function ($choice) use ($accessor, $index) {
return $accessor->getValue($choice, $index);
};
Expand All @@ -196,7 +193,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
$groupBy = new PropertyPath($groupBy);
}

if ($groupBy instanceof PropertyPath) {
if ($groupBy instanceof PropertyPathInterface) {
$groupBy = function ($choice) use ($accessor, $groupBy) {
try {
return $accessor->getValue($choice, $groupBy);
Expand All @@ -211,7 +208,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
$attr = new PropertyPath($attr);
}

if ($attr instanceof PropertyPath) {
if ($attr instanceof PropertyPathInterface) {
$attr = function ($choice) use ($accessor, $attr) {
return $accessor->getValue($choice, $attr);
};
Expand Down
Expand Up @@ -261,8 +261,16 @@ private static function resolveValidationGroups($groups, FormInterface $form)

private static function getConstraintsInGroups($constraints, $group)
{
return array_filter($constraints, static function (Constraint $constraint) use ($group) {
return \in_array($group, $constraint->groups, true);
$groups = (array) $group;

return array_filter($constraints, static function (Constraint $constraint) use ($groups) {
foreach ($groups as $group) {
if (\in_array($group, $constraint->groups, true)) {
return true;
}
}

return false;
});
}
}
4 changes: 2 additions & 2 deletions src/Symfony/Component/Form/SubmitButton.php
Expand Up @@ -31,8 +31,8 @@ public function isClicked()
/**
* Submits data to the button.
*
* @param string|null $submittedData The data
* @param bool $clearMissing Not used
* @param array|string|null $submittedData The data
* @param bool $clearMissing Not used
*
* @return $this
*
Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Component/Form/Util/OptionsResolverWrapper.php
Expand Up @@ -67,6 +67,8 @@ public function addAllowedValues(string $option, $allowedValues): self
}

/**
* @param string|array $allowedTypes
*
* @return $this
*/
public function setAllowedTypes(string $option, $allowedTypes): self
Expand All @@ -81,6 +83,8 @@ public function setAllowedTypes(string $option, $allowedTypes): self
}

/**
* @param string|array $allowedTypes
*
* @return $this
*/
public function addAllowedTypes(string $option, $allowedTypes): self
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Validator/Constraints/GroupSequence.php
Expand Up @@ -57,7 +57,7 @@ class GroupSequence
/**
* The groups in the sequence.
*
* @var string[]|string[][]|GroupSequence[]
* @var array<string|string[]|GroupSequence>
*/
public $groups;

Expand All @@ -80,7 +80,7 @@ class GroupSequence
/**
* Creates a new group sequence.
*
* @param string[] $groups The groups in the sequence
* @param array<string|string[]|GroupSequence> $groups The groups in the sequence
*/
public function __construct(array $groups)
{
Expand Down

0 comments on commit 5514f15

Please sign in to comment.