diff --git a/src/Symfony/Component/Validator/Constraints/Composite.php b/src/Symfony/Component/Validator/Constraints/Composite.php index 90c98620f0055..49adb5b8b0d7e 100644 --- a/src/Symfony/Component/Validator/Constraints/Composite.php +++ b/src/Symfony/Component/Validator/Constraints/Composite.php @@ -69,6 +69,10 @@ public function __construct($options = null) foreach ($nestedConstraints as $constraint) { if (!$constraint instanceof Constraint) { + if (is_object($constraint)) { + $constraint = get_class($constraint); + } + throw new ConstraintDefinitionException(sprintf('The value %s is not an instance of Constraint in constraint %s', $constraint, get_class($this))); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CompositeTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CompositeTest.php index eab15ed3bb848..2846040e944bc 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CompositeTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CompositeTest.php @@ -126,6 +126,17 @@ public function testFailIfNoConstraint() )); } + /** + * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException + */ + public function testFailIfNoConstraintObject() + { + new ConcreteComposite(array( + new NotNull(array('groups' => 'Default')), + new \ArrayObject(), + )); + } + /** * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException */
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: