Mercurial > hg > cmmr2012-drupal-site
diff vendor/symfony/validator/Constraint.php @ 4:a9cd425dd02b
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:11:55 +0000 |
parents | c75dbcec494b |
children | 12f9dff5fda9 |
line wrap: on
line diff
--- a/vendor/symfony/validator/Constraint.php Thu Feb 28 11:14:44 2019 +0000 +++ b/vendor/symfony/validator/Constraint.php Thu Feb 28 13:11:55 2019 +0000 @@ -49,7 +49,7 @@ /** * Maps error codes to the names of their constants. */ - protected static $errorNames = array(); + protected static $errorNames = []; /** * Domain-specific data attached to a constraint. @@ -70,11 +70,7 @@ 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]; @@ -109,22 +105,22 @@ */ public function __construct($options = null) { - $invalidOptions = array(); + $invalidOptions = []; $missingOptions = array_flip((array) $this->getRequiredOptions()); $knownOptions = get_object_vars($this); // 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 ($options && \is_array($options) && \is_string(key($options))) { foreach ($options as $option => $value) { if (array_key_exists($option, $knownOptions)) { $this->$option = $value; @@ -133,13 +129,11 @@ $invalidOptions[] = $option; } } - } elseif (null !== $options && !(is_array($options) && 0 === count($options))) { + } 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)) { @@ -150,18 +144,12 @@ } } - 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)); } } @@ -185,7 +173,7 @@ 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)), [$option]); } /** @@ -206,12 +194,12 @@ public function __get($option) { if ('groups' === $option) { - $this->groups = array(self::DEFAULT_GROUP); + $this->groups = [self::DEFAULT_GROUP]; 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)), [$option]); } /** @@ -231,7 +219,7 @@ */ 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; } } @@ -260,7 +248,7 @@ */ public function getRequiredOptions() { - return array(); + return []; } /** @@ -274,7 +262,7 @@ */ public function validatedBy() { - return get_class($this).'Validator'; + return \get_class($this).'Validator'; } /** @@ -296,9 +284,7 @@ * * @return array The properties to serialize * - * @internal This method may be replaced by an implementation of - * {@link \Serializable} in the future. Please don't use or - * overwrite it. + * @internal */ public function __sleep() {