public function testBlockPositionsOnAbstractClass() { $blocks = new ArrayList(); $listener = function (BlockEvent $event) use($blocks) { $blocks->add($event->getBlock()); }; $parser = new Parser(); $parser->getContext()->addListener(Context::EVENT_BLOCK_LEAVE, $listener); $parser->parse($this->getRawContent('abstract-class')); $tokens = $parser->getTokens(); // test: class $class = $blocks->get(3); $this->assertEquals(Block::TYPE_CLASS, $class->type); $this->assertEquals($tokens->get(8), $class->start); $this->assertEquals($tokens->get(59), $class->end); // test: static method $static = $blocks->get(1); $this->assertEquals(Block::TYPE_METHOD, $static->type); $this->assertEquals($tokens->get(34), $static->start); $this->assertEquals($tokens->get(46), $static->end); }
/** * Retrieves a token at the given index * * @param int $index the given index * @return Token */ public function get($index) { return parent::get($index); }