ZF2-110: Zend\Code\DocBlockScanner doesn't recognize anymore tags without values
Description
Component: Zend\Code (not listed)
The DocBlockScanner doesn't parse anymore tagnames wihout values such as this:
/** * @mytag */
They could be useful to tag code elements with custom tags as I was doing in zf 2.0 dev2
Comments
Posted by Adam Lundrigan (adamlundrigan) on 2012-02-23T17:44:45.000+0000
I believe this issue has been rectified already. I ran this unit test against Zend\Code\Scanner\DocBlockScanner:
And it passed. I've issued a PR (https://github.com/zendframework/zf2/pull/820) to get this test added to the ZF2 test suite.
Posted by Massimiliano Torromeo (mtorromeo) on 2012-02-23T21:30:13.000+0000
It seems I was wrong thinking that the problem was simply about tags without values. I still couldn't get my tags recognized with latest master and I found out that the issue was caused by a bug in the docblock cleaning function.
The regular expression used with single quotes failed to recognize tabs (\t) and also the cleaned docblock was not passed to the scanner.
Here is the fix:
diff --git a/library/Zend/Code/Reflection/DocBlockReflection.php b/library/Zend/Code/Reflection/DocBlockReflection.php index 564ce62..63c35d4 100644 --- a/library/Zend/Code/Reflection/DocBlockReflection.php +++ b/library/Zend/Code/Reflection/DocBlockReflection.php @@ -259,10 +259,10 @@ class DocBlockReflection implements Reflection $docComment = $this->docComment; // localize variable // create a clean docComment - $this->cleanDocComment = preg_replace('#[ \t]*(?:\/\*\*|\*\/|\*)?[ ]{0,1}(.*)?#', '$1', $docComment); + $this->cleanDocComment = preg_replace("#[ \t]*(?:\/\*\*|\*\/|\*)?[ ]{0,1}(.*)?#", '$1', $docComment); $this->cleanDocComment = ltrim($this->cleanDocComment, "\r\n"); // @todo should be changed to remove first and last empty line - $scanner = new DocBlockScanner($docComment); + $scanner = new DocBlockScanner($this->cleanDocComment); $this->shortDescription = ltrim($scanner->getShortDescription()); $this->longDescription = ltrim($scanner->getLongDescription()); foreach ($scanner->getTags() as $tag) {Posted by Maks 3w (maks3w) on 2012-05-14T16:09:44.000+0000
Hi Massimiliano,
You can send a Pull Request in Github with your patch. Anyway I tried to proposal but break some tests.
Regards.
Posted by Ralph Schindler (ralph) on 2012-10-08T20:15:37.000+0000
This issue has been closed on Jira and moved to GitHub for issue tracking. To continue following the resolution of this issues, please visit: https://github.com/zendframework/zf2/issues/2445