Skip to content
gossi edited this page Oct 18, 2014 · 1 revision

The context is a parser-compartment. It provides you with all the required information to your currently processed token. It also manages the contexts and keeps track of entering and leaving a block, group or line contexts. You can also register listeners to be notified when one of this events happens.

Context-related Methods

// context methods
$context->getCurrentContext(); // file, struct, routine, block, group

// shortcuts
$context->inStructBody();
$context->inRoutineBody();

// entity accessors
$context->getBlockContext();
$context->getGroupContext();
$context->getLineContext();

Listeners

Register listener to get notified when parsing through a specific type of token.

$context->addListener($name, $listener);
$context->removeListener($name, $listener);

$name - is one of the Context::EVENT_* constants
$listener - a callable, which takes an event as argument, depending on the listener, this is a BlockEvent or GroupEvent.

Clone this wiki locally