Added the Search API Synonym module to deal specifically with licence and license...
[yaffs-website] / vendor / symfony / validator / ConstraintValidator.php
index 804a9b2a193ec444b63494a52f39ebf7e6506104..35f41889eaee7a4e47ccfc29d7fa8c82bc6a4ec5 100644 (file)
@@ -11,9 +11,7 @@
 
 namespace Symfony\Component\Validator;
 
-use Symfony\Component\Validator\Context\ExecutionContextInterface as ExecutionContextInterface2Dot5;
-use Symfony\Component\Validator\Violation\ConstraintViolationBuilderInterface;
-use Symfony\Component\Validator\Violation\LegacyConstraintViolationBuilder;
+use Symfony\Component\Validator\Context\ExecutionContextInterface;
 
 /**
  * Base class for constraint validators.
@@ -25,20 +23,16 @@ abstract class ConstraintValidator implements ConstraintValidatorInterface
     /**
      * Whether to format {@link \DateTime} objects as RFC-3339 dates
      * ("Y-m-d H:i:s").
-     *
-     * @var int
      */
     const PRETTY_DATE = 1;
 
     /**
      * Whether to cast objects with a "__toString()" method to strings.
-     *
-     * @var int
      */
     const OBJECT_TO_STRING = 2;
 
     /**
-     * @var ExecutionContextInterface2Dot5
+     * @var ExecutionContextInterface
      */
     protected $context;
 
@@ -50,51 +44,6 @@ abstract class ConstraintValidator implements ConstraintValidatorInterface
         $this->context = $context;
     }
 
-    /**
-     * Wrapper for {@link ExecutionContextInterface::buildViolation} that
-     * supports the 2.4 context API.
-     *
-     * @param string $message    The violation message
-     * @param array  $parameters The message parameters
-     *
-     * @return ConstraintViolationBuilderInterface The violation builder
-     *
-     * @deprecated since version 2.5, to be removed in 3.0.
-     */
-    protected function buildViolation($message, array $parameters = array())
-    {
-        @trigger_error('The '.__METHOD__.' is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
-
-        if ($this->context instanceof ExecutionContextInterface2Dot5) {
-            return $this->context->buildViolation($message, $parameters);
-        }
-
-        return new LegacyConstraintViolationBuilder($this->context, $message, $parameters);
-    }
-
-    /**
-     * Wrapper for {@link ExecutionContextInterface::buildViolation} that
-     * supports the 2.4 context API.
-     *
-     * @param ExecutionContextInterface $context    The context to use
-     * @param string                    $message    The violation message
-     * @param array                     $parameters The message parameters
-     *
-     * @return ConstraintViolationBuilderInterface The violation builder
-     *
-     * @deprecated since version 2.5, to be removed in 3.0.
-     */
-    protected function buildViolationInContext(ExecutionContextInterface $context, $message, array $parameters = array())
-    {
-        @trigger_error('The '.__METHOD__.' is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
-
-        if ($context instanceof ExecutionContextInterface2Dot5) {
-            return $context->buildViolation($message, $parameters);
-        }
-
-        return new LegacyConstraintViolationBuilder($context, $message, $parameters);
-    }
-
     /**
      * Returns a string representation of the type of the value.
      *
@@ -109,7 +58,7 @@ abstract class ConstraintValidator implements ConstraintValidatorInterface
      */
     protected function formatTypeOf($value)
     {
-        return is_object($value) ? get_class($value) : gettype($value);
+        return \is_object($value) ? \get_class($value) : \gettype($value);
     }
 
     /**
@@ -136,7 +85,7 @@ abstract class ConstraintValidator implements ConstraintValidatorInterface
      */
     protected function formatValue($value, $format = 0)
     {
-        $isDateTime = $value instanceof \DateTime || $value instanceof \DateTimeInterface;
+        $isDateTime = $value instanceof \DateTimeInterface;
 
         if (($format & self::PRETTY_DATE) && $isDateTime) {
             if (class_exists('IntlDateFormatter')) {
@@ -158,7 +107,7 @@ abstract class ConstraintValidator implements ConstraintValidatorInterface
             return $value->format('Y-m-d H:i:s');
         }
 
-        if (is_object($value)) {
+        if (\is_object($value)) {
             if (($format & self::OBJECT_TO_STRING) && method_exists($value, '__toString')) {
                 return $value->__toString();
             }
@@ -166,15 +115,15 @@ abstract class ConstraintValidator implements ConstraintValidatorInterface
             return 'object';
         }
 
-        if (is_array($value)) {
+        if (\is_array($value)) {
             return 'array';
         }
 
-        if (is_string($value)) {
+        if (\is_string($value)) {
             return '"'.$value.'"';
         }
 
-        if (is_resource($value)) {
+        if (\is_resource($value)) {
             return 'resource';
         }