/** * @param string|null $input * * @return array */ public function parse($input = null) { if (null !== $input) { $this->input = $input; } $this->lexer->setInput($this->input); $this->lexer->moveNext(); $this->srid = null; $this->dimension = null; if ($this->lexer->isNextToken(Lexer::T_SRID)) { $this->srid = $this->srid(); } $geometry = $this->geometry(); $geometry['srid'] = $this->srid; $geometry['dimension'] = '' === $this->dimension ? null : $this->dimension; return $geometry; }
public function testTokenRecognitionReuseLexer() { $lexer = new Lexer(); foreach ($this->tokenData() as $name => $testData) { $lexer->setInput($testData['value']); foreach ($testData['expected'] as $token) { $lexer->moveNext(); $actual = $lexer->lookahead; $this->assertEquals($token[0], $actual['type']); $this->assertEquals($token[1], $actual['value']); $this->assertEquals($token[2], $actual['position']); } } }