From 179a081ee38bd134cf3eea89fa71ca2e785f1e52 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 25 Sep 2018 09:16:06 +0200 Subject: [PATCH] improve docblocks around group sequences --- .../Validator/Constraints/FormValidator.php | 8 +++--- .../GroupSequenceProviderInterface.php | 4 ++- .../Validator/Mapping/ClassMetadata.php | 2 +- .../ContextualValidatorInterface.php | 27 ++++++++----------- .../RecursiveContextualValidator.php | 12 ++++----- .../Validator/ValidatorInterface.php | 27 ++++++++----------- 6 files changed, 36 insertions(+), 44 deletions(-) diff --git a/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php b/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php index 21551f36bb..fc6f2abe51 100644 --- a/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php +++ b/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php @@ -211,7 +211,7 @@ class FormValidator extends ConstraintValidator /** * Returns the validation groups of the given form. * - * @return array The validation groups + * @return string|GroupSequence|(string|GroupSequence)[] The validation groups */ private static function getValidationGroups(FormInterface $form) { @@ -246,10 +246,10 @@ class FormValidator extends ConstraintValidator /** * Post-processes the validation groups option for a given form. * - * @param array|callable $groups The validation groups - * @param FormInterface $form The validated form + * @param string|GroupSequence|(string|GroupSequence)[]|callable $groups The validation groups + * @param FormInterface $form The validated form * - * @return array The validation groups + * @return (string|GroupSequence)[] The validation groups */ private static function resolveValidationGroups($groups, FormInterface $form) { diff --git a/src/Symfony/Component/Validator/GroupSequenceProviderInterface.php b/src/Symfony/Component/Validator/GroupSequenceProviderInterface.php index 62e8a5ed0d..5894397da4 100644 --- a/src/Symfony/Component/Validator/GroupSequenceProviderInterface.php +++ b/src/Symfony/Component/Validator/GroupSequenceProviderInterface.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Validator; +use Symfony\Component\Validator\Constraints\GroupSequence; + /** * Defines the interface for a group sequence provider. */ @@ -20,7 +22,7 @@ interface GroupSequenceProviderInterface * Returns which validation groups should be used for a certain state * of the object. * - * @return array An array of validation groups + * @return string[]|GroupSequence An array of validation groups */ public function getGroupSequence(); } diff --git a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php index 26dba4b725..c3a6544ed4 100644 --- a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php @@ -485,7 +485,7 @@ class ClassMetadata extends ElementMetadata implements ClassMetadataInterface /** * Sets the default group sequence for this class. * - * @param array $groupSequence An array of group names + * @param string[]|GroupSequence $groupSequence An array of group names * * @return $this * diff --git a/src/Symfony/Component/Validator/Validator/ContextualValidatorInterface.php b/src/Symfony/Component/Validator/Validator/ContextualValidatorInterface.php index 1cc96c834e..c8b545b54b 100644 --- a/src/Symfony/Component/Validator/Validator/ContextualValidatorInterface.php +++ b/src/Symfony/Component/Validator/Validator/ContextualValidatorInterface.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Validator\Validator; use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\Constraints\GroupSequence; use Symfony\Component\Validator\ConstraintViolationListInterface; /** @@ -39,12 +40,9 @@ interface ContextualValidatorInterface * If no constraint is passed, the constraint * {@link \Symfony\Component\Validator\Constraints\Valid} is assumed. * - * @param mixed $value The value to validate - * @param Constraint|Constraint[] $constraints The constraint(s) to validate - * against - * @param array|null $groups The validation groups to - * validate. If none is given, - * "Default" is assumed + * @param mixed $value The value to validate + * @param Constraint|Constraint[] $constraints The constraint(s) to validate against + * @param string|GroupSequence|(string|GroupSequence)[]|null $groups The validation groups to validate. If none is given, "Default" is assumed * * @return $this */ @@ -54,10 +52,9 @@ interface ContextualValidatorInterface * Validates a property of an object against the constraints specified * for this property. * - * @param object $object The object - * @param string $propertyName The name of the validated property - * @param array|null $groups The validation groups to validate. If - * none is given, "Default" is assumed + * @param object $object The object + * @param string $propertyName The name of the validated property + * @param string|GroupSequence|(string|GroupSequence)[]|null $groups The validation groups to validate. If none is given, "Default" is assumed * * @return $this */ @@ -67,12 +64,10 @@ interface ContextualValidatorInterface * Validates a value against the constraints specified for an object's * property. * - * @param object|string $objectOrClass The object or its class name - * @param string $propertyName The name of the property - * @param mixed $value The value to validate against the - * property's constraints - * @param array|null $groups The validation groups to validate. If - * none is given, "Default" is assumed + * @param object|string $objectOrClass The object or its class name + * @param string $propertyName The name of the property + * @param mixed $value The value to validate against the property's constraints + * @param string|GroupSequence|(string|GroupSequence)[]|null $groups The validation groups to validate. If none is given, "Default" is assumed * * @return $this */ diff --git a/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php b/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php index 033900d103..14456d8c91 100644 --- a/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php +++ b/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php @@ -275,9 +275,9 @@ class RecursiveContextualValidator implements ContextualValidatorInterface /** * Normalizes the given group or list of groups to an array. * - * @param mixed $groups The groups to normalize + * @param string|GroupSequence|(string|GroupSequence)[] $groups The groups to normalize * - * @return array A group array + * @return (string|GroupSequence)[] A group array */ protected function normalizeGroups($groups) { @@ -298,7 +298,7 @@ class RecursiveContextualValidator implements ContextualValidatorInterface * * @param object $object The object to cascade * @param string $propertyPath The current property path - * @param string[] $groups The validated groups + * @param (string|GroupSequence)[] $groups The validated groups * @param int $traversalStrategy The strategy for traversing the * cascaded object * @param ExecutionContextInterface $context The current execution context @@ -361,7 +361,7 @@ class RecursiveContextualValidator implements ContextualValidatorInterface * * @param iterable $collection The collection * @param string $propertyPath The current property path - * @param string[] $groups The validated groups + * @param (string|GroupSequence)[] $groups The validated groups * @param bool $stopRecursion Whether to disable * recursive iteration. For * backwards compatibility @@ -441,7 +441,7 @@ class RecursiveContextualValidator implements ContextualValidatorInterface * the object * @param string $propertyPath The property path leading * to the object - * @param string[] $groups The groups in which the + * @param (string|GroupSequence)[] $groups The groups in which the * object should be validated * @param string[]|null $cascadedGroups The groups in which * cascaded objects should @@ -630,7 +630,7 @@ class RecursiveContextualValidator implements ContextualValidatorInterface * value * @param string $propertyPath The property path leading * to the value - * @param string[] $groups The groups in which the + * @param (string|GroupSequence)[] $groups The groups in which the * value should be validated * @param string[]|null $cascadedGroups The groups in which * cascaded objects should diff --git a/src/Symfony/Component/Validator/Validator/ValidatorInterface.php b/src/Symfony/Component/Validator/Validator/ValidatorInterface.php index 5bac2e8898..78157465ab 100644 --- a/src/Symfony/Component/Validator/Validator/ValidatorInterface.php +++ b/src/Symfony/Component/Validator/Validator/ValidatorInterface.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Validator\Validator; use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\Constraints\GroupSequence; use Symfony\Component\Validator\ConstraintViolationListInterface; use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface; @@ -29,12 +30,9 @@ interface ValidatorInterface extends MetadataFactoryInterface * If no constraint is passed, the constraint * {@link \Symfony\Component\Validator\Constraints\Valid} is assumed. * - * @param mixed $value The value to validate - * @param Constraint|Constraint[] $constraints The constraint(s) to validate - * against - * @param array|null $groups The validation groups to - * validate. If none is given, - * "Default" is assumed + * @param mixed $value The value to validate + * @param Constraint|Constraint[] $constraints The constraint(s) to validate against + * @param string|GroupSequence|(string|GroupSequence)[]|null $groups The validation groups to validate. If none is given, "Default" is assumed * * @return ConstraintViolationListInterface A list of constraint violations * If the list is empty, validation @@ -46,10 +44,9 @@ interface ValidatorInterface extends MetadataFactoryInterface * Validates a property of an object against the constraints specified * for this property. * - * @param object $object The object - * @param string $propertyName The name of the validated property - * @param array|null $groups The validation groups to validate. If - * none is given, "Default" is assumed + * @param object $object The object + * @param string $propertyName The name of the validated property + * @param string|GroupSequence|(string|GroupSequence)[]|null $groups The validation groups to validate. If none is given, "Default" is assumed * * @return ConstraintViolationListInterface A list of constraint violations * If the list is empty, validation @@ -61,12 +58,10 @@ interface ValidatorInterface extends MetadataFactoryInterface * Validates a value against the constraints specified for an object's * property. * - * @param object|string $objectOrClass The object or its class name - * @param string $propertyName The name of the property - * @param mixed $value The value to validate against the - * property's constraints - * @param array|null $groups The validation groups to validate. If - * none is given, "Default" is assumed + * @param object|string $objectOrClass The object or its class name + * @param string $propertyName The name of the property + * @param mixed $value The value to validate against the property's constraints + * @param string|GroupSequence|(string|GroupSequence)[]|null $groups The validation groups to validate. If none is given, "Default" is assumed * * @return ConstraintViolationListInterface A list of constraint violations * If the list is empty, validation