浏览代码

Merge remote branch 'schmittjoh/annotations'

* schmittjoh/annotations:
  removed obsolete compiler pass
  fixed some more tests
  fixed tests
  removed unused vendor
  some cleanups
  updated to latest changes
  [WebProfilerBundle] removed @ignorePhpDoc annotations
  [FrameworkBundle] fixed default
  [FrameworkBundle] updated configuration
  [Validator] updated fixtures
  updated UPDATE file
  updated Annotations integration
  [Routing] updated to changes
  [FrameworkBundle] added framework-wide annotation reader, updated validator tests
  [WebProfilerBundle] fixed controllers
  fixed unit tests
  added Annotations library
Fabien Potencier 14 年之前
父节点
当前提交
a2a1a88291
共有 36 个文件被更改,包括 352 次插入252 次删除
  1. 78 0
      UPDATE.md
  2. 1 1
      src/Symfony/Bundle/AsseticBundle/Tests/Resources/config/config.yml
  3. 67 0
      src/Symfony/Bundle/DoctrineBundle/Annotations/IndexedReader.php
  4. 0 31
      src/Symfony/Bundle/DoctrineBundle/DependencyInjection/Compiler/AddValidatorNamespaceAliasPass.php
  5. 0 2
      src/Symfony/Bundle/DoctrineBundle/DoctrineBundle.php
  6. 2 5
      src/Symfony/Bundle/DoctrineBundle/Resources/config/orm.xml
  7. 1 1
      src/Symfony/Bundle/DoctrineBundle/Tests/ContainerTest.php
  8. 1 2
      src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php
  9. 6 1
      src/Symfony/Bundle/DoctrineBundle/Tests/TestCase.php
  10. 21 19
      src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
  11. 29 10
      src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
  12. 29 0
      src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml
  13. 12 10
      src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
  14. 1 1
      src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml
  15. 7 0
      src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php
  16. 1 5
      src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_annotations.php
  17. 3 0
      src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml
  18. 1 3
      src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_annotations.xml
  19. 5 0
      src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml
  20. 1 3
      src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_annotations.yml
  21. 16 4
      src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
  22. 0 46
      src/Symfony/Component/Routing/Annotation/Routes.php
  23. 5 18
      src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php
  24. 0 22
      src/Symfony/Component/Validator/Constraints/Set.php
  25. 6 28
      src/Symfony/Component/Validator/Mapping/Loader/AnnotationLoader.php
  26. 3 6
      src/Symfony/Component/Validator/ValidatorFactory.php
  27. 4 0
      tests/Symfony/Tests/Bridge/Doctrine/Fixtures/CompositeIdentEntity.php
  28. 4 0
      tests/Symfony/Tests/Bridge/Doctrine/Fixtures/CompositeStringIdentEntity.php
  29. 4 0
      tests/Symfony/Tests/Bridge/Doctrine/Fixtures/SingleIdentEntity.php
  30. 4 0
      tests/Symfony/Tests/Bridge/Doctrine/Fixtures/SingleStringIdentEntity.php
  31. 7 1
      tests/Symfony/Tests/Bridge/Doctrine/Form/DoctrineOrmTestCase.php
  32. 12 12
      tests/Symfony/Tests/Component/Validator/Fixtures/Entity.php
  33. 3 1
      tests/Symfony/Tests/Component/Validator/Fixtures/EntityParent.php
  34. 7 6
      tests/Symfony/Tests/Component/Validator/Mapping/Loader/AnnotationLoaderTest.php
  35. 10 13
      tests/Symfony/Tests/Component/Validator/ValidatorFactoryTest.php
  36. 1 1
      vendors.sh

+ 78 - 0
UPDATE.md

@@ -9,6 +9,84 @@ timeline closely anyway.
 beta1 to beta2
 --------------
 
+* The annotation parsing process has been changed. All annotations which are used
+  in a class must now be imported (just like you import PHP namespaces with the
+  "use" statement):
+
+  Before:
+
+    /**
+     * @orm:Entity
+     */
+    class MyUser
+    {
+        /**
+         * @orm:Id
+         * @orm:GeneratedValue(strategy = "AUTO")
+         * @orm:Column(type="integer")
+         * @var integer
+         */
+        private $id;
+        
+        /**
+         * @orm:Column(type="string", nullable=false)
+         * @assert:NotBlank
+         * @var string
+         */
+        private $name;
+    }
+
+  After:
+
+    use Doctrine\ORM\Mapping as ORM;
+    use Symfony\Component\Validator\Constraints as Assert;
+
+    /**
+     * @ORM\Entity
+     */
+    class MyUser
+    {
+        /**
+         * @ORM\Id
+         * @ORM\GeneratedValue(strategy="AUTO")
+         * @ORM\Column(type="integer")
+         *
+         * @var integer
+         */
+        private $id;
+
+        /**
+         * @ORM\Column(type="string", nullable=false)
+         * @Assert\NotBlank
+         *
+         * @var string
+         */
+        private $name;
+    }
+
+* The config under "framework.validation.annotations" has been removed and was 
+  replaced with a boolean flag "framework.validation.enable_annotations" which
+  defaults to false.
+
+* The Set constraint has been removed as it is not required anymore.
+
+  Before:
+  
+    /**
+     * @assert:Set({@assert:Callback(...), @assert:Callback(...)})
+     */
+    private $foo;
+
+  After:
+
+    use Symfony\Component\Validator\Constraints\Callback;
+
+    /**
+     * @Callback(...)
+     * @Callback(...)
+     */
+    private  $foo;
+
 * Forms must now be explicitly enabled (automatically done in Symfony SE):
 
         form: ~

+ 1 - 1
src/Symfony/Bundle/AsseticBundle/Tests/Resources/config/config.yml

@@ -4,7 +4,7 @@ framework:
     csrf_protection:
         enabled: true
     router:        { resource: "%kernel.root_dir%/config/routing.yml" }
-    validation:    { enabled: true, annotations: true }
+    validation:    { enabled: true, enable_annotations: true }
     templating:    { engines: ['twig', 'php'] }
     session:
         default_locale: en

+ 67 - 0
src/Symfony/Bundle/DoctrineBundle/Annotations/IndexedReader.php

@@ -0,0 +1,67 @@
+<?php
+
+namespace Symfony\Bundle\DoctrineBundle\Annotations;
+
+use Doctrine\Common\Annotations\Reader;
+
+/**
+ * Allows the reader to be used in-place of Doctrine's reader.
+ *
+ * This can be removed once the BC layer is in place.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+class IndexedReader implements Reader
+{
+    private $delegate;
+
+    public function __construct(Reader $reader)
+    {
+        $this->delegate = $reader;
+    }
+
+    public function getClassAnnotations(\ReflectionClass $class)
+    {
+        $annotations = array();
+        foreach ($this->delegate->getClassAnnotations($class) as $annot) {
+            $annotations[get_class($annot)] = $annot;
+        }
+
+        return $annotations;
+    }
+
+    public function getClassAnnotation(\ReflectionClass $class, $annotation)
+    {
+        return $this->delegate->getClassAnnotation($class, $annotation);
+    }
+
+    public function getMethodAnnotations(\ReflectionMethod $method)
+    {
+        $annotations = array();
+        foreach ($this->delegate->getMethodAnnotations($method) as $annot) {
+            $annotations[get_class($annot)] = $annot;
+        }
+
+        return $annotations;
+    }
+
+    public function getMethodAnnotation(\ReflectionMethod $method, $annotation)
+    {
+        return $this->delegate->getMethodAnnotation($method, $annotation);
+    }
+
+    public function getPropertyAnnotations(\ReflectionProperty $property)
+    {
+        $annotations = array();
+        foreach ($this->delegate->getPropertyAnnotations($property) as $annot) {
+            $annotations[get_class($annot)] = $annot;
+        }
+
+        return $annotations;
+    }
+
+    public function getPropertyAnnotation(\ReflectionProperty $property, $annotation)
+    {
+        return $this->delegate->getPropertyAnnotation($property, $annotation);
+    }
+}

+ 0 - 31
src/Symfony/Bundle/DoctrineBundle/DependencyInjection/Compiler/AddValidatorNamespaceAliasPass.php

@@ -1,31 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Bundle\DoctrineBundle\DependencyInjection\Compiler;
-
-use Symfony\Component\DependencyInjection\ContainerBuilder;
-use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
-
-class AddValidatorNamespaceAliasPass implements CompilerPassInterface
-{
-    public function process(ContainerBuilder $container)
-    {
-        if (!$container->hasDefinition('validator.mapping.loader.annotation_loader')) {
-            return;
-        }
-
-        $loader = $container->getDefinition('validator.mapping.loader.annotation_loader');
-        $args = $container->getParameterBag()->resolveValue($loader->getArguments());
-
-        $args[0]['assertORM'] = 'Symfony\\Bridge\\Doctrine\\Validator\\Constraints\\';
-        $loader->replaceArgument(0, $args[0]);
-    }
-}

+ 0 - 2
src/Symfony/Bundle/DoctrineBundle/DoctrineBundle.php

@@ -13,7 +13,6 @@ namespace Symfony\Bundle\DoctrineBundle;
 
 use Symfony\Component\DependencyInjection\Compiler\PassConfig;
 use Symfony\Bundle\DoctrineBundle\DependencyInjection\Compiler\RegisterEventListenersAndSubscribersPass;
-use Symfony\Bundle\DoctrineBundle\DependencyInjection\Compiler\AddValidatorNamespaceAliasPass;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\HttpKernel\Bundle\Bundle;
 
@@ -30,6 +29,5 @@ class DoctrineBundle extends Bundle
         parent::build($container);
 
         $container->addCompilerPass(new RegisterEventListenersAndSubscribersPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION);
-        $container->addCompilerPass(new AddValidatorNamespaceAliasPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION);
     }
 }

+ 2 - 5
src/Symfony/Bundle/DoctrineBundle/Resources/config/orm.xml

@@ -20,7 +20,7 @@
         <!-- metadata -->
         <parameter key="doctrine.orm.metadata.driver_chain.class">Doctrine\ORM\Mapping\Driver\DriverChain</parameter>
         <parameter key="doctrine.orm.metadata.annotation.class">Doctrine\ORM\Mapping\Driver\AnnotationDriver</parameter>
-        <parameter key="doctrine.orm.metadata.annotation_reader.class">Doctrine\Common\Annotations\AnnotationReader</parameter>
+        <parameter key="doctrine.orm.metadata.annotation_reader.class">Symfony\Bundle\DoctrineBundle\Annotations\IndexedReader</parameter>
         <parameter key="doctrine.orm.metadata.xml.class">Symfony\Bundle\DoctrineBundle\Mapping\Driver\XmlDriver</parameter>
         <parameter key="doctrine.orm.metadata.yml.class">Symfony\Bundle\DoctrineBundle\Mapping\Driver\YamlDriver</parameter>
         <parameter key="doctrine.orm.metadata.php.class">Doctrine\ORM\Mapping\Driver\PHPDriver</parameter>
@@ -39,10 +39,7 @@
     <services>
         <!--- Annotation Metadata Reader Service -->
         <service id="doctrine.orm.metadata.annotation_reader" class="%doctrine.orm.metadata.annotation_reader.class%" public="false">
-            <call method="setAnnotationNamespaceAlias">
-              <argument>Doctrine\ORM\Mapping\</argument>
-              <argument>orm</argument>
-            </call>
+            <argument type="service" id="annotation_reader" />
         </service>
 
         <service id="doctrine.orm.proxy_cache_warmer" class="%doctrine.orm.proxy_cache_warmer.class%" public="false">

+ 1 - 1
src/Symfony/Bundle/DoctrineBundle/Tests/ContainerTest.php

@@ -24,7 +24,7 @@ class ContainerTest extends TestCase
         $this->assertInstanceOf('Doctrine\DBAL\Configuration', $container->get('doctrine.dbal.default_connection.configuration'));
         $this->assertInstanceOf('Doctrine\Common\EventManager', $container->get('doctrine.dbal.default_connection.event_manager'));
         $this->assertInstanceOf('Doctrine\DBAL\Connection', $container->get('doctrine.dbal.default_connection'));
-        $this->assertInstanceOf('Doctrine\Common\Annotations\AnnotationReader', $container->get('doctrine.orm.metadata.annotation_reader'));
+        $this->assertInstanceOf('Doctrine\Common\Annotations\Reader', $container->get('doctrine.orm.metadata.annotation_reader'));
         $this->assertInstanceOf('Doctrine\ORM\Configuration', $container->get('doctrine.orm.default_configuration'));
         $this->assertInstanceOf('Doctrine\ORM\Mapping\Driver\DriverChain', $container->get('doctrine.orm.default_metadata_driver'));
         $this->assertInstanceOf('Doctrine\Common\Cache\ArrayCache', $container->get('doctrine.orm.default_metadata_cache'));

+ 1 - 2
src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php

@@ -35,7 +35,7 @@ abstract class AbstractDoctrineExtensionTest extends TestCase
         // doctrine.dbal.default_connection
         $this->assertEquals('%doctrine.default_connection%', $container->getDefinition('doctrine')->getArgument(3), '->load() overrides existing configuration options');
         $this->assertEquals('foo', $container->getParameter('doctrine.default_connection'), '->load() overrides existing configuration options');
-        
+
     }
 
     public function testDbalLoad()
@@ -121,7 +121,6 @@ abstract class AbstractDoctrineExtensionTest extends TestCase
         $this->assertEquals('Doctrine\Common\Cache\XcacheCache', $container->getParameter('doctrine.orm.cache.xcache.class'));
         $this->assertEquals('Doctrine\ORM\Mapping\Driver\DriverChain', $container->getParameter('doctrine.orm.metadata.driver_chain.class'));
         $this->assertEquals('Doctrine\ORM\Mapping\Driver\AnnotationDriver', $container->getParameter('doctrine.orm.metadata.annotation.class'));
-        $this->assertEquals('Doctrine\Common\Annotations\AnnotationReader', $container->getParameter('doctrine.orm.metadata.annotation_reader.class'));
         $this->assertEquals('Symfony\Bundle\DoctrineBundle\Mapping\Driver\XmlDriver', $container->getParameter('doctrine.orm.metadata.xml.class'));
         $this->assertEquals('Symfony\Bundle\DoctrineBundle\Mapping\Driver\YamlDriver', $container->getParameter('doctrine.orm.metadata.yml.class'));
 

+ 6 - 1
src/Symfony/Bundle/DoctrineBundle/Tests/TestCase.php

@@ -11,6 +11,10 @@
 
 namespace Symfony\Bundle\DoctrineBundle\Tests;
 
+use Symfony\Bundle\DoctrineBundle\Annotations\IndexedReader;
+
+use Doctrine\Common\Annotations\AnnotationReader;
+use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
 use Doctrine\ORM\EntityManager;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
@@ -36,7 +40,7 @@ class TestCase extends \PHPUnit_Framework_TestCase
         $config->setAutoGenerateProxyClasses(true);
         $config->setProxyDir(\sys_get_temp_dir());
         $config->setProxyNamespace('SymfonyTests\Doctrine');
-        $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver($paths));
+        $config->setMetadataDriverImpl(new AnnotationDriver(new IndexedReader(new AnnotationReader()), $paths));
         $config->setQueryCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
         $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
 
@@ -56,6 +60,7 @@ class TestCase extends \PHPUnit_Framework_TestCase
             'kernel.cache_dir'   => sys_get_temp_dir(),
             'kernel.root_dir'    => __DIR__ . "/../../../../" // src dir
         )));
+        $container->set('annotation_reader', new AnnotationReader());
         $loader = new DoctrineExtension();
         $container->registerExtension($loader);
         $loader->load(array(array(

+ 21 - 19
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

@@ -54,6 +54,7 @@ class Configuration implements ConfigurationInterface
         $this->addTemplatingSection($rootNode);
         $this->addTranslatorSection($rootNode);
         $this->addValidationSection($rootNode);
+        $this->addAnnotationsSection($rootNode);
 
         return $treeBuilder;
     }
@@ -255,28 +256,29 @@ class Configuration implements ConfigurationInterface
                     ->canBeUnset()
                     ->treatNullLike(array('enabled' => true))
                     ->treatTrueLike(array('enabled' => true))
-                    // For XML, namespace is a child of validation, so it must be moved under annotations
-                    ->beforeNormalization()
-                        ->ifTrue(function($v) { return is_array($v) && !empty($v['annotations']) && !empty($v['namespace']); })
-                        ->then(function($v){
-                            $v['annotations'] = array('namespace' => $v['namespace']);
-                            unset($v['namespace']);
-                            return $v;
-                        })
-                    ->end()
                     ->children()
-                        ->booleanNode('enabled')->defaultTrue()->end()
+                    ->booleanNode('enabled')->defaultTrue()->end()
                         ->scalarNode('cache')->end()
-                        ->arrayNode('annotations')
-                            ->canBeUnset()
-                            ->treatNullLike(array())
-                            ->treatTrueLike(array())
-                            ->fixXmlConfig('namespace')
+                        ->booleanNode('enable_annotations')->defaultFalse()->end()
+                    ->end()
+                ->end()
+            ->end()
+        ;
+    }
+
+    private function addAnnotationsSection(ArrayNodeDefinition $rootNode)
+    {
+        $rootNode
+            ->children()
+                ->arrayNode('annotations')
+                    ->addDefaultsIfNotSet()
+                    ->children()
+                        ->scalarNode('cache')->defaultValue('file')->end()
+                        ->arrayNode('file_cache')
+                            ->addDefaultsIfNotSet()
                             ->children()
-                                ->arrayNode('namespaces')
-                                    ->useAttributeAsKey('prefix')
-                                    ->prototype('scalar')->end()
-                                ->end()
+                                ->scalarNode('dir')->defaultValue('%kernel.cache_dir%/annotations')->end()
+                                ->booleanNode('debug')->defaultValue($this->debug)->end()
                             ->end()
                         ->end()
                     ->end()

+ 29 - 10
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

@@ -11,6 +11,7 @@
 
 namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;
 
+use Symfony\Component\Config\Loader\LoaderInterface;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\Definition;
 use Symfony\Component\DependencyInjection\Parameter;
@@ -102,6 +103,8 @@ class FrameworkExtension extends Extension
             $this->registerTranslatorConfiguration($config['translator'], $container);
         }
 
+        $this->registerAnnotationsConfiguration($config['annotations'], $container, $loader);
+
         $this->addClassesToCompile(array(
             'Symfony\\Component\\HttpFoundation\\ParameterBag',
             'Symfony\\Component\\HttpFoundation\\HeaderBag',
@@ -461,16 +464,7 @@ class FrameworkExtension extends Extension
         $container->setParameter('validator.mapping.loader.xml_files_loader.mapping_files', $this->getValidatorXmlMappingFiles($container));
         $container->setParameter('validator.mapping.loader.yaml_files_loader.mapping_files', $this->getValidatorYamlMappingFiles($container));
 
-        if (isset($config['annotations'])) {
-            $namespaces = array('assert' => 'Symfony\\Component\\Validator\\Constraints\\');
-            // Register prefixes for constraint namespaces
-            if (!empty($config['annotations']['namespaces'])) {
-                $namespaces = array_merge($namespaces, $config['annotations']['namespaces']);
-            }
-
-            // Register annotation loader
-            $container->setParameter('validator.mapping.loader.annotation_loader.namespaces', $namespaces);
-
+        if ($config['enable_annotations']) {
             $loaderChain = $container->getDefinition('validator.mapping.loader.loader_chain');
             $arguments = $loaderChain->getArguments();
             array_unshift($arguments[0], new Reference('validator.mapping.loader.annotation_loader'));
@@ -520,6 +514,31 @@ class FrameworkExtension extends Extension
         return $files;
     }
 
+    private function registerAnnotationsConfiguration(array $config, ContainerBuilder $container,$loader)
+    {
+        $loader->load('annotations.xml');
+
+        if ('file' === $config['cache']) {
+            $cacheDir = $container->getParameterBag()->resolveValue($config['file_cache']['dir']);
+            if (!is_dir($cacheDir) && false === @mkdir($cacheDir, 0777, true)) {
+                throw new \RuntimeException(sprintf('Could not create cache directory "%s".', $cacheDir));
+            }
+
+            $container
+                ->getDefinition('annotations.cache.file_cache')
+                ->replaceArgument(0, $cacheDir)
+                ->replaceArgument(1, $config['file_cache']['debug'])
+            ;
+        } else if ('none' === $config['cache']) {
+            $container->setAlias('annotation_reader', 'annotations.reader');
+        } else {
+            $container
+                ->getDefinition('annotations.cached_reader')
+                ->replaceArgument(1, new Reference($config['cache']))
+            ;
+        }
+    }
+
     /**
      * Returns the base path for the XSD files.
      *

+ 29 - 0
src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml

@@ -0,0 +1,29 @@
+<?xml version="1.0" ?>
+
+<container xmlns="http://symfony.com/schema/dic/services"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
+
+    <parameters>
+        <parameter key="annotations.cache.file_cache.class">Doctrine\Common\Annotations\Cache\FileCache</parameter>
+
+        <parameter key="annotations.reader.class">Doctrine\Common\Annotations\AnnotationReader</parameter>
+        <parameter key="annotations.cached_reader.class">Doctrine\Common\Annotations\CachedReader</parameter>
+    </parameters>
+
+    <services>
+        <service id="annotations.cache.file_cache" class="%annotations.cache.file_cache.class%" public="false">
+            <argument /><!-- Cache Directory -->
+            <argument /><!-- Debug-Flag -->
+        </service>
+
+        <service id="annotations.reader" class="%annotations.reader.class%" public="false" />
+
+        <service id="annotations.cached_reader" class="%annotations.cached_reader.class%" public="false">
+            <argument type="service" id="annotations.reader" />
+            <argument type="service" id="annotations.cache.file_cache" />
+        </service>
+
+        <service id="annotation_reader" alias="annotations.cached_reader" />
+    </services>
+</container>

+ 12 - 10
src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd

@@ -18,6 +18,7 @@
             <xsd:element name="templating" type="templating" minOccurs="0" maxOccurs="1" />
             <xsd:element name="translator" type="translator" minOccurs="0" maxOccurs="1" />
             <xsd:element name="validation" type="validation" minOccurs="0" maxOccurs="1" />
+            <xsd:element name="annotations" type="annotations" minOccurs="0" maxOccurs="1" />
         </xsd:all>
 
         <xsd:attribute name="cache-warmer" type="cache_warmer" />
@@ -121,20 +122,21 @@
     </xsd:complexType>
 
     <xsd:complexType name="validation">
+        <xsd:attribute name="enabled" type="xsd:boolean" />
+        <xsd:attribute name="cache" type="xsd:string" />
+        <xsd:attribute name="enable-annotations" type="xsd:boolean" />
+    </xsd:complexType>
+    
+    <xsd:complexType name="annotations">
         <xsd:sequence>
-            <xsd:element name="namespace" type="validation_namespace" minOccurs="0" maxOccurs="1" />
+            <xsd:element name="file-cache" type="annotations.file_cache" minOccurs="0" maxOccurs="1" />
         </xsd:sequence>
 
-        <xsd:attribute name="enabled" type="xsd:boolean" />
         <xsd:attribute name="cache" type="xsd:string" />
-        <xsd:attribute name="annotations" type="xsd:boolean" />
     </xsd:complexType>
-
-    <xsd:complexType name="validation_namespace">
-        <xsd:simpleContent>
-            <xsd:extension base="xsd:string">
-                <xsd:attribute name="prefix" type="xsd:string" />
-            </xsd:extension>
-        </xsd:simpleContent>
+    
+    <xsd:complexType name="annotations.file_cache">
+        <xsd:attribute name="dir" type="xsd:string" />
+        <xsd:attribute name="debug" type="xsd:string" />
     </xsd:complexType>
 </xsd:schema>

+ 1 - 1
src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml

@@ -51,7 +51,7 @@
         <service id="validator.mapping.loader.static_method_loader" class="%validator.mapping.loader.static_method_loader.class%" public="false" />
 
         <service id="validator.mapping.loader.annotation_loader" class="%validator.mapping.loader.annotation_loader.class%" public="false">
-            <argument>%validator.mapping.loader.annotation_loader.namespaces%</argument>
+            <argument type="service" id="annotation_reader" />
         </service>
 
         <service id="validator.mapping.loader.xml_files_loader" class="%validator.mapping.loader.xml_files_loader.class%" public="false">

+ 7 - 0
src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php

@@ -57,4 +57,11 @@ $container->loadFromExtension('framework', array(
         'enabled' => true,
         'cache'   => 'apc',
     ),
+    'annotations' => array(
+        'cache' => 'file',
+        'file_cache' => array(
+            'dir'   => '%kernel.cache_dir%/annotations',
+            'debug' => true,
+        )
+    ),
 ));

+ 1 - 5
src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_annotations.php

@@ -4,10 +4,6 @@ $container->loadFromExtension('framework', array(
     'secret' => 's3cr3t',
     'validation' => array(
         'enabled'     => true,
-        'annotations' => array(
-            'namespaces' => array(
-                'app' => 'Application\\Validator\\Constraints\\',
-            ),
-        ),
+        'enable_annotations' => true,
     ),
 ));

+ 3 - 0
src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml

@@ -31,5 +31,8 @@
         </framework:templating>
         <framework:translator enabled="true" fallback="fr" />
         <framework:validation enabled="true" cache="apc" />
+        <framework:annotations cache="file">
+            <framework:file-cache dir="%kernel.cache_dir%/annotations" debug="true" />
+        </framework:annotations>
     </framework:config>
 </container>

+ 1 - 3
src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_annotations.xml

@@ -7,8 +7,6 @@
                         http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
 
     <framework:config secret="s3cr3t">
-        <framework:validation enabled="true" annotations="true">
-            <framework:namespace prefix="app">Application\Validator\Constraints\</framework:namespace>
-        </framework:validation>
+        <framework:validation enabled="true" enable-annotations="true" />
     </framework:config>
 </container>

+ 5 - 0
src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml

@@ -43,3 +43,8 @@ framework:
     validation:
         enabled: true
         cache:   apc
+    annotations:
+        cache:   file
+        file_cache:
+            dir:   %kernel.cache_dir%/annotations
+            debug: true

+ 1 - 3
src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_annotations.yml

@@ -2,6 +2,4 @@ framework:
     secret: s3cr3t
     validation:
         enabled:     true
-        annotations:
-            namespaces:
-                app: Application\Validator\Constraints\
+        enable_annotations: true

+ 16 - 4
src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

@@ -168,15 +168,27 @@ abstract class FrameworkExtensionTest extends TestCase
         );
     }
 
+    public function testAnnotations()
+    {
+        $container = $this->createContainerFromFile('full');
+
+        $this->assertEquals($container->getParameter('kernel.cache_dir').'/annotations', $container->getDefinition('annotations.cache.file_cache')->getArgument(0));
+        $this->assertEquals('annotations.cached_reader', (string) $container->getAlias('annotation_reader'));
+    }
+
     public function testValidationAnnotations()
     {
         $container = $this->createContainerFromFile('validation_annotations');
 
         $this->assertTrue($container->hasDefinition('validator.mapping.loader.annotation_loader'), '->registerValidationConfiguration() defines the annotation loader');
-
-        $argument = $container->getParameter('validator.mapping.loader.annotation_loader.namespaces');
-        $this->assertEquals('Symfony\\Component\\Validator\\Constraints\\', $argument['assert'], '->registerValidationConfiguration() loads the default "assert" prefix');
-        $this->assertEquals('Application\\Validator\\Constraints\\', $argument['app'], '->registerValidationConfiguration() loads custom validation namespaces');
+        $loaders = $container->getDefinition('validator.mapping.loader.loader_chain')->getArgument(0);
+        $found = false;
+        foreach ($loaders as $loader) {
+            if ('validator.mapping.loader.annotation_loader' === (string) $loader) {
+                $found = true;
+            }
+        }
+        $this->assertTrue($found, 'validator.mapping.loader.annotation_loader is added to the loader chain.');
     }
 
     public function testValidationPaths()

+ 0 - 46
src/Symfony/Component/Routing/Annotation/Routes.php

@@ -1,46 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Routing\Annotation;
-
-/**
- * Annotation class for @Routes().
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Routes
-{
-    private $routes;
-
-    /**
-     * Constructor.
-     *
-     * @param array $data An array of key/value parameters.
-     */
-    public function __construct(array $data)
-    {
-        if (!isset($data['value']) || !is_array($data['value'])) {
-            throw new \LogicException('A @Routes annotation must have an array of @Route annotation as argument.');
-        }
-
-        $this->routes = $data['value'];
-    }
-
-    public function setRoutes($routes)
-    {
-        $this->routes = $routes;
-    }
-
-    public function getRoutes()
-    {
-        return $this->routes;
-    }
-}

+ 5 - 18
src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php

@@ -11,7 +11,7 @@
 
 namespace Symfony\Component\Routing\Loader;
 
-use Doctrine\Common\Annotations\AnnotationReader;
+use Doctrine\Common\Annotations\Reader;
 use Symfony\Component\Routing\Annotation\Route as RouteAnnotation;
 use Symfony\Component\Config\Resource\FileResource;
 use Symfony\Component\Routing\Route;
@@ -59,14 +59,13 @@ abstract class AnnotationClassLoader implements LoaderInterface
 {
     protected $reader;
     protected $routeAnnotationClass  = 'Symfony\\Component\\Routing\\Annotation\\Route';
-    protected $routesAnnotationClass = 'Symfony\\Component\\Routing\\Annotation\\Routes';
 
     /**
      * Constructor.
      *
-     * @param AnnotationReader $reader
+     * @param Reader $reader
      */
-    public function __construct(AnnotationReader $reader)
+    public function __construct(Reader $reader)
     {
         $this->reader = $reader;
     }
@@ -81,16 +80,6 @@ abstract class AnnotationClassLoader implements LoaderInterface
         $this->routeAnnotationClass = $class;
     }
 
-    /**
-     * Sets the annotation class to read routes properties from.
-     *
-     * @param string $class A fully-qualified class name
-     */
-    public function setRoutesAnnotationClass($class)
-    {
-        $this->routesAnnotationClass = $class;
-    }
-
     /**
      * Loads from annotations from a class.
      *
@@ -137,12 +126,10 @@ abstract class AnnotationClassLoader implements LoaderInterface
         $collection->addResource(new FileResource($class->getFileName()));
 
         foreach ($class->getMethods() as $method) {
-            if ($annots = $this->reader->getMethodAnnotation($method, $this->routesAnnotationClass)) {
-                foreach ($annots->getRoutes() as $annot) {
+            foreach ($this->reader->getMethodAnnotations($method) as $annot) {
+                if ($annot instanceof $this->routeAnnotationClass) {
                     $this->addRoute($collection, $annot, $globals, $class, $method);
                 }
-            } elseif ($annot = $this->reader->getMethodAnnotation($method, $this->routeAnnotationClass)) {
-                $this->addRoute($collection, $annot, $globals, $class, $method);
             }
         }
 

+ 0 - 22
src/Symfony/Component/Validator/Constraints/Set.php

@@ -1,22 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Validator\Constraints;
-
-class Set
-{
-    public $constraints;
-
-    public function __construct(array $constraints)
-    {
-        $this->constraints = $constraints['value'];
-    }
-}

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

@@ -11,10 +11,9 @@
 
 namespace Symfony\Component\Validator\Mapping\Loader;
 
+use Doctrine\Common\Annotations\Reader;
 use Symfony\Component\Validator\Exception\MappingException;
 use Symfony\Component\Validator\Mapping\ClassMetadata;
-use Doctrine\Common\Annotations\AnnotationReader;
-use Symfony\Component\Validator\Constraints\Set;
 use Symfony\Component\Validator\Constraints\GroupSequence;
 use Symfony\Component\Validator\Constraint;
 
@@ -22,18 +21,9 @@ class AnnotationLoader implements LoaderInterface
 {
     protected $reader;
 
-    public function __construct(array $paths = null)
+    public function __construct(Reader $reader)
     {
-        if (null === $paths) {
-            $paths = array('assert' => 'Symfony\\Component\\Validator\\Constraints\\');
-        }
-
-        $this->reader = new AnnotationReader();
-        $this->reader->setAutoloadAnnotations(true);
-
-        foreach ($paths as $prefix => $path) {
-            $this->reader->setAnnotationNamespaceAlias($path, $prefix);
-        }
+        $this->reader = $reader;
     }
 
     /**
@@ -46,11 +36,7 @@ class AnnotationLoader implements LoaderInterface
         $loaded = false;
 
         foreach ($this->reader->getClassAnnotations($reflClass) as $constraint) {
-            if ($constraint instanceof Set) {
-                foreach ($constraint->constraints as $constraint) {
-                    $metadata->addConstraint($constraint);
-                }
-            } elseif ($constraint instanceof GroupSequence) {
+            if ($constraint instanceof GroupSequence) {
                 $metadata->setGroupSequence($constraint->groups);
             } elseif ($constraint instanceof Constraint) {
                 $metadata->addConstraint($constraint);
@@ -62,11 +48,7 @@ class AnnotationLoader implements LoaderInterface
         foreach ($reflClass->getProperties() as $property) {
             if ($property->getDeclaringClass()->getName() == $className) {
                 foreach ($this->reader->getPropertyAnnotations($property) as $constraint) {
-                    if ($constraint instanceof Set) {
-                        foreach ($constraint->constraints as $constraint) {
-                            $metadata->addPropertyConstraint($property->getName(), $constraint);
-                        }
-                    } elseif ($constraint instanceof Constraint) {
+                    if ($constraint instanceof Constraint) {
                         $metadata->addPropertyConstraint($property->getName(), $constraint);
                     }
 
@@ -81,11 +63,7 @@ class AnnotationLoader implements LoaderInterface
                     // TODO: clean this up
                     $name = lcfirst(substr($method->getName(), 0, 3)=='get' ? substr($method->getName(), 3) : substr($method->getName(), 2));
 
-                    if ($constraint instanceof Set) {
-                        foreach ($constraint->constraints as $constraint) {
-                            $metadata->addGetterConstraint($name, $constraint);
-                        }
-                    } elseif ($constraint instanceof Constraint) {
+                    if ($constraint instanceof Constraint) {
                         $metadata->addGetterConstraint($name, $constraint);
                     }
 

+ 3 - 6
src/Symfony/Component/Validator/ValidatorFactory.php

@@ -11,6 +11,7 @@ namespace Symfony\Component\Validator;
  * file that was distributed with this source code.
  */
 
+use Doctrine\Common\Annotations\AnnotationReader;
 use Symfony\Component\Validator\Exception\MappingException;
 use Symfony\Component\Validator\Mapping\ClassMetadataFactory;
 use Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface;
@@ -89,10 +90,6 @@ class ValidatorFactory implements ValidatorContextInterface
      *                                      found. Can be empty.
      * @param  Boolean $annotations         Whether to use annotations for
      *                                      retrieving mapping information
-     * @param  array $annotationNamespaces  The annotation namespaces used
-     *                                      for finding the annotation classes.
-     *                                      The namespace "validation" is used
-     *                                      by default
      * @param  string $staticMethod         The name of the static method to
      *                                      use, if static method loading should
      *                                      be enabled
@@ -100,7 +97,7 @@ class ValidatorFactory implements ValidatorContextInterface
      *                                      has neither the extension ".xml" nor
      *                                      ".yml" nor ".yaml"
      */
-    public static function buildDefault(array $mappingFiles = array(), $annotations = true, $annotationNamespaces = null, $staticMethod = null)
+    public static function buildDefault(array $mappingFiles = array(), $annotations = true, $staticMethod = null)
     {
         $xmlMappingFiles = array();
         $yamlMappingFiles = array();
@@ -128,7 +125,7 @@ class ValidatorFactory implements ValidatorContextInterface
         }
 
         if ($annotations) {
-            $loaders[] = new AnnotationLoader($annotationNamespaces);
+            $loaders[] = new AnnotationLoader(new AnnotationReader());
         }
 
         if ($staticMethod) {

+ 4 - 0
tests/Symfony/Tests/Bridge/Doctrine/Fixtures/CompositeIdentEntity.php

@@ -2,6 +2,10 @@
 
 namespace Symfony\Tests\Bridge\Doctrine\Form\Fixtures;
 
+use Doctrine\ORM\Mapping\Id;
+use Doctrine\ORM\Mapping\Column;
+use Doctrine\ORM\Mapping\Entity;
+
 /** @Entity */
 class CompositeIdentEntity
 {

+ 4 - 0
tests/Symfony/Tests/Bridge/Doctrine/Fixtures/CompositeStringIdentEntity.php

@@ -2,6 +2,10 @@
 
 namespace Symfony\Tests\Bridge\Doctrine\Form\Fixtures;
 
+use Doctrine\ORM\Mapping\Id;
+use Doctrine\ORM\Mapping\Column;
+use Doctrine\ORM\Mapping\Entity;
+
 /** @Entity */
 class CompositeStringIdentEntity
 {

+ 4 - 0
tests/Symfony/Tests/Bridge/Doctrine/Fixtures/SingleIdentEntity.php

@@ -2,6 +2,10 @@
 
 namespace Symfony\Tests\Bridge\Doctrine\Form\Fixtures;
 
+use Doctrine\ORM\Mapping\Id;
+use Doctrine\ORM\Mapping\Column;
+use Doctrine\ORM\Mapping\Entity;
+
 /** @Entity */
 class SingleIdentEntity
 {

+ 4 - 0
tests/Symfony/Tests/Bridge/Doctrine/Fixtures/SingleStringIdentEntity.php

@@ -2,6 +2,10 @@
 
 namespace Symfony\Tests\Bridge\Doctrine\Form\Fixtures;
 
+use Doctrine\ORM\Mapping\Id;
+use Doctrine\ORM\Mapping\Column;
+use Doctrine\ORM\Mapping\Entity;
+
 /** @Entity */
 class SingleStringIdentEntity
 {

+ 7 - 1
tests/Symfony/Tests/Bridge/Doctrine/Form/DoctrineOrmTestCase.php

@@ -11,6 +11,12 @@
 
 namespace Symfony\Tests\Bridge\Doctrine\Form;
 
+use Symfony\Bundle\DoctrineBundle\Annotations\IndexedReader;
+
+use Doctrine\Common\Annotations\AnnotationReader;
+
+use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
+
 use Doctrine\ORM\EntityManager;
 use Symfony\Tests\Component\Form\Extension\Core\Type\TestCase;
 
@@ -32,7 +38,7 @@ abstract class DoctrineOrmTestCase extends \PHPUnit_Framework_TestCase
         $config->setAutoGenerateProxyClasses(true);
         $config->setProxyDir(\sys_get_temp_dir());
         $config->setProxyNamespace('SymfonyTests\Doctrine');
-        $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver($paths));
+        $config->setMetadataDriverImpl(new AnnotationDriver(new IndexedReader(new AnnotationReader())));
         $config->setQueryCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
         $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
 

+ 12 - 12
tests/Symfony/Tests/Component/Validator/Fixtures/Entity.php

@@ -5,24 +5,24 @@ namespace Symfony\Tests\Component\Validator\Fixtures;
 require_once __DIR__.'/EntityParent.php';
 require_once __DIR__.'/EntityInterface.php';
 
+use Symfony\Component\Validator\Constraints as Assert;
+
 /**
  * @Symfony\Tests\Component\Validator\Fixtures\ConstraintA
- * @assert:GroupSequence({"Foo", "Entity"})
+ * @Assert\GroupSequence({"Foo", "Entity"})
  */
 class Entity extends EntityParent implements EntityInterface
 {
     /**
-     * @assert:NotNull
-     * @assert:Min(3)
-     * @assert:Set({
-     *   @assert:All({@assert:NotNull, @assert:Min(3)}),
-     *   @assert:All(constraints={@assert:NotNull, @assert:Min(3)})
-     * })
-     * @assert:Collection(fields={
-     *   "foo" = {@assert:NotNull, @assert:Min(3)},
-     *   "bar" = @assert:Min(5)
+     * @Assert\NotNull
+     * @Assert\Min(3)
+     * @Assert\All({@Assert\NotNull, @Assert\Min(3)}),
+     * @Assert\All(constraints={@Assert\NotNull, @Assert\Min(3)})
+     * @Assert\Collection(fields={
+     *   "foo" = {@Assert\NotNull, @Assert\Min(3)},
+     *   "bar" = @Assert\Min(5)
      * })
-     * @assert:Choice(choices={"A", "B"}, message="Must be one of %choices%")
+     * @Assert\Choice(choices={"A", "B"}, message="Must be one of %choices%")
      */
     protected $firstName;
     protected $lastName;
@@ -41,7 +41,7 @@ class Entity extends EntityParent implements EntityInterface
     }
 
     /**
-     * @assert:NotNull
+     * @Assert\NotNull
      */
     public function getLastName()
     {

+ 3 - 1
tests/Symfony/Tests/Component/Validator/Fixtures/EntityParent.php

@@ -2,13 +2,15 @@
 
 namespace Symfony\Tests\Component\Validator\Fixtures;
 
+use Symfony\Component\Validator\Constraints\NotNull;
+
 class EntityParent
 {
     protected $firstName;
     private $internal;
 
     /**
-     * @assert:NotNull
+     * @NotNull
      */
     protected $other;
 }

+ 7 - 6
tests/Symfony/Tests/Component/Validator/Mapping/Loader/AnnotationLoaderTest.php

@@ -14,6 +14,7 @@ namespace Symfony\Tests\Component\Validator\Mapping\Loader;
 require_once __DIR__.'/../../Fixtures/Entity.php';
 require_once __DIR__.'/../../Fixtures/ConstraintA.php';
 
+use Doctrine\Common\Annotations\AnnotationReader;
 use Symfony\Component\Validator\Constraints\All;
 use Symfony\Component\Validator\Constraints\Collection;
 use Symfony\Component\Validator\Constraints\NotNull;
@@ -28,13 +29,13 @@ class AnnotationLoaderTest extends \PHPUnit_Framework_TestCase
     protected function setUp()
     {
         if (!class_exists('Doctrine\Common\Annotations\AnnotationReader')) {
-            $this->markTestSkipped('Unmet dependency: doctrine-common is required for this test');
+            $this->markTestSkipped('Unmet dependency: Annotations is required for this test');
         }
     }
 
     public function testLoadClassMetadataReturnsTrueIfSuccessful()
     {
-        $loader = new AnnotationLoader();
+        $loader = new AnnotationLoader(new AnnotationReader());
         $metadata = new ClassMetadata('Symfony\Tests\Component\Validator\Fixtures\Entity');
 
         $this->assertTrue($loader->loadClassMetadata($metadata));
@@ -42,7 +43,7 @@ class AnnotationLoaderTest extends \PHPUnit_Framework_TestCase
 
     public function testLoadClassMetadataReturnsFalseIfNotSuccessful()
     {
-        $loader = new AnnotationLoader();
+        $loader = new AnnotationLoader(new AnnotationReader());
         $metadata = new ClassMetadata('\stdClass');
 
         $this->assertFalse($loader->loadClassMetadata($metadata));
@@ -50,7 +51,7 @@ class AnnotationLoaderTest extends \PHPUnit_Framework_TestCase
 
     public function testLoadClassMetadata()
     {
-        $loader = new AnnotationLoader();
+        $loader = new AnnotationLoader(new AnnotationReader());
         $metadata = new ClassMetadata('Symfony\Tests\Component\Validator\Fixtures\Entity');
 
         $loader->loadClassMetadata($metadata);
@@ -83,7 +84,7 @@ class AnnotationLoaderTest extends \PHPUnit_Framework_TestCase
      */
     public function testLoadParentClassMetadata()
     {
-        $loader = new AnnotationLoader();
+        $loader = new AnnotationLoader(new AnnotationReader());
 
         // Load Parent MetaData
         $parent_metadata = new ClassMetadata('Symfony\Tests\Component\Validator\Fixtures\EntityParent');
@@ -100,7 +101,7 @@ class AnnotationLoaderTest extends \PHPUnit_Framework_TestCase
      */
     public function testLoadClassMetadataAndMerge()
     {
-        $loader = new AnnotationLoader();
+        $loader = new AnnotationLoader(new AnnotationReader());
 
         // Load Parent MetaData
         $parent_metadata = new ClassMetadata('Symfony\Tests\Component\Validator\Fixtures\EntityParent');

+ 10 - 13
tests/Symfony/Tests/Component/Validator/ValidatorFactoryTest.php

@@ -11,6 +11,7 @@
 
 namespace Symfony\Tests\Component\Validator;
 
+use Doctrine\Common\Annotations\AnnotationReader;
 use Symfony\Component\Validator\Validator;
 use Symfony\Component\Validator\ValidatorContext;
 use Symfony\Component\Validator\ValidatorFactory;
@@ -76,13 +77,13 @@ class ValidatorFactoryTest extends \PHPUnit_Framework_TestCase
     public function testBuildDefaultFromAnnotations()
     {
         if (!class_exists('Doctrine\Common\Annotations\AnnotationReader')) {
-            $this->markTestSkipped('Doctrine is required for this test');
+            $this->markTestSkipped('Annotations is required for this test');
         }
         $factory = ValidatorFactory::buildDefault();
 
         $context = new ValidatorContext();
         $context
-            ->setClassMetadataFactory(new ClassMetadataFactory(new AnnotationLoader()))
+            ->setClassMetadataFactory(new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader())))
             ->setConstraintValidatorFactory(new ConstraintValidatorFactory());
 
         $this->assertEquals(new ValidatorFactory($context), $factory);
@@ -91,17 +92,13 @@ class ValidatorFactoryTest extends \PHPUnit_Framework_TestCase
     public function testBuildDefaultFromAnnotationsWithCustomNamespaces()
     {
         if (!class_exists('Doctrine\Common\Annotations\AnnotationReader')) {
-            $this->markTestSkipped('Doctrine is required for this test');
+            $this->markTestSkipped('Annotations is required for this test');
         }
-        $factory = ValidatorFactory::buildDefault(array(), true, array(
-            'myns' => 'My\\Namespace\\',
-        ));
+        $factory = ValidatorFactory::buildDefault(array(), true);
 
         $context = new ValidatorContext();
         $context
-            ->setClassMetadataFactory(new ClassMetadataFactory(new AnnotationLoader(array(
-                'myns' => 'My\\Namespace\\',
-            ))))
+            ->setClassMetadataFactory(new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader())))
             ->setConstraintValidatorFactory(new ConstraintValidatorFactory());
 
         $this->assertEquals(new ValidatorFactory($context), $factory);
@@ -136,7 +133,7 @@ class ValidatorFactoryTest extends \PHPUnit_Framework_TestCase
     public function testBuildDefaultFromStaticMethod()
     {
         $path = __DIR__.'/Mapping/Loader/constraint-mapping.yml';
-        $factory = ValidatorFactory::buildDefault(array(), false, null, 'loadMetadata');
+        $factory = ValidatorFactory::buildDefault(array(), false, 'loadMetadata');
 
         $context = new ValidatorContext();
         $context
@@ -149,16 +146,16 @@ class ValidatorFactoryTest extends \PHPUnit_Framework_TestCase
     public function testBuildDefaultFromMultipleLoaders()
     {
         if (!class_exists('Doctrine\Common\Annotations\AnnotationReader')) {
-            $this->markTestSkipped('Doctrine is required for this test');
+            $this->markTestSkipped('Annotations is required for this test');
         }
         $xmlPath = __DIR__.'/Mapping/Loader/constraint-mapping.xml';
         $yamlPath = __DIR__.'/Mapping/Loader/constraint-mapping.yml';
-        $factory = ValidatorFactory::buildDefault(array($xmlPath, $yamlPath), true, null, 'loadMetadata');
+        $factory = ValidatorFactory::buildDefault(array($xmlPath, $yamlPath), true, 'loadMetadata');
 
         $chain = new LoaderChain(array(
             new XmlFilesLoader(array($xmlPath)),
             new YamlFilesLoader(array($yamlPath)),
-            new AnnotationLoader(),
+            new AnnotationLoader(new AnnotationReader()),
             new StaticMethodLoader('loadMetadata'),
         ));
 

+ 1 - 1
vendors.sh

@@ -44,7 +44,7 @@ install_git doctrine git://github.com/doctrine/doctrine2.git 2.0.5
 install_git doctrine-dbal git://github.com/doctrine/dbal.git 2.0.5
 
 # Doctrine Common
-install_git doctrine-common git://github.com/doctrine/common.git 2.0.2
+install_git doctrine-common git://github.com/doctrine/common.git origin/3.0.x
 
 # Doctrine migrations
 install_git doctrine-migrations git://github.com/doctrine/migrations.git