Changeset 32425
- Timestamp:
- 03/31/11 15:15:08 (2 years ago)
- Files:
-
- branches/2.0/src/Symfony/Component/Validator/Constraint.php (modified) (2 diffs)
- branches/2.0/src/Symfony/Component/Validator/Constraints/CountryValidator.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Constraints/DateTimeValidator.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Constraints/DateValidator.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Constraints/EmailValidator.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Constraints/FileValidator.php (modified) (3 diffs)
- branches/2.0/src/Symfony/Component/Validator/Constraints/IpValidator.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Constraints/LanguageValidator.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Constraints/LocaleValidator.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Constraints/MaxLengthValidator.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Constraints/MinLengthValidator.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Constraints/RegexValidator.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Constraints/TimeValidator.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Constraints/UrlValidator.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Mapping/BlackholeMetadataFactory.php (added)
- branches/2.0/src/Symfony/Component/Validator/Mapping/ClassMetadata.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Mapping/Loader/FileLoader.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php (modified) (6 diffs)
- branches/2.0/src/Symfony/Component/Validator/Mapping/MemberMetadata.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Validator.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/2.0/src/Symfony/Component/Validator/Constraint.php
r32423 r32425 82 82 { 83 83 $invalidOptions = array(); 84 $missingOptions = array_flip((array) $this->getRequiredOptions());84 $missingOptions = array_flip((array) $this->getRequiredOptions()); 85 85 86 86 if (is_array($options) && count($options) == 1 && isset($options['value'])) { … … 128 128 } 129 129 130 $this->groups = (array) $this->groups;130 $this->groups = (array) $this->groups; 131 131 } 132 132 branches/2.0/src/Symfony/Component/Validator/Constraints/CountryValidator.php
r32184 r32425 33 33 } 34 34 35 $value = (string) $value;35 $value = (string) $value; 36 36 37 37 if (!in_array($value, \Symfony\Component\Locale\Locale::getCountries())) { branches/2.0/src/Symfony/Component/Validator/Constraints/DateTimeValidator.php
r32184 r32425 34 34 } 35 35 36 $value = (string) $value;36 $value = (string) $value; 37 37 38 38 if (!preg_match(self::PATTERN, $value, $matches)) { branches/2.0/src/Symfony/Component/Validator/Constraints/DateValidator.php
r32184 r32425 30 30 } 31 31 32 $value = (string) $value;32 $value = (string) $value; 33 33 34 34 if (!preg_match(self::PATTERN, $value, $matches)) { branches/2.0/src/Symfony/Component/Validator/Constraints/EmailValidator.php
r32258 r32425 29 29 } 30 30 31 $value = (string) $value;31 $value = (string) $value; 32 32 33 33 if (!filter_var($value, FILTER_VALIDATE_EMAIL)) { branches/2.0/src/Symfony/Component/Validator/Constraints/FileValidator.php
r32184 r32425 34 34 } 35 35 36 $path = $value instanceof FileObject ? $value->getPath() : (string) $value;36 $path = $value instanceof FileObject ? $value->getPath() : (string) $value; 37 37 38 38 if (!file_exists($path)) { … … 49 49 50 50 if ($constraint->maxSize) { 51 if (ctype_digit((string) $constraint->maxSize)) {51 if (ctype_digit((string) $constraint->maxSize)) { 52 52 $size = filesize($path); 53 53 $limit = $constraint->maxSize; … … 81 81 } 82 82 83 if (!in_array($value->getMimeType(), (array) $constraint->mimeTypes)) {83 if (!in_array($value->getMimeType(), (array) $constraint->mimeTypes)) { 84 84 $this->setMessage($constraint->mimeTypesMessage, array( 85 85 '{{ type }}' => '"'.$value->getMimeType().'"', 86 '{{ types }}' => '"'.implode('", "', (array) $constraint->mimeTypes).'"',86 '{{ types }}' => '"'.implode('", "', (array) $constraint->mimeTypes).'"', 87 87 '{{ file }}' => $path, 88 88 )); branches/2.0/src/Symfony/Component/Validator/Constraints/IpValidator.php
r32184 r32425 36 36 } 37 37 38 $value = (string) $value;38 $value = (string) $value; 39 39 $valid = false; 40 40 branches/2.0/src/Symfony/Component/Validator/Constraints/LanguageValidator.php
r32184 r32425 33 33 } 34 34 35 $value = (string) $value;35 $value = (string) $value; 36 36 37 37 if (!in_array($value, \Symfony\Component\Locale\Locale::getLanguages())) { branches/2.0/src/Symfony/Component/Validator/Constraints/LocaleValidator.php
r32184 r32425 33 33 } 34 34 35 $value = (string) $value;35 $value = (string) $value; 36 36 37 37 if (!in_array($value, \Symfony\Component\Locale\Locale::getLocales())) { branches/2.0/src/Symfony/Component/Validator/Constraints/MaxLengthValidator.php
r32184 r32425 28 28 } 29 29 30 $value = (string) $value;30 $value = (string) $value; 31 31 32 32 $length = function_exists('mb_strlen') ? mb_strlen($value, $constraint->charset) : strlen($value); branches/2.0/src/Symfony/Component/Validator/Constraints/MinLengthValidator.php
r32184 r32425 28 28 } 29 29 30 $value = (string) $value;30 $value = (string) $value; 31 31 32 32 $length = function_exists('mb_strlen') ? mb_strlen($value, $constraint->charset) : strlen($value); branches/2.0/src/Symfony/Component/Validator/Constraints/RegexValidator.php
r32184 r32425 28 28 } 29 29 30 $value = (string) $value;30 $value = (string) $value; 31 31 32 32 if ( branches/2.0/src/Symfony/Component/Validator/Constraints/TimeValidator.php
r32184 r32425 30 30 } 31 31 32 $value = (string) $value;32 $value = (string) $value; 33 33 34 34 if (!preg_match(self::PATTERN, $value)) { branches/2.0/src/Symfony/Component/Validator/Constraints/UrlValidator.php
r32184 r32425 39 39 } 40 40 41 $value = (string) $value;41 $value = (string) $value; 42 42 43 43 $pattern = sprintf(self::PATTERN, implode('|', $constraint->protocols)); branches/2.0/src/Symfony/Component/Validator/Mapping/ClassMetadata.php
r32423 r32425 97 97 public function addConstraint(Constraint $constraint) 98 98 { 99 if (!in_array(Constraint::CLASS_CONSTRAINT, (array) $constraint->getTargets())) {99 if (!in_array(Constraint::CLASS_CONSTRAINT, (array) $constraint->getTargets())) { 100 100 throw new ConstraintDefinitionException(sprintf( 101 101 'The constraint %s cannot be put on classes', branches/2.0/src/Symfony/Component/Validator/Mapping/Loader/FileLoader.php
r32184 r32425 51 51 { 52 52 if (strpos($name, '\\') !== false && class_exists($name)) { 53 $className = (string) $name;53 $className = (string) $name; 54 54 } else if (strpos($name, ':') !== false) { 55 55 list($prefix, $className) = explode(':', $name); branches/2.0/src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php
r32184 r32425 33 33 34 34 foreach ($xml->namespace as $namespace) { 35 $this->namespaces[(string) $namespace['prefix']] = trim((string)$namespace);35 $this->namespaces[(string) $namespace['prefix']] = trim((string) $namespace); 36 36 } 37 37 38 38 foreach ($xml->class as $class) { 39 $this->classes[(string) $class['name']] = $class;39 $this->classes[(string) $class['name']] = $class; 40 40 } 41 41 } … … 50 50 foreach ($xml->property as $property) { 51 51 foreach ($this->parseConstraints($property->constraint) as $constraint) { 52 $metadata->addPropertyConstraint((string) $property['name'], $constraint);52 $metadata->addPropertyConstraint((string) $property['name'], $constraint); 53 53 } 54 54 } … … 56 56 foreach ($xml->getter as $getter) { 57 57 foreach ($this->parseConstraints($getter->constraint) as $constraint) { 58 $metadata->addGetterConstraint((string) $getter['property'], $constraint);58 $metadata->addGetterConstraint((string) $getter['property'], $constraint); 59 59 } 60 60 } … … 88 88 $options = array(); 89 89 } 90 } else if (strlen((string) $node) > 0) {90 } else if (strlen((string) $node) > 0) { 91 91 $options = trim($node); 92 92 } else { … … 125 125 126 126 if (isset($node['key'])) { 127 $values[(string) $node['key']] = $value;127 $values[(string) $node['key']] = $value; 128 128 } else { 129 129 $values[] = $value; … … 158 158 } 159 159 160 $options[(string) $node['name']] = $value;160 $options[(string) $node['name']] = $value; 161 161 } 162 162 branches/2.0/src/Symfony/Component/Validator/Mapping/MemberMetadata.php
r32423 r32425 45 45 public function addConstraint(Constraint $constraint) 46 46 { 47 if (!in_array(Constraint::PROPERTY_CONSTRAINT, (array) $constraint->getTargets())) {47 if (!in_array(Constraint::PROPERTY_CONSTRAINT, (array) $constraint->getTargets())) { 48 48 throw new ConstraintDefinitionException(sprintf( 49 49 'The constraint %s cannot be put on properties or getters', branches/2.0/src/Symfony/Component/Validator/Validator.php
r32184 r32425 96 96 { 97 97 $walker = new GraphWalker($root, $this->metadataFactory, $this->validatorFactory); 98 $groups = $groups ? (array) $groups : array(Constraint::DEFAULT_GROUP);98 $groups = $groups ? (array) $groups : array(Constraint::DEFAULT_GROUP); 99 99 100 100 foreach ($groups as $group) {