[Validator] Removed information from the violation output if the value is an array, object or resource

This was decided in the discussion of #10687.
This commit is contained in:
Bernhard Schussek 2014-07-28 15:51:04 +02:00
parent d6a783f989
commit 08ea6d3621
3 changed files with 18 additions and 19 deletions

View File

@ -67,11 +67,11 @@ abstract class ConstraintValidator implements ConstraintValidatorInterface
} }
if (is_object($value)) { if (is_object($value)) {
return 'Object('.get_class($value).')'; return 'object';
} }
if (is_array($value)) { if (is_array($value)) {
return 'Array'; return 'array';
} }
if (is_string($value)) { if (is_string($value)) {
@ -79,7 +79,7 @@ abstract class ConstraintValidator implements ConstraintValidatorInterface
} }
if (is_resource($value)) { if (is_resource($value)) {
return sprintf('Resource(%s#%d)', get_resource_type($value), $value); return 'resource';
} }
if (null === $value) { if (null === $value) {

View File

@ -66,9 +66,9 @@ class NullValidatorTest extends \PHPUnit_Framework_TestCase
array(true, 'true'), array(true, 'true'),
array('', '""'), array('', '""'),
array('foo bar', '"foo bar"'), array('foo bar', '"foo bar"'),
array(new \DateTime(), 'Object(DateTime)'), array(new \DateTime(), 'object'),
array(new \stdClass(), 'Object(stdClass)'), array(new \stdClass(), 'object'),
array(array(), 'Array'), array(array(), 'array'),
); );
} }
} }

View File

@ -132,7 +132,6 @@ class TypeValidatorTest extends \PHPUnit_Framework_TestCase
{ {
$object = new \stdClass(); $object = new \stdClass();
$file = $this->createFile(); $file = $this->createFile();
$fileAsString = 'Resource(stream#'.intval($file).')';
return array( return array(
array('foobar', 'numeric', '"foobar"'), array('foobar', 'numeric', '"foobar"'),
@ -140,18 +139,18 @@ class TypeValidatorTest extends \PHPUnit_Framework_TestCase
array('0', 'integer', '"0"'), array('0', 'integer', '"0"'),
array('1.5', 'float', '"1.5"'), array('1.5', 'float', '"1.5"'),
array(12345, 'string', '12345'), array(12345, 'string', '12345'),
array($object, 'boolean', 'Object(stdClass)'), array($object, 'boolean', 'object'),
array($object, 'numeric', 'Object(stdClass)'), array($object, 'numeric', 'object'),
array($object, 'integer', 'Object(stdClass)'), array($object, 'integer', 'object'),
array($object, 'float', 'Object(stdClass)'), array($object, 'float', 'object'),
array($object, 'string', 'Object(stdClass)'), array($object, 'string', 'object'),
array($object, 'resource', 'Object(stdClass)'), array($object, 'resource', 'object'),
array($file, 'boolean', $fileAsString), array($file, 'boolean', 'resource'),
array($file, 'numeric', $fileAsString), array($file, 'numeric', 'resource'),
array($file, 'integer', $fileAsString), array($file, 'integer', 'resource'),
array($file, 'float', $fileAsString), array($file, 'float', 'resource'),
array($file, 'string', $fileAsString), array($file, 'string', 'resource'),
array($file, 'object', $fileAsString), array($file, 'object', 'resource'),
array('12a34', 'digit', '"12a34"'), array('12a34', 'digit', '"12a34"'),
array('1a#23', 'alnum', '"1a#23"'), array('1a#23', 'alnum', '"1a#23"'),
array('abcd1', 'alpha', '"abcd1"'), array('abcd1', 'alpha', '"abcd1"'),