add parameter type hints to the Validator component

This commit is contained in:
Christian Flothmann 2019-06-28 09:31:01 +02:00
parent 58d61dc997
commit df3a5cbd11
21 changed files with 71 additions and 71 deletions

View File

@ -28,7 +28,7 @@ class DoctrineInitializer implements ObjectInitializerInterface
$this->registry = $registry; $this->registry = $registry;
} }
public function initialize($object) public function initialize(object $object)
{ {
$manager = $this->registry->getManagerForClass(\get_class($object)); $manager = $this->registry->getManagerForClass(\get_class($object));
if (null !== $manager) { if (null !== $manager) {

View File

@ -72,7 +72,7 @@ class ConstraintViolationList implements \IteratorAggregate, ConstraintViolation
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function get($offset) public function get(int $offset)
{ {
if (!isset($this->violations[$offset])) { if (!isset($this->violations[$offset])) {
throw new \OutOfBoundsException(sprintf('The offset "%s" does not exist.', $offset)); throw new \OutOfBoundsException(sprintf('The offset "%s" does not exist.', $offset));
@ -84,7 +84,7 @@ class ConstraintViolationList implements \IteratorAggregate, ConstraintViolation
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function has($offset) public function has(int $offset)
{ {
return isset($this->violations[$offset]); return isset($this->violations[$offset]);
} }
@ -92,7 +92,7 @@ class ConstraintViolationList implements \IteratorAggregate, ConstraintViolation
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function set($offset, ConstraintViolationInterface $violation) public function set(int $offset, ConstraintViolationInterface $violation)
{ {
$this->violations[$offset] = $violation; $this->violations[$offset] = $violation;
} }
@ -100,7 +100,7 @@ class ConstraintViolationList implements \IteratorAggregate, ConstraintViolation
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function remove($offset) public function remove(int $offset)
{ {
unset($this->violations[$offset]); unset($this->violations[$offset]);
} }

View File

@ -37,7 +37,7 @@ interface ConstraintViolationListInterface extends \Traversable, \Countable, \Ar
* *
* @throws \OutOfBoundsException if the offset does not exist * @throws \OutOfBoundsException if the offset does not exist
*/ */
public function get($offset); public function get(int $offset);
/** /**
* Returns whether the given offset exists. * Returns whether the given offset exists.
@ -46,7 +46,7 @@ interface ConstraintViolationListInterface extends \Traversable, \Countable, \Ar
* *
* @return bool Whether the offset exists * @return bool Whether the offset exists
*/ */
public function has($offset); public function has(int $offset);
/** /**
* Sets a violation at a given offset. * Sets a violation at a given offset.
@ -54,12 +54,12 @@ interface ConstraintViolationListInterface extends \Traversable, \Countable, \Ar
* @param int $offset The violation offset * @param int $offset The violation offset
* @param ConstraintViolationInterface $violation The violation * @param ConstraintViolationInterface $violation The violation
*/ */
public function set($offset, ConstraintViolationInterface $violation); public function set(int $offset, ConstraintViolationInterface $violation);
/** /**
* Removes a violation at a given offset. * Removes a violation at a given offset.
* *
* @param int $offset The offset to remove * @param int $offset The offset to remove
*/ */
public function remove($offset); public function remove(int $offset);
} }

View File

@ -143,7 +143,7 @@ class ExecutionContext implements ExecutionContextInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setNode($value, $object, MetadataInterface $metadata = null, $propertyPath) public function setNode($value, ?object $object, MetadataInterface $metadata = null, string $propertyPath)
{ {
$this->value = $value; $this->value = $value;
$this->object = $object; $this->object = $object;
@ -154,7 +154,7 @@ class ExecutionContext implements ExecutionContextInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setGroup($group) public function setGroup(?string $group)
{ {
$this->group = $group; $this->group = $group;
} }
@ -170,7 +170,7 @@ class ExecutionContext implements ExecutionContextInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function addViolation($message, array $parameters = []) public function addViolation(string $message, array $parameters = [])
{ {
$this->violations->add(new ConstraintViolation( $this->violations->add(new ConstraintViolation(
$this->translator->trans($message, $parameters, $this->translationDomain), $this->translator->trans($message, $parameters, $this->translationDomain),
@ -188,7 +188,7 @@ class ExecutionContext implements ExecutionContextInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function buildViolation($message, array $parameters = []) public function buildViolation(string $message, array $parameters = [])
{ {
return new ConstraintViolationBuilder( return new ConstraintViolationBuilder(
$this->violations, $this->violations,
@ -283,7 +283,7 @@ class ExecutionContext implements ExecutionContextInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getPropertyPath($subPath = '') public function getPropertyPath(string $subPath = '')
{ {
return PropertyPath::append($this->propertyPath, $subPath); return PropertyPath::append($this->propertyPath, $subPath);
} }
@ -291,7 +291,7 @@ class ExecutionContext implements ExecutionContextInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function markGroupAsValidated($cacheKey, $groupHash) public function markGroupAsValidated(string $cacheKey, string $groupHash)
{ {
if (!isset($this->validatedObjects[$cacheKey])) { if (!isset($this->validatedObjects[$cacheKey])) {
$this->validatedObjects[$cacheKey] = []; $this->validatedObjects[$cacheKey] = [];
@ -303,7 +303,7 @@ class ExecutionContext implements ExecutionContextInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function isGroupValidated($cacheKey, $groupHash) public function isGroupValidated(string $cacheKey, string $groupHash)
{ {
return isset($this->validatedObjects[$cacheKey][$groupHash]); return isset($this->validatedObjects[$cacheKey][$groupHash]);
} }
@ -311,7 +311,7 @@ class ExecutionContext implements ExecutionContextInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function markConstraintAsValidated($cacheKey, $constraintHash) public function markConstraintAsValidated(string $cacheKey, string $constraintHash)
{ {
$this->validatedConstraints[$cacheKey.':'.$constraintHash] = true; $this->validatedConstraints[$cacheKey.':'.$constraintHash] = true;
} }
@ -319,7 +319,7 @@ class ExecutionContext implements ExecutionContextInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function isConstraintValidated($cacheKey, $constraintHash) public function isConstraintValidated(string $cacheKey, string $constraintHash)
{ {
return isset($this->validatedConstraints[$cacheKey.':'.$constraintHash]); return isset($this->validatedConstraints[$cacheKey.':'.$constraintHash]);
} }
@ -327,7 +327,7 @@ class ExecutionContext implements ExecutionContextInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function markObjectAsInitialized($cacheKey) public function markObjectAsInitialized(string $cacheKey)
{ {
$this->initializedObjects[$cacheKey] = true; $this->initializedObjects[$cacheKey] = true;
} }
@ -335,7 +335,7 @@ class ExecutionContext implements ExecutionContextInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function isObjectInitialized($cacheKey) public function isObjectInitialized(string $cacheKey)
{ {
return isset($this->initializedObjects[$cacheKey]); return isset($this->initializedObjects[$cacheKey]);
} }

View File

@ -67,7 +67,7 @@ interface ExecutionContextInterface
* @param string $message The error message * @param string $message The error message
* @param array $params The parameters substituted in the error message * @param array $params The parameters substituted in the error message
*/ */
public function addViolation($message, array $params = []); public function addViolation(string $message, array $params = []);
/** /**
* Returns a builder for adding a violation with extended information. * Returns a builder for adding a violation with extended information.
@ -86,7 +86,7 @@ interface ExecutionContextInterface
* *
* @return ConstraintViolationBuilderInterface The violation builder * @return ConstraintViolationBuilderInterface The violation builder
*/ */
public function buildViolation($message, array $parameters = []); public function buildViolation(string $message, array $parameters = []);
/** /**
* Returns the validator. * Returns the validator.
@ -133,7 +133,7 @@ interface ExecutionContextInterface
* @internal Used by the validator engine. Should not be called by user * @internal Used by the validator engine. Should not be called by user
* code. * code.
*/ */
public function setNode($value, $object, MetadataInterface $metadata = null, $propertyPath); public function setNode($value, ?object $object, MetadataInterface $metadata = null, string $propertyPath);
/** /**
* Sets the currently validated group. * Sets the currently validated group.
@ -143,7 +143,7 @@ interface ExecutionContextInterface
* @internal Used by the validator engine. Should not be called by user * @internal Used by the validator engine. Should not be called by user
* code. * code.
*/ */
public function setGroup($group); public function setGroup(?string $group);
/** /**
* Sets the currently validated constraint. * Sets the currently validated constraint.
@ -165,7 +165,7 @@ interface ExecutionContextInterface
* @internal Used by the validator engine. Should not be called by user * @internal Used by the validator engine. Should not be called by user
* code. * code.
*/ */
public function markGroupAsValidated($cacheKey, $groupHash); public function markGroupAsValidated(string $cacheKey, string $groupHash);
/** /**
* Returns whether an object was validated in a specific validation group. * Returns whether an object was validated in a specific validation group.
@ -180,7 +180,7 @@ interface ExecutionContextInterface
* @internal Used by the validator engine. Should not be called by user * @internal Used by the validator engine. Should not be called by user
* code. * code.
*/ */
public function isGroupValidated($cacheKey, $groupHash); public function isGroupValidated(string $cacheKey, string $groupHash);
/** /**
* Marks a constraint as validated for an object. * Marks a constraint as validated for an object.
@ -191,7 +191,7 @@ interface ExecutionContextInterface
* @internal Used by the validator engine. Should not be called by user * @internal Used by the validator engine. Should not be called by user
* code. * code.
*/ */
public function markConstraintAsValidated($cacheKey, $constraintHash); public function markConstraintAsValidated(string $cacheKey, string $constraintHash);
/** /**
* Returns whether a constraint was validated for an object. * Returns whether a constraint was validated for an object.
@ -204,7 +204,7 @@ interface ExecutionContextInterface
* @internal Used by the validator engine. Should not be called by user * @internal Used by the validator engine. Should not be called by user
* code. * code.
*/ */
public function isConstraintValidated($cacheKey, $constraintHash); public function isConstraintValidated(string $cacheKey, string $constraintHash);
/** /**
* Marks that an object was initialized. * Marks that an object was initialized.
@ -216,7 +216,7 @@ interface ExecutionContextInterface
* *
* @see ObjectInitializerInterface * @see ObjectInitializerInterface
*/ */
public function markObjectAsInitialized($cacheKey); public function markObjectAsInitialized(string $cacheKey);
/** /**
* Returns whether an object was initialized. * Returns whether an object was initialized.
@ -230,7 +230,7 @@ interface ExecutionContextInterface
* *
* @see ObjectInitializerInterface * @see ObjectInitializerInterface
*/ */
public function isObjectInitialized($cacheKey); public function isObjectInitialized(string $cacheKey);
/** /**
* Returns the violations generated by the validator so far. * Returns the violations generated by the validator so far.
@ -340,5 +340,5 @@ interface ExecutionContextInterface
* string if the validator is currently validating the * string if the validator is currently validating the
* root value of the validation graph. * root value of the validation graph.
*/ */
public function getPropertyPath($subPath = ''); public function getPropertyPath(string $subPath = '');
} }

View File

@ -25,7 +25,7 @@ interface CacheInterface
* *
* @param string $class * @param string $class
*/ */
public function has($class); public function has(string $class);
/** /**
* Returns the metadata for the given class from the cache. * Returns the metadata for the given class from the cache.
@ -34,7 +34,7 @@ interface CacheInterface
* *
* @return ClassMetadata|false A ClassMetadata instance or false on miss * @return ClassMetadata|false A ClassMetadata instance or false on miss
*/ */
public function read($class); public function read(string $class);
/** /**
* Stores a class metadata in the cache. * Stores a class metadata in the cache.

View File

@ -36,7 +36,7 @@ final class DoctrineCache implements CacheInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function has($class): bool public function has(string $class): bool
{ {
return $this->cache->contains($class); return $this->cache->contains($class);
} }
@ -44,7 +44,7 @@ final class DoctrineCache implements CacheInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function read($class) public function read(string $class)
{ {
return $this->cache->fetch($class); return $this->cache->fetch($class);
} }

View File

@ -31,7 +31,7 @@ class Psr6Cache implements CacheInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function has($class) public function has(string $class)
{ {
return $this->cacheItemPool->hasItem($this->escapeClassName($class)); return $this->cacheItemPool->hasItem($this->escapeClassName($class));
} }
@ -39,7 +39,7 @@ class Psr6Cache implements CacheInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function read($class) public function read(string $class)
{ {
$item = $this->cacheItemPool->getItem($this->escapeClassName($class)); $item = $this->cacheItemPool->getItem($this->escapeClassName($class));

View File

@ -364,7 +364,7 @@ class ClassMetadata extends GenericMetadata implements ClassMetadataInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function hasPropertyMetadata($property) public function hasPropertyMetadata(string $property)
{ {
return \array_key_exists($property, $this->members); return \array_key_exists($property, $this->members);
} }
@ -372,7 +372,7 @@ class ClassMetadata extends GenericMetadata implements ClassMetadataInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getPropertyMetadata($property) public function getPropertyMetadata(string $property)
{ {
if (!isset($this->members[$property])) { if (!isset($this->members[$property])) {
return []; return [];

View File

@ -81,7 +81,7 @@ interface ClassMetadataInterface extends MetadataInterface
* *
* @return bool * @return bool
*/ */
public function hasPropertyMetadata($property); public function hasPropertyMetadata(string $property);
/** /**
* Returns all metadata instances for the given named property. * Returns all metadata instances for the given named property.
@ -94,7 +94,7 @@ interface ClassMetadataInterface extends MetadataInterface
* @return PropertyMetadataInterface[] A list of metadata instances. Empty if * @return PropertyMetadataInterface[] A list of metadata instances. Empty if
* no metadata exists for the property. * no metadata exists for the property.
*/ */
public function getPropertyMetadata($property); public function getPropertyMetadata(string $property);
/** /**
* Returns the name of the backing PHP class. * Returns the name of the backing PHP class.

View File

@ -185,7 +185,7 @@ class GenericMetadata implements MetadataInterface
* *
* Aware of the global group (* group). * Aware of the global group (* group).
*/ */
public function findConstraints($group) public function findConstraints(string $group)
{ {
return isset($this->constraintsByGroup[$group]) return isset($this->constraintsByGroup[$group])
? $this->constraintsByGroup[$group] ? $this->constraintsByGroup[$group]

View File

@ -62,5 +62,5 @@ interface MetadataInterface
* *
* @return Constraint[] A list of constraint instances * @return Constraint[] A list of constraint instances
*/ */
public function findConstraints($group); public function findConstraints(string $group);
} }

View File

@ -27,5 +27,5 @@ interface ObjectInitializerInterface
* *
* @param object $object The object to validate * @param object $object The object to validate
*/ */
public function initialize($object); public function initialize(object $object);
} }

View File

@ -15,7 +15,7 @@ use Symfony\Component\Validator\Mapping\ClassMetadata;
class FakeClassMetadata extends ClassMetadata class FakeClassMetadata extends ClassMetadata
{ {
public function addCustomPropertyMetadata($propertyName, $metadata) public function addCustomPropertyMetadata(string $propertyName, $metadata)
{ {
if (!isset($this->members[$propertyName])) { if (!isset($this->members[$propertyName])) {
$this->members[$propertyName] = []; $this->members[$propertyName] = [];

View File

@ -32,7 +32,7 @@ interface ContextualValidatorInterface
* *
* @return $this * @return $this
*/ */
public function atPath($path); public function atPath(string $path);
/** /**
* Validates a value against a constraint or a list of constraints. * Validates a value against a constraint or a list of constraints.
@ -58,7 +58,7 @@ interface ContextualValidatorInterface
* *
* @return $this * @return $this
*/ */
public function validateProperty($object, $propertyName, $groups = null); public function validateProperty($object, string $propertyName, $groups = null);
/** /**
* Validates a value against the constraints specified for an object's * Validates a value against the constraints specified for an object's
@ -71,7 +71,7 @@ interface ContextualValidatorInterface
* *
* @return $this * @return $this
*/ */
public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = null); public function validatePropertyValue($objectOrClass, string $propertyName, $value, $groups = null);
/** /**
* Returns the violations that have been generated so far in the context * Returns the violations that have been generated so far in the context

View File

@ -71,7 +71,7 @@ class RecursiveContextualValidator implements ContextualValidatorInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function atPath($path) public function atPath(string $path)
{ {
$this->defaultPropertyPath = $this->context->getPropertyPath($path); $this->defaultPropertyPath = $this->context->getPropertyPath($path);
@ -169,7 +169,7 @@ class RecursiveContextualValidator implements ContextualValidatorInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function validateProperty($object, $propertyName, $groups = null) public function validateProperty($object, string $propertyName, $groups = null)
{ {
$classMetadata = $this->metadataFactory->getMetadataFor($object); $classMetadata = $this->metadataFactory->getMetadataFor($object);
@ -213,7 +213,7 @@ class RecursiveContextualValidator implements ContextualValidatorInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = null) public function validatePropertyValue($objectOrClass, string $propertyName, $value, $groups = null)
{ {
$classMetadata = $this->metadataFactory->getMetadataFor($objectOrClass); $classMetadata = $this->metadataFactory->getMetadataFor($objectOrClass);
@ -295,7 +295,7 @@ class RecursiveContextualValidator implements ContextualValidatorInterface
* traversal, the object will be iterated and each nested object will be * traversal, the object will be iterated and each nested object will be
* validated instead. * validated instead.
* *
* @param object $object The object to cascade * @param object|int|float|string $object The object to cascade
* @param string $propertyPath The current property path * @param string $propertyPath The current property path
* @param (string|GroupSequence)[] $groups The validated groups * @param (string|GroupSequence)[] $groups The validated groups
* @param int $traversalStrategy The strategy for traversing the * @param int $traversalStrategy The strategy for traversing the
@ -437,7 +437,7 @@ class RecursiveContextualValidator implements ContextualValidatorInterface
* *
* @see TraversalStrategy * @see TraversalStrategy
*/ */
private function validateClassNode($object, $cacheKey, ClassMetadataInterface $metadata = null, $propertyPath, array $groups, $cascadedGroups, $traversalStrategy, ExecutionContextInterface $context) private function validateClassNode(object $object, $cacheKey, ClassMetadataInterface $metadata = null, $propertyPath, array $groups, $cascadedGroups, $traversalStrategy, ExecutionContextInterface $context)
{ {
$context->setNode($object, $object, $metadata, $propertyPath); $context->setNode($object, $object, $metadata, $propertyPath);
@ -616,7 +616,7 @@ class RecursiveContextualValidator implements ContextualValidatorInterface
* *
* @see TraversalStrategy * @see TraversalStrategy
*/ */
private function validateGenericNode($value, $object, $cacheKey, MetadataInterface $metadata = null, $propertyPath, array $groups, $cascadedGroups, $traversalStrategy, ExecutionContextInterface $context) private function validateGenericNode($value, ?object $object, $cacheKey, MetadataInterface $metadata = null, $propertyPath, array $groups, $cascadedGroups, $traversalStrategy, ExecutionContextInterface $context)
{ {
$context->setNode($value, $object, $metadata, $propertyPath); $context->setNode($value, $object, $metadata, $propertyPath);
@ -724,7 +724,7 @@ class RecursiveContextualValidator implements ContextualValidatorInterface
* the group sequence * the group sequence
* @param ExecutionContextInterface $context The execution context * @param ExecutionContextInterface $context The execution context
*/ */
private function stepThroughGroupSequence($value, $object, $cacheKey, MetadataInterface $metadata = null, $propertyPath, $traversalStrategy, GroupSequence $groupSequence, $cascadedGroup, ExecutionContextInterface $context) private function stepThroughGroupSequence($value, ?object $object, $cacheKey, MetadataInterface $metadata = null, $propertyPath, $traversalStrategy, GroupSequence $groupSequence, $cascadedGroup, ExecutionContextInterface $context)
{ {
$violationCount = \count($context->getViolations()); $violationCount = \count($context->getViolations());
$cascadedGroups = $cascadedGroup ? [$cascadedGroup] : null; $cascadedGroups = $cascadedGroup ? [$cascadedGroup] : null;

View File

@ -104,7 +104,7 @@ class RecursiveValidator implements ValidatorInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function validateProperty($object, $propertyName, $groups = null) public function validateProperty($object, string $propertyName, $groups = null)
{ {
return $this->startContext($object) return $this->startContext($object)
->validateProperty($object, $propertyName, $groups) ->validateProperty($object, $propertyName, $groups)
@ -114,7 +114,7 @@ class RecursiveValidator implements ValidatorInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = null) public function validatePropertyValue($objectOrClass, string $propertyName, $value, $groups = null)
{ {
// If a class name is passed, take $value as root // If a class name is passed, take $value as root
return $this->startContext(\is_object($objectOrClass) ? $objectOrClass : $value) return $this->startContext(\is_object($objectOrClass) ? $objectOrClass : $value)

View File

@ -105,7 +105,7 @@ class TraceableValidator implements ValidatorInterface, ResetInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function validateProperty($object, $propertyName, $groups = null) public function validateProperty($object, string $propertyName, $groups = null)
{ {
return $this->validator->validateProperty($object, $propertyName, $groups); return $this->validator->validateProperty($object, $propertyName, $groups);
} }
@ -113,7 +113,7 @@ class TraceableValidator implements ValidatorInterface, ResetInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = null) public function validatePropertyValue($objectOrClass, string $propertyName, $value, $groups = null)
{ {
return $this->validator->validatePropertyValue($objectOrClass, $propertyName, $value, $groups); return $this->validator->validatePropertyValue($objectOrClass, $propertyName, $value, $groups);
} }

View File

@ -52,7 +52,7 @@ interface ValidatorInterface extends MetadataFactoryInterface
* If the list is empty, validation * If the list is empty, validation
* succeeded * succeeded
*/ */
public function validateProperty($object, $propertyName, $groups = null); public function validateProperty($object, string $propertyName, $groups = null);
/** /**
* Validates a value against the constraints specified for an object's * Validates a value against the constraints specified for an object's
@ -67,7 +67,7 @@ interface ValidatorInterface extends MetadataFactoryInterface
* If the list is empty, validation * If the list is empty, validation
* succeeded * succeeded
*/ */
public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = null); public function validatePropertyValue($objectOrClass, string $propertyName, $value, $groups = null);
/** /**
* Starts a new validation context and returns a validator for that context. * Starts a new validation context and returns a validator for that context.

View File

@ -59,7 +59,7 @@ class ConstraintViolationBuilder implements ConstraintViolationBuilderInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function atPath($path) public function atPath(string $path)
{ {
$this->propertyPath = PropertyPath::append($this->propertyPath, $path); $this->propertyPath = PropertyPath::append($this->propertyPath, $path);
@ -69,7 +69,7 @@ class ConstraintViolationBuilder implements ConstraintViolationBuilderInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setParameter($key, $value) public function setParameter(string $key, string $value)
{ {
$this->parameters[$key] = $value; $this->parameters[$key] = $value;
@ -89,7 +89,7 @@ class ConstraintViolationBuilder implements ConstraintViolationBuilderInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setTranslationDomain($translationDomain) public function setTranslationDomain(string $translationDomain)
{ {
$this->translationDomain = $translationDomain; $this->translationDomain = $translationDomain;
@ -109,7 +109,7 @@ class ConstraintViolationBuilder implements ConstraintViolationBuilderInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setPlural($number) public function setPlural(int $number)
{ {
$this->plural = $number; $this->plural = $number;
@ -119,7 +119,7 @@ class ConstraintViolationBuilder implements ConstraintViolationBuilderInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setCode($code) public function setCode(?string $code)
{ {
$this->code = $code; $this->code = $code;

View File

@ -33,7 +33,7 @@ interface ConstraintViolationBuilderInterface
* *
* @return $this * @return $this
*/ */
public function atPath($path); public function atPath(string $path);
/** /**
* Sets a parameter to be inserted into the violation message. * Sets a parameter to be inserted into the violation message.
@ -43,7 +43,7 @@ interface ConstraintViolationBuilderInterface
* *
* @return $this * @return $this
*/ */
public function setParameter($key, $value); public function setParameter(string $key, string $value);
/** /**
* Sets all parameters to be inserted into the violation message. * Sets all parameters to be inserted into the violation message.
@ -66,7 +66,7 @@ interface ConstraintViolationBuilderInterface
* *
* @see \Symfony\Contracts\Translation\TranslatorInterface * @see \Symfony\Contracts\Translation\TranslatorInterface
*/ */
public function setTranslationDomain($translationDomain); public function setTranslationDomain(string $translationDomain);
/** /**
* Sets the invalid value that caused this violation. * Sets the invalid value that caused this violation.
@ -87,7 +87,7 @@ interface ConstraintViolationBuilderInterface
* *
* @see \Symfony\Contracts\Translation\TranslatorInterface::trans() * @see \Symfony\Contracts\Translation\TranslatorInterface::trans()
*/ */
public function setPlural($number); public function setPlural(int $number);
/** /**
* Sets the violation code. * Sets the violation code.
@ -96,7 +96,7 @@ interface ConstraintViolationBuilderInterface
* *
* @return $this * @return $this
*/ */
public function setCode($code); public function setCode(?string $code);
/** /**
* Sets the cause of the violation. * Sets the cause of the violation.