/** * Emits a token, passing it on to the tree builder. * @param array $token * @param bool $checkStream * @param bool $dry */ protected function _emitToken($token, $checkStream = true, $dry = false) { if ($checkStream) { // Emit errors from input stream. foreach ($this->stream->getErrors() as $stream_error) { $this->_emitToken($stream_error, false); } } if ($token['type'] === Tokenizer::TOKEN_ENDTAG && !empty($token['attr'])) { for ($i = 0; $i < count($token['attr']); $i++) { $this->_emitToken(array('type' => Tokenizer::TOKEN_PARSEERROR, 'data' => 'attributes-in-end-tag')); } } if ($token['type'] === Tokenizer::TOKEN_ENDTAG && !empty($token['self-closing'])) { $this->_emitToken(array('type' => Tokenizer::TOKEN_PARSEERROR, 'data' => 'self-closing-flag-on-end-tag')); } if ($token['type'] === Tokenizer::TOKEN_STARTTAG) { // This could be changed to actually pass the tree-builder a hash $hash = array(); foreach ($token['attr'] as $attr) { if (isset($hash[$attr['name']])) { $this->_emitToken(array('type' => Tokenizer::TOKEN_PARSEERROR, 'data' => 'duplicate-attribute')); } else { $hash[$attr['name']] = $attr['value']; } } } if (!$dry) { // the current structure of attributes is not a terribly good one $this->emitToken($token); } if ($token['type'] === Tokenizer::TOKEN_ENDTAG) { $this->content_model = self::PCDATA; } }
/** * @param string $node_class * @param InputStream $stream */ protected function assertYieldsNode($node_class, $stream) { $this->assertEquals($node_class, get_class($stream->symbol())); }