From 60152530646aef7029ddaed0fb338b0454604652 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sat, 17 Dec 2011 12:35:22 +0100 Subject: [PATCH] DDC-1524 - Add validation and error messages for annotation named query code. --- lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php index d469fd66e..bee84159f 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php @@ -192,7 +192,14 @@ class AnnotationDriver implements Driver if (isset($classAnnotations['Doctrine\ORM\Mapping\NamedQueries'])) { $namedQueriesAnnot = $classAnnotations['Doctrine\ORM\Mapping\NamedQueries']; + if (!is_array($namedQueriesAnnot->value)) { + throw new \UnexpectedValueException("@NamedQueries should contain an array of @NamedQuery annotations."); + } + foreach ($namedQueriesAnnot->value as $namedQuery) { + if (!($namedQuery instanceof \Doctrine\ORM\Mapping\NamedQuery)) { + throw new \UnexpectedValueException("@NamedQueries should contain an array of @NamedQuery annotations."); + } $metadata->addNamedQuery(array( 'name' => $namedQuery->name, 'query' => $namedQuery->query