Skip to content

Loading…

DCOM-61: Class annotation is not setting annotation properties #662

Closed
doctrinebot opened this Issue · 3 comments

2 participants

@doctrinebot

Jira issue originally created by user jreed:

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.

@doctrinebot

Comment created by jreed:

This is blocking me from upgrading to v2.1

@doctrinebot

Comment created by jreed:

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

@doctrinebot

Issue was closed with resolution "Invalid"

@doctrinebot doctrinebot added the Bug label
@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.