PHP-Token-Reflection icon indicating copy to clipboard operation
PHP-Token-Reflection copied to clipboard

Retrieving Reflection of Generic Lines

Open onet4 opened this issue 9 years ago • 0 comments

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?

onet4 avatar Jun 01 '16 22:06 onet4