Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@var type description not parsed correctly #61

Open
wdoekes opened this issue Mar 1, 2012 · 1 comment
Open

@var type description not parsed correctly #61

wdoekes opened this issue Mar 1, 2012 · 1 comment

Comments

@wdoekes
Copy link

wdoekes commented Mar 1, 2012

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.

@wdoekes
Copy link
Author

wdoekes commented Mar 1, 2012

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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant