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

Posted by Kris on Stack Overflow See other posts from Stack Overflow or by Kris
Published on 2010-06-09T22:06:30Z Indexed on 2010/06/09 22:12 UTC
Read the original article Hit count: 194

Filed under:
|
|

Hi folks,

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 the following lines:


    /**
     * 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 regexes after stripping away comment outline would be awesome.

© Stack Overflow or respective owner

Related posts about php

Related posts about parser