瀏覽代碼

[Validator] tweaked previous merge

Fabien Potencier 14 年之前
父節點
當前提交
1c36d5a529
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      src/Symfony/Component/Validator/Mapping/Loader/AnnotationLoader.php

+ 2 - 2
src/Symfony/Component/Validator/Mapping/Loader/AnnotationLoader.php

@@ -61,10 +61,10 @@ class AnnotationLoader implements LoaderInterface
             if ($method->getDeclaringClass()->getName() ==  $className) {
                 foreach ($this->reader->getMethodAnnotations($method) as $constraint) {
                     if ($constraint instanceof Constraint) {
-                        if (preg_match( '/^(get|is)(.+)$/', $method->getName(), $matches)) {
+                        if (preg_match('/^(get|is)(.+)$/i', $method->getName(), $matches)) {
                             $metadata->addGetterConstraint(lcfirst($matches[2]), $constraint);
                         } else {
-                            throw new MappingException( sprintf( 'Cannot add constraint to %s::%s', $className, $method->getName() ) );
+                            throw new MappingException(sprintf('The constraint on "%s::%s" cannot be added. Constraints can only be added on methods beginning with "get" or "is".', $className, $method->getName()));
                         }
                     }