소스 검색

Merge remote branch 'mvrhov/metadata_defaultgroup_fix'

* mvrhov/metadata_defaultgroup_fix:
  If there is no namespace in classname the 1st character was stripped off
Fabien Potencier 14 년 전
부모
커밋
9c1bdc6ca4
1개의 변경된 파일5개의 추가작업 그리고 1개의 파일을 삭제
  1. 5 1
      src/Symfony/Component/Validator/Mapping/ClassMetadata.php

+ 5 - 1
src/Symfony/Component/Validator/Mapping/ClassMetadata.php

@@ -41,7 +41,11 @@ class ClassMetadata extends ElementMetadata
     {
         $this->name = $class;
         // class name without namespace
-        $this->defaultGroup = substr($class, strrpos($class, '\\') + 1);
+        if (false !== $nsSep = strrpos($class, '\\')) {
+            $this->defaultGroup = substr($class, $nsSep + 1);
+        } else {
+            $this->defaultGroup = $class;
+        }
     }
 
     /**