Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Add failing test to demonstrate parse error when @ is present in the description #195

wants to merge 1 commit into from

5 participants


If someone can take this and fix the issue it'd be great. I couldn't figure it out at a quick glance and I don't really have time, but it's a pretty messed up bug and not so trivial to debug if you don't know what happens in the background so I'd say it's pretty important.



thank you for positing this Pull Request. I have automatically opened an issue on our Jira Bug Tracker for you with the details of this Pull-Request. See the Link:


Oh btw, I just (automatically) realized that you are not creating this pull request against the master branch.

Unless there are good reasons for this, i would suggest to close and rebase the Pull Request against master and then create it again. Sorry!


Oh btw, did you realize GitHub released a nice feature to help contributors before they fuck up?

@pscheit pscheit referenced this pull request from a commit in pscheit/common
@pscheit pscheit fix: #DCOM-118 #195 restrict quoted-strings only to strings within qu…
…otes without a newline character
@pscheit pscheit referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@pscheit pscheit referenced this pull request from a commit in pscheit/common
@pscheit pscheit fix: #DCOM-118 #195 restrict quoted-strings only to strings within qu…
…otes without a newline character

I'm not sure whether we can fix this at all.

Is it possible to change the doc comment?


I've seen this fix, but it is problematic as it breaks multiline strings.


i had only one good other idea: to restrict the definition of an annotation when it is a string with an @ at the beginning of a "new line" in a doc block



something like that. Because i think thats the only difference from other annotations in the doc block.


Currently, we have an optimization in the DocParser in that we trim everything from the doc comment until the first @.

We could instead add an additional search for the first " and then only trim to whatever comes first. This should solve this, but makes the parsing process potentially a bit slower, and if you have an unclosed " in your doc comment it would still mess up. So, I'm not really sure it is worth it.


yep, it does not help much, had this idea, too. what about escaping multi line lineends with an \

@multilineannotation(" bla bla bla \
la la la \
la la")

Just for the record, yes of course I fixed my docblock in consequence, but it's a really nasty issue so it'd be nice if it could at least be detected and error out instead of returning no annotations.


@schmittjoh can you point me to the place where the trimming is done? Then I can try to improve it without making it slower. This bug is really a pain.


Thanks @pscheit - new version of the PR on the new repo, closing this. See doctrine/annotations#28

@Seldaek Seldaek closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
10 tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php
@@ -104,6 +104,16 @@ public function testAnnotationsWithVarType()
$this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', $barAnnot[0]->annotation);
+ public function testAtInDescription()
+ {
+ $reader = $this->getReader();
+ $class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAtInDescriptionAndAnnotation');
+ $this->assertEquals(1,count($fooAnnot = $reader->getPropertyAnnotations($class->getProperty('foo'))));
+ $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetPropertyMethod', $fooAnnot[0]);
+ }
* @expectedException Doctrine\Common\Annotations\AnnotationException
* @expectedExceptionMessage [Semantical Error] Annotation @AnnotationTargetPropertyMethod is not allowed to be declared on class Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtClass. You may only use this annotation on these code elements: METHOD, PROPERTY
19 tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithAtInDescriptionAndAnnotation.php
@@ -0,0 +1,19 @@
+namespace Doctrine\Tests\Common\Annotations\Fixtures;
+use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetPropertyMethod;
+class ClassWithAtInDescriptionAndAnnotation
+ /**
+ * Lala
+ *
+ * {
+ * "email": ""
+ * }
+ *
+ * @AnnotationTargetPropertyMethod("Bar")
+ */
+ public $foo;
Something went wrong with that request. Please try again.