Andrewsville / PHP-Token-Reflection

Library emulating the PHP internal reflection using just the tokenized source code
http://andrewsville.github.com/PHP-Token-Reflection/
Other
190 stars 44 forks source link

Retrieving Reflection of Generic Lines #75

Open onet4 opened 8 years ago

onet4 commented 8 years ago

Hello, thanks for the great tool.

The basic concept is, that any reflection is possible to process the particular part of the token array describing the reflected element.

I could pull doc-block descriptions of a class like this.

$broker = new Broker(new Broker\Backend\Memory());
$broker->processDirectory( dirname( __FILE__ ) . '/project_x' );
$class = $broker->getClass( 'MyClassBase' );
$long_description = $class->getAnnotation(ReflectionAnnotation::LONG_DESCRIPTION);

I'm wondering if there is a way to retrieve doc-block contents of an arbitrary line of code. Say, there is a line which is neither a class, method, constant, nor function declaration and it is documented with the docblock format.

/**
 * This is for arbitrary contents.
 * 
 * Trying to see if custom doc-blocks can be included.
 * 
 * @package     CustomLine
 */
doAction( 'custom_line' );

When I print out the contents of $broker by doing like print_r( $broker, true );, I see the doc-block of such an above case is parsed and stored in the object. What I want to do is to list doc-block contents of generic lines which belong to a certain package or namespace. Is there a method like $broker->getMisc() or something?