2017 © Pedro Peláez
 

library comment-introspection

PHP library providing a toolkit to parse class and method comments.

image

podlove/comment-introspection

PHP library providing a toolkit to parse class and method comments.

  • Saturday, January 4, 2014
  • by eteubert
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3,257 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 2 % Grown

The README.md

Podlove Comment Introspection

Build Status, (*1)

PHP library providing a toolkit to parse class and method comments., (*2)

Usage

use Podlove\Comment\Comment;

class ExampleClass {

    /**
     * A Title
     *
     * A multiline
     * description.
     * 
     * @tag1
     * @tag2 tag2 description
     */
    public function foo() {
        return "bar";
    }
}

$reflectionClass = new ReflectionClass("ExampleClass");
$methods = $reflectionClass->getMethods();
$parsedMethods = array_map(function($method) {
    $c = new Comment($method->getDocComment());
    $c->parse();

    return [
        'methodname'  => $method->name,
        'title'       => $c->getTitle(),
        'description' => $c->getDescription(),
        'tags'        => $c->getTags()
        /**
         * You can also access specific tags like so:
         * $c->getTag('tag1') or
         * $c->getTags('param') if you use one tag multiple times
         */
    ];
}, $methods);
print_r($parsedMethods);

/* =>

Array
(
    [0] => Array
        (
            [methodname] => foo
            [title] => A Title
            [description] => A multiline
description.

            [tags] => Array
                (
                    [0] => Array
                        (
                            [name] => tag2
                            [description] => tag2 description
                            [line] => 6
                        )

                    [1] => Array
                        (
                            [name] => tag1
                            [description] =>
                            [line] => 5
                        )

                )

        )

)
*/

The Versions

04/01 2014

dev-master

9999999-dev

PHP library providing a toolkit to parse class and method comments.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

parser reflection comment introspection podlove