Skip to content

Commit

Permalink
[Validator] Removed information from the violation output if the valu…
Browse files Browse the repository at this point in the history
…e is an array, object or resource

This was decided in the discussion of #10687.
  • Loading branch information
webmozart committed Jul 30, 2014
1 parent d6a783f commit 08ea6d3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
6 changes: 3 additions & 3 deletions src/Symfony/Component/Validator/ConstraintValidator.php
Expand Up @@ -67,19 +67,19 @@ protected function formatValue($value, $prettyDateTime = false)
}

if (is_object($value)) {
return 'Object('.get_class($value).')';
return 'object';
}

if (is_array($value)) {
return 'Array';
return 'array';
}

if (is_string($value)) {
return '"'.$value.'"';
}

if (is_resource($value)) {
return sprintf('Resource(%s#%d)', get_resource_type($value), $value);
return 'resource';
}

if (null === $value) {
Expand Down
Expand Up @@ -66,9 +66,9 @@ public function getInvalidValues()
array(true, 'true'),
array('', '""'),
array('foo bar', '"foo bar"'),
array(new \DateTime(), 'Object(DateTime)'),
array(new \stdClass(), 'Object(stdClass)'),
array(array(), 'Array'),
array(new \DateTime(), 'object'),
array(new \stdClass(), 'object'),
array(array(), 'array'),
);
}
}
Expand Up @@ -132,26 +132,25 @@ public function getInvalidValues()
{
$object = new \stdClass();
$file = $this->createFile();
$fileAsString = 'Resource(stream#'.intval($file).')';

return array(
array('foobar', 'numeric', '"foobar"'),
array('foobar', 'boolean', '"foobar"'),
array('0', 'integer', '"0"'),
array('1.5', 'float', '"1.5"'),
array(12345, 'string', '12345'),
array($object, 'boolean', 'Object(stdClass)'),
array($object, 'numeric', 'Object(stdClass)'),
array($object, 'integer', 'Object(stdClass)'),
array($object, 'float', 'Object(stdClass)'),
array($object, 'string', 'Object(stdClass)'),
array($object, 'resource', 'Object(stdClass)'),
array($file, 'boolean', $fileAsString),
array($file, 'numeric', $fileAsString),
array($file, 'integer', $fileAsString),
array($file, 'float', $fileAsString),
array($file, 'string', $fileAsString),
array($file, 'object', $fileAsString),
array($object, 'boolean', 'object'),
array($object, 'numeric', 'object'),
array($object, 'integer', 'object'),
array($object, 'float', 'object'),
array($object, 'string', 'object'),
array($object, 'resource', 'object'),
array($file, 'boolean', 'resource'),
array($file, 'numeric', 'resource'),
array($file, 'integer', 'resource'),
array($file, 'float', 'resource'),
array($file, 'string', 'resource'),
array($file, 'object', 'resource'),
array('12a34', 'digit', '"12a34"'),
array('1a#23', 'alnum', '"1a#23"'),
array('abcd1', 'alpha', '"abcd1"'),
Expand Down

0 comments on commit 08ea6d3

Please sign in to comment.