From 08ea6d362138ffd593cc9b6951c055b93464ce0e Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Mon, 28 Jul 2014 15:51:04 +0200 Subject: [PATCH] [Validator] Removed information from the violation output if the value is an array, object or resource This was decided in the discussion of #10687. --- .../Validator/ConstraintValidator.php | 6 ++--- .../Tests/Constraints/NullValidatorTest.php | 6 ++--- .../Tests/Constraints/TypeValidatorTest.php | 25 +++++++++---------- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/Symfony/Component/Validator/ConstraintValidator.php b/src/Symfony/Component/Validator/ConstraintValidator.php index bb3378cd93e1..28609a693675 100644 --- a/src/Symfony/Component/Validator/ConstraintValidator.php +++ b/src/Symfony/Component/Validator/ConstraintValidator.php @@ -67,11 +67,11 @@ 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)) { @@ -79,7 +79,7 @@ protected function formatValue($value, $prettyDateTime = false) } if (is_resource($value)) { - return sprintf('Resource(%s#%d)', get_resource_type($value), $value); + return 'resource'; } if (null === $value) { diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NullValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NullValidatorTest.php index cbf8da1f385a..4ca50c1087d5 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NullValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NullValidatorTest.php @@ -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'), ); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php index 57d7f5c4c473..db008ce3cef9 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php @@ -132,7 +132,6 @@ public function getInvalidValues() { $object = new \stdClass(); $file = $this->createFile(); - $fileAsString = 'Resource(stream#'.intval($file).')'; return array( array('foobar', 'numeric', '"foobar"'), @@ -140,18 +139,18 @@ public function getInvalidValues() 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"'),