X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=vendor%2Fsymfony%2Fvalidator%2FConstraint.php;h=45d4bcf41a4b8a0bae26cc56486a1f413ba2ffa7;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hp=fc5288d13bee7f2ec053720d91ee323db853b5b5;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/vendor/symfony/validator/Constraint.php b/vendor/symfony/validator/Constraint.php index fc5288d13..45d4bcf41 100644 --- a/vendor/symfony/validator/Constraint.php +++ b/vendor/symfony/validator/Constraint.php @@ -33,29 +33,21 @@ abstract class Constraint { /** * The name of the group given to all constraints with no explicit group. - * - * @var string */ const DEFAULT_GROUP = 'Default'; /** * Marks a constraint that can be put onto classes. - * - * @var string */ const CLASS_CONSTRAINT = 'class'; /** * Marks a constraint that can be put onto properties. - * - * @var string */ const PROPERTY_CONSTRAINT = 'property'; /** * Maps error codes to the names of their constants. - * - * @var array */ protected static $errorNames = array(); @@ -78,11 +70,7 @@ abstract class Constraint public static function getErrorName($errorCode) { if (!isset(static::$errorNames[$errorCode])) { - throw new InvalidArgumentException(sprintf( - 'The error code "%s" does not exist for constraint of type "%s".', - $errorCode, - get_called_class() - )); + throw new InvalidArgumentException(sprintf('The error code "%s" does not exist for constraint of type "%s".', $errorCode, \get_called_class())); } return static::$errorNames[$errorCode]; @@ -124,15 +112,15 @@ abstract class Constraint // The "groups" option is added to the object lazily $knownOptions['groups'] = true; - if (is_array($options) && count($options) >= 1 && isset($options['value']) && !property_exists($this, 'value')) { + if (\is_array($options) && \count($options) >= 1 && isset($options['value']) && !property_exists($this, 'value')) { $options[$this->getDefaultOption()] = $options['value']; unset($options['value']); } - if (is_array($options)) { + if (\is_array($options)) { reset($options); } - if (is_array($options) && count($options) > 0 && is_string(key($options))) { + if (\is_array($options) && \count($options) > 0 && \is_string(key($options))) { foreach ($options as $option => $value) { if (array_key_exists($option, $knownOptions)) { $this->$option = $value; @@ -141,13 +129,11 @@ abstract class Constraint $invalidOptions[] = $option; } } - } elseif (null !== $options && !(is_array($options) && count($options) === 0)) { + } elseif (null !== $options && !(\is_array($options) && 0 === \count($options))) { $option = $this->getDefaultOption(); if (null === $option) { - throw new ConstraintDefinitionException( - sprintf('No default option is configured for constraint %s', get_class($this)) - ); + throw new ConstraintDefinitionException(sprintf('No default option is configured for constraint %s', \get_class($this))); } if (array_key_exists($option, $knownOptions)) { @@ -158,18 +144,12 @@ abstract class Constraint } } - if (count($invalidOptions) > 0) { - throw new InvalidOptionsException( - sprintf('The options "%s" do not exist in constraint %s', implode('", "', $invalidOptions), get_class($this)), - $invalidOptions - ); + if (\count($invalidOptions) > 0) { + throw new InvalidOptionsException(sprintf('The options "%s" do not exist in constraint %s', implode('", "', $invalidOptions), \get_class($this)), $invalidOptions); } - if (count($missingOptions) > 0) { - throw new MissingOptionsException( - sprintf('The options "%s" must be set for constraint %s', implode('", "', array_keys($missingOptions)), get_class($this)), - array_keys($missingOptions) - ); + if (\count($missingOptions) > 0) { + throw new MissingOptionsException(sprintf('The options "%s" must be set for constraint %s', implode('", "', array_keys($missingOptions)), \get_class($this)), array_keys($missingOptions)); } } @@ -193,7 +173,7 @@ abstract class Constraint return; } - throw new InvalidOptionsException(sprintf('The option "%s" does not exist in constraint %s', $option, get_class($this)), array($option)); + throw new InvalidOptionsException(sprintf('The option "%s" does not exist in constraint %s', $option, \get_class($this)), array($option)); } /** @@ -209,7 +189,7 @@ abstract class Constraint * * @throws InvalidOptionsException If an invalid option name is given * - * @internal This method should not be used or overwritten in userland code. + * @internal this method should not be used or overwritten in userland code */ public function __get($option) { @@ -219,7 +199,17 @@ abstract class Constraint return $this->groups; } - throw new InvalidOptionsException(sprintf('The option "%s" does not exist in constraint %s', $option, get_class($this)), array($option)); + throw new InvalidOptionsException(sprintf('The option "%s" does not exist in constraint %s', $option, \get_class($this)), array($option)); + } + + /** + * @param string $option The option name + * + * @return bool + */ + public function __isset($option) + { + return 'groups' === $option; } /** @@ -229,7 +219,7 @@ abstract class Constraint */ public function addImplicitGroupName($group) { - if (in_array(self::DEFAULT_GROUP, $this->groups) && !in_array($group, $this->groups)) { + if (\in_array(self::DEFAULT_GROUP, $this->groups) && !\in_array($group, $this->groups)) { $this->groups[] = $group; } } @@ -272,7 +262,7 @@ abstract class Constraint */ public function validatedBy() { - return get_class($this).'Validator'; + return \get_class($this).'Validator'; } /**