Alex Rivera | Logout

Is there a good (standalone) PHPDoc parser class or function in PHP?

Asked 2010-06-09T22:06:30.300
10

I'm looking for some method of converting a PHP Docblock (as used for generating documentation by tools like Doxygen) into a structure I can inspect in PHP.

For example, I want to parse

/**
 * Multiply two values
 * @CHECKME
 *
 * @author someone
 * @created eons ago
 *
 * @param integer $x
 * @param integer $x
 *
 * @return integer
 */
function multiply($x, $y)
{
    return $x * $y;
}

into something similar to:

array(
     'author'  => 'someone'
    ,'created' => 'eons ago'
    ,'param'   => array(
                      'integer $x'
                     ,'integer $y'
                  )
    ,'_flags'  => array(
                     '@CHECKME'
                  )
);

I explicitly cannot use PEAR or any such library, it has to be relatively standalone. Any given solution that is better than using a bunch of regular expressions after stripping away comment outline would be awesome.

Edit
Report

1 Answer

-1

I have written a runtime PHP documentation utility that contains a PHPDoc parser class (Doqumentor). I would think this will do what you want if you want to take a look. It is also available on github if you have any improvements or bug fixes.

answered 2012-02-23T13:03:31.287

Your Answer