public function testFilteredScan() { $reader = new FileReader(__DIR__ . '/../Fixtures/files/TestFile.php'); // Test the raw file with newlines and whitespaces $context = new DefaultScannerContext(); $context->addTokenFilter(new TokenFilter\NoNewlinesFilter()); $context->addTokenFilter(new TokenFilter\NoWhitespacesFilter()); $scanner = new GenericScanner($context); $queue = $scanner->scan($reader); $this->assertTokens($this->expectedTokensNoEmptyToken, $queue); }
private function parse(ReaderInterface $reader) { $scanner = new GenericScanner(new DefaultScannerContextWithoutSpacesAndComments()); $this->tokenQueue = $scanner->scan($reader); while (!$this->tokenQueue->isEof()) { while ($this->checkToken(Token::TK_SYMBOL, '<')) { $this->parseNamespaceMapping(); } if (!$this->tokenQueue->isEof()) { $this->parseNodeType(); } } return array('namespaces' => $this->namespaces, 'nodeTypes' => $this->nodeTypes); }