Doctrine Common
  1. Doctrine Common
  2. DCOM-61

Class annotation is not setting annotation properties

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Blocker Blocker
    • Resolution: Invalid
    • Affects Version/s: 2.1
    • Fix Version/s: None
    • Component/s: Annotations
    • Labels:
      None
    • Environment:
      Windows 7 64-bit, PHP v5.3.1

      Description

      My annotations were working fine with v2.0.5. Once I upgraded to v2.1 they stopped working. Using this condensed code based on the v2.1 documentation on Annotations (http://www.doctrine-project.org/docs/common/2.1/en/reference/annotations.html):

      require 'c:/dev/library/doctrine-orm/Doctrine/Common/ClassLoader.php';
      
      $classLoader = new \Doctrine\Common\ClassLoader('Doctrine', 'c:/dev/library/doctrine-orm');
      $classLoader->register();
      $classLoader = new \Doctrine\Common\ClassLoader('Symfony', 'c:/dev/library/doctrine-orm/Doctrine');
      $classLoader->register();
      
      $reader = new \Doctrine\Common\Annotations\AnnotationReader();
      $reader->setIgnoreNotImportedAnnotations(true);
      $reader->setEnableParsePhpImports(false);
      $className = 'User';
      $reflectionClass = new \ReflectionClass($className);
      
      $classAnnotations = $reader->getClassAnnotations($reflectionClass);
      echo "Class Annotations - $className:\n";
      print_r($classAnnotations);
      
      /**
      * @Annotation
      */
      class Foo {
          public $bar;
      }
      
      /**
      * @Foo(bar="foo")
      */
      class User {
          
      }
      

      The result is:

      Class Annotations - User:
      Array
      (
          [0] => Foo Object
              (
                  [bar] =>
              )
      
      )
      

      Why is bar empty? If I remove the @Foo annotation from the docblock for the User class, then the result is an empty array. So it's clearly detecting the annotation, it's just not setting the annotation property.

        Activity

        Hide
        James Reed added a comment -

        This is blocking me from upgrading to v2.1

        Show
        James Reed added a comment - This is blocking me from upgrading to v2.1
        Hide
        James Reed added a comment -

        Got the same result with v2.0.6. Must be something I'm missing here.

        Show
        James Reed added a comment - Got the same result with v2.0.6. Must be something I'm missing here.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            James Reed
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: