New issue 28 by shabbyrobe: Annotations with no space between the docblock
margin and the @ symbol are silently eaten
http://code.google.com/p/addendum/issues/detail?id=28
What steps will reproduce the problem?
1. Create a class
2. Add an annotation doc block
3. Omit the space between the * margin of the docblock and the @ of the
annotation.
If I have an annotation declared like so, with no space preceding the @,
Addendum cannot find the annotation:
/**
*@Table("person")
*/
class Person {}
$c = new ReflectionAnnotatedClass('Person');
var_dump($c->getAnnotations()); // nope
In the AnnotationsMatcher class, the regular expression seems to be looking
for a "space that is followed by an at symbol".
Changing the regex from '/\s(?=@)/' to '/[\s\*](?=@)/' seems to work
without breaking any of the other tests.
I used the following tests to make sure it worked as I expected. The second
test case was just to make sure "/**\n@Annotation(true)\n*/ worked, and it
does.
public function
testAnnotationsMatcherShouldMatchWhenThereIsNoSpaceBetweenDocBlockMarginAndAt()
{
$matcher = new AnnotationsMatcher;
$expected = array('Annotation'=>array(array('value'=>true)));
$block = "/**\n *@Annotation(true)\n*/";
$this->assertMatcherResult($matcher, $block, $expected);
}
public function
testAnnotationsMatcherShouldMatchWhenFirstThingOnALine() {
$matcher = new AnnotationsMatcher;
$expected = array('Annotation'=>array(array('value'=>true)));
$block = "/**\n@Annotation(true)\n*/";
$this->assertMatcherResult($matcher, $block, $expected);
}
Comment #1 on issue 28 by jan.suchal: Annotations with no space between the
docblock margin and the @ symbol are silently eaten
http://code.google.com/p/addendum/issues/detail?id=28
Cool, would you mind providing a file .patch of this change?
Here 'tis. Is this format OK? I just did an svn diff.
Attachments:
issue-28.diff 1.7 KB
Comment #3 on issue 28 by jan.suchal: Annotations with no space between the
docblock margin and the @ symbol are silently eaten
http://code.google.com/p/addendum/issues/detail?id=28
Thanks, applied in #75 http://code.google.com/p/addendum/source/detail?r=75#