Deprecated: Constant E_STRICT is deprecated in /home/pastorz/old-espace-client/vendor/symfony/error-handler/ErrorHandler.php on line 58

Deprecated: Constant E_STRICT is deprecated in /home/pastorz/old-espace-client/vendor/symfony/error-handler/ErrorHandler.php on line 76
Symfony Profiler

vendor/symfony/validator/Context/ExecutionContextInterface.php line 132

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\Validator\Context;
  11. use Symfony\Component\Validator\Constraint;
  12. use Symfony\Component\Validator\ConstraintViolationListInterface;
  13. use Symfony\Component\Validator\Mapping;
  14. use Symfony\Component\Validator\Mapping\MetadataInterface;
  15. use Symfony\Component\Validator\Validator\ValidatorInterface;
  16. use Symfony\Component\Validator\Violation\ConstraintViolationBuilderInterface;
  17. /**
  18.  * The context of a validation run.
  19.  *
  20.  * The context collects all violations generated during the validation. By
  21.  * default, validators execute all validations in a new context:
  22.  *
  23.  *     $violations = $validator->validate($object);
  24.  *
  25.  * When you make another call to the validator, while the validation is in
  26.  * progress, the violations will be isolated from each other:
  27.  *
  28.  *     public function validate($value, Constraint $constraint)
  29.  *     {
  30.  *         $validator = $this->context->getValidator();
  31.  *
  32.  *         // The violations are not added to $this->context
  33.  *         $violations = $validator->validate($value);
  34.  *     }
  35.  *
  36.  * However, if you want to add the violations to the current context, use the
  37.  * {@link ValidatorInterface::inContext()} method:
  38.  *
  39.  *     public function validate($value, Constraint $constraint)
  40.  *     {
  41.  *         $validator = $this->context->getValidator();
  42.  *
  43.  *         // The violations are added to $this->context
  44.  *         $validator
  45.  *             ->inContext($this->context)
  46.  *             ->validate($value)
  47.  *         ;
  48.  *     }
  49.  *
  50.  * Additionally, the context provides information about the current state of
  51.  * the validator, such as the currently validated class, the name of the
  52.  * currently validated property and more. These values change over time, so you
  53.  * cannot store a context and expect that the methods still return the same
  54.  * results later on.
  55.  *
  56.  * @author Bernhard Schussek <bschussek@gmail.com>
  57.  */
  58. interface ExecutionContextInterface
  59. {
  60.     /**
  61.      * Adds a violation at the current node of the validation graph.
  62.      *
  63.      * @param string|\Stringable $message The error message as a string or a stringable object
  64.      * @param array              $params  The parameters substituted in the error message
  65.      */
  66.     public function addViolation(string $message, array $params = []);
  67.     /**
  68.      * Returns a builder for adding a violation with extended information.
  69.      *
  70.      * Call {@link ConstraintViolationBuilderInterface::addViolation()} to
  71.      * add the violation when you're done with the configuration:
  72.      *
  73.      *     $context->buildViolation('Please enter a number between %min% and %max%.')
  74.      *         ->setParameter('%min%', '3')
  75.      *         ->setParameter('%max%', '10')
  76.      *         ->setTranslationDomain('number_validation')
  77.      *         ->addViolation();
  78.      *
  79.      * @param string|\Stringable $message    The error message as a string or a stringable object
  80.      * @param array              $parameters The parameters substituted in the error message
  81.      *
  82.      * @return ConstraintViolationBuilderInterface
  83.      */
  84.     public function buildViolation(string $message, array $parameters = []);
  85.     /**
  86.      * Returns the validator.
  87.      *
  88.      * Useful if you want to validate additional constraints:
  89.      *
  90.      *     public function validate($value, Constraint $constraint)
  91.      *     {
  92.      *         $validator = $this->context->getValidator();
  93.      *
  94.      *         $violations = $validator->validate($value, new Length(['min' => 3]));
  95.      *
  96.      *         if (count($violations) > 0) {
  97.      *             // ...
  98.      *         }
  99.      *     }
  100.      *
  101.      * @return ValidatorInterface
  102.      */
  103.     public function getValidator();
  104.     /**
  105.      * Returns the currently validated object.
  106.      *
  107.      * If the validator is currently validating a class constraint, the
  108.      * object of that class is returned. If it is validating a property or
  109.      * getter constraint, the object that the property/getter belongs to is
  110.      * returned.
  111.      *
  112.      * In other cases, null is returned.
  113.      *
  114.      * @return object|null
  115.      */
  116.     public function getObject();
  117.     /**
  118.      * Warning: Should not be called by user code, to be used by the validator engine only.
  119.      *
  120.      * @param mixed       $value        The validated value
  121.      * @param object|null $object       The currently validated object
  122.      * @param string      $propertyPath The property path to the current value
  123.      */
  124.     public function setNode($value, ?object $objectMetadataInterface $metadata nullstring $propertyPath);
  125.     /**
  126.      * Warning: Should not be called by user code, to be used by the validator engine only.
  127.      *
  128.      * @param string|null $group The validated group
  129.      */
  130.     public function setGroup(?string $group);
  131.     /**
  132.      * Warning: Should not be called by user code, to be used by the validator engine only.
  133.      */
  134.     public function setConstraint(Constraint $constraint);
  135.     /**
  136.      * Warning: Should not be called by user code, to be used by the validator engine only.
  137.      *
  138.      * @param string $cacheKey  The hash of the object
  139.      * @param string $groupHash The group's name or hash, if it is group
  140.      *                          sequence
  141.      */
  142.     public function markGroupAsValidated(string $cacheKeystring $groupHash);
  143.     /**
  144.      * Warning: Should not be called by user code, to be used by the validator engine only.
  145.      *
  146.      * @param string $cacheKey  The hash of the object
  147.      * @param string $groupHash The group's name or hash, if it is group
  148.      *                          sequence
  149.      *
  150.      * @return bool
  151.      */
  152.     public function isGroupValidated(string $cacheKeystring $groupHash);
  153.     /**
  154.      * Warning: Should not be called by user code, to be used by the validator engine only.
  155.      *
  156.      * @param string $cacheKey       The hash of the object
  157.      * @param string $constraintHash The hash of the constraint
  158.      */
  159.     public function markConstraintAsValidated(string $cacheKeystring $constraintHash);
  160.     /**
  161.      * Warning: Should not be called by user code, to be used by the validator engine only.
  162.      *
  163.      * @param string $cacheKey       The hash of the object
  164.      * @param string $constraintHash The hash of the constraint
  165.      *
  166.      * @return bool
  167.      */
  168.     public function isConstraintValidated(string $cacheKeystring $constraintHash);
  169.     /**
  170.      * Warning: Should not be called by user code, to be used by the validator engine only.
  171.      *
  172.      * @param string $cacheKey The hash of the object
  173.      *
  174.      * @see ObjectInitializerInterface
  175.      */
  176.     public function markObjectAsInitialized(string $cacheKey);
  177.     /**
  178.      * Warning: Should not be called by user code, to be used by the validator engine only.
  179.      *
  180.      * @param string $cacheKey The hash of the object
  181.      *
  182.      * @return bool
  183.      *
  184.      * @see ObjectInitializerInterface
  185.      */
  186.     public function isObjectInitialized(string $cacheKey);
  187.     /**
  188.      * Returns the violations generated by the validator so far.
  189.      *
  190.      * @return ConstraintViolationListInterface
  191.      */
  192.     public function getViolations();
  193.     /**
  194.      * Returns the value at which validation was started in the object graph.
  195.      *
  196.      * The validator, when given an object, traverses the properties and
  197.      * related objects and their properties. The root of the validation is the
  198.      * object from which the traversal started.
  199.      *
  200.      * The current value is returned by {@link getValue}.
  201.      *
  202.      * @return mixed
  203.      */
  204.     public function getRoot();
  205.     /**
  206.      * Returns the value that the validator is currently validating.
  207.      *
  208.      * If you want to retrieve the object that was originally passed to the
  209.      * validator, use {@link getRoot}.
  210.      *
  211.      * @return mixed
  212.      */
  213.     public function getValue();
  214.     /**
  215.      * Returns the metadata for the currently validated value.
  216.      *
  217.      * With the core implementation, this method returns a
  218.      * {@link Mapping\ClassMetadataInterface} instance if the current value is an object,
  219.      * a {@link Mapping\PropertyMetadata} instance if the current value is
  220.      * the value of a property and a {@link Mapping\GetterMetadata} instance if
  221.      * the validated value is the result of a getter method.
  222.      *
  223.      * If the validated value is neither of these, for example if the validator
  224.      * has been called with a plain value and constraint, this method returns
  225.      * null.
  226.      *
  227.      * @return MetadataInterface|null
  228.      */
  229.     public function getMetadata();
  230.     /**
  231.      * Returns the validation group that is currently being validated.
  232.      *
  233.      * @return string|null
  234.      */
  235.     public function getGroup();
  236.     /**
  237.      * Returns the class name of the current node.
  238.      *
  239.      * If the metadata of the current node does not implement
  240.      * {@link Mapping\ClassMetadataInterface} or if no metadata is available for the
  241.      * current node, this method returns null.
  242.      *
  243.      * @return string|null
  244.      */
  245.     public function getClassName();
  246.     /**
  247.      * Returns the property name of the current node.
  248.      *
  249.      * If the metadata of the current node does not implement
  250.      * {@link PropertyMetadataInterface} or if no metadata is available for the
  251.      * current node, this method returns null.
  252.      *
  253.      * @return string|null
  254.      */
  255.     public function getPropertyName();
  256.     /**
  257.      * Returns the property path to the value that the validator is currently
  258.      * validating.
  259.      *
  260.      * For example, take the following object graph:
  261.      *
  262.      * <pre>
  263.      * (Person)---($address: Address)---($street: string)
  264.      * </pre>
  265.      *
  266.      * When the <tt>Person</tt> instance is passed to the validator, the
  267.      * property path is initially empty. When the <tt>$address</tt> property
  268.      * of that person is validated, the property path is "address". When
  269.      * the <tt>$street</tt> property of the related <tt>Address</tt> instance
  270.      * is validated, the property path is "address.street".
  271.      *
  272.      * Properties of objects are prefixed with a dot in the property path.
  273.      * Indices of arrays or objects implementing the {@link \ArrayAccess}
  274.      * interface are enclosed in brackets. For example, if the property in
  275.      * the previous example is <tt>$addresses</tt> and contains an array
  276.      * of <tt>Address</tt> instance, the property path generated for the
  277.      * <tt>$street</tt> property of one of these addresses is for example
  278.      * "addresses[0].street".
  279.      *
  280.      * @param string $subPath Optional. The suffix appended to the current
  281.      *                        property path.
  282.      *
  283.      * @return string The current property path. The result may be an empty
  284.      *                string if the validator is currently validating the
  285.      *                root value of the validation graph.
  286.      */
  287.     public function getPropertyPath(string $subPath '');
  288. }