phpdoctor
phpdoctor copied to clipboard
@var type description not parsed correctly
Hi,
I was trying to use the @var like this: http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_tags.var.pkg.html
/** @var type description */ public $somevar;
But that won't work.
(1) It requires a linefeed to even parse the @var, (2) it won't convert the description into @text.
Attached, a possible fix, complete enough for my needs, but you'll probably want to tweak it.
Regards, Walter Doekes OSSO B.V.
diff --git a/classes/phpDoctor.php b/classes/phpDoctor.php
index 6b86d1c..31d7101 100644
--- a/classes/phpDoctor.php
+++ b/classes/phpDoctor.php
@@ -1302,12 +1302,15 @@ class PHPDoctor
'tags' => array()
);
- $explodedComment = preg_split('/\n[ \n\t\/]*\*[ \t]*@/', "\n".$comment);
+ // Either split it on "BOS /** @" or "LF * @"
+ $explodedComment = preg_split('/(^\n\/\*\*[ \t]*|\n[ \n\t\/]*\*[ \t]*)@/', "\n".$comment);
preg_match_all('/^[ \t]*[\/*]*\**( ?.*)[ \t\/*]*$/m', array_shift($explodedComment), $matches); // changed; we need the leading whitespace to detect multi-line list entries
if (isset($matches[1])) {
- $txt = implode("\n", $matches[1]);
- $data['tags']['@text'] = $this->createTag('@text', trim($txt, " \n\t\0\x0B*/"), $data, $root);
+ $txt = trim(implode("\n", $matches[1]));
+ if ($txt) {
+ $data['tags']['@text'] = $this->createTag('@text', trim($txt, " \n\t\0\x0B*/"), $data, $root);
+ }
}
foreach ($explodedComment as $tag) { // process tags
@@ -1328,7 +1331,18 @@ class PHPDoctor
}
break;
case 'var': // set variable type
- $data['type'] = $text;
+ $explodedText = preg_split('/\s+/', $text, 2);
+ if (isset($explodedText[1]) && trim($explodedText[1])) {
+ $doc = $explodedText[1];
+ $data['type'] = $explodedText[0];
+ if (!isset($data['tags']['@text'])) {
+ $data['tags']['@text'] = $this->createTag('@text', $explodedText[1], $data, $root);
+ } else {
+ // FIXME: discarding @var-description!
+ }
+ } else {
+ $data['type'] = $text;
+ }
break;
case 'access': // set access permission
$data['access'] = $text;