protected function doParsing($string)
 {
     $stream = new StringStream($string);
     $annotations = array();
     while ($char = $stream->getFirstCharacter()) {
         if ($char == '@') {
             $parser = new AnnotationParser();
             $annotation = $parser->parseStream($stream);
             $annotations[get_class($annotation)] = $annotation;
         } else {
             $stream->forward();
         }
     }
     return $annotations;
 }
Beispiel #2
1
 /**
  * @expectedException \OutOfBoundsException
  * */
 public function testRead()
 {
     $stream = new StringStream('123abcdefg');
     $this->assertEquals('1', $stream->getBuffer()->read(8));
     $stream->skip(16);
     $this->assertEquals('a', $stream->getBuffer()->read(8));
     $stream->skip(8);
     $this->assertEquals('c', $stream->getBuffer()->read(8));
     $this->assertEquals('d', $stream->getBuffer()->read(8));
     $stream->getBuffer()->read(200 * 8);
 }
Beispiel #3
1
 /**
  * Renders the parsed tree.
  */
 public function render()
 {
     if (!$this->line_number) {
         $this->parse();
     }
     $result = $this->root->render();
     ob_start();
     StringStream::add_string('result', $result);
     extract($this->variables);
     $__options = $this->options;
     $__render_attributes = function ($attributes) use($__options) {
         nodes\Tag::render_attributes_html($__options['format'], $__options['attr_wrapper'], $attributes);
     };
     include 'StringStream://result';
     StringStream::clear('result');
     return rtrim(ob_get_clean());
 }
Beispiel #4
1
 public function testMetadata()
 {
     $str = new StringStream('foobar');
     $this->assertEmpty($str->getMetadata());
     $this->assertNull($str->getMetadata('foo'));
 }
Beispiel #5
0
 /**
  * Test read
  */
 public function testRead()
 {
     $stream = new StringStream('test');
     $this->assertEquals('te', $stream->read(2));
 }
 /**
  * @expectedException Innmind\Filesystem\Exception\PositionNotSeekableException
  */
 public function testThrowWhenPositionNotSeekable()
 {
     $stream = new StringStream('Lorem ipsum dolor');
     $stream->seek(200);
 }