/** * @param Lexer $lexer * @param DOMNode $currentElement * @return string[] */ public function replace(Lexer $lexer, DOMNode $currentElement) { $xslForEach = $currentElement->parentNode; if ($xslForEach instanceof DOMNode) { while ($this->isForEachGroupElement($xslForEach) === false && $currentElement->ownerDocument !== $xslForEach) { $xslForEach = $xslForEach->parentNode; } } if ($this->isForEachGroupElement($xslForEach) === false) { $lexer->seek($lexer->key() + 2); return ['/', 'xs:sequence', '/', '*']; } /** @var DOMElement $xslForEach */ $groupId = $xslForEach->getAttribute('group-id'); $resultTokens = []; $resultTokens[] = '$current-un-grouped-' . $groupId; $resultTokens[] = '['; $resultTokens[] = 'generate-id'; $resultTokens[] = '('; $resultTokens[] = '.'; $resultTokens[] = ')'; $resultTokens[] = '='; $resultTokens[] = '$current-group-' . $groupId; $resultTokens[] = '//'; $resultTokens[] = 'xsl:element-id'; $resultTokens[] = ']'; $lexer->seek($lexer->key() + 2); return $resultTokens; }
/** * @param Lexer $lexer * @return bool */ public function supports(Lexer $lexer) { if ($lexer->current() !== '(') { return false; } if ($lexer->key() > 0) { $whiteSpaceOrOpeningParenthesis = new MatchingIterator($lexer, '/\\s|\\(/', MatchingIterator::DIRECTION_DOWN); for ($i = 0, $j = 2; $i < $j; $i++) { if ($whiteSpaceOrOpeningParenthesis->valid() === false) { return false; } if ($whiteSpaceOrOpeningParenthesis->key() < $lexer->key() - $i) { return false; } $whiteSpaceOrOpeningParenthesis->next(); } } $key = $lexer->key() + 1; $commaFound = false; while ($nextToken = $lexer->peek($key)) { if ($nextToken === '(') { return false; } if ($nextToken === ',') { $commaFound = true; } if ($nextToken === ')') { return $commaFound; } $key++; } return false; }
/** * @param Lexer $lexer * @param DOMNode $currentElement * @return array|\string[] */ public function replace(Lexer $lexer, DOMNode $currentElement) { $resultTokens = []; $resultTokens[] = 'php:function'; $resultTokens[] = '('; $resultTokens[] = '\''; $resultTokens[] = PhpCallback::class . '::callStatic'; $resultTokens[] = '\''; $resultTokens[] = ','; $resultTokens[] = '\''; $resultTokens[] = static::class; $resultTokens[] = '\''; $resultTokens[] = ','; $resultTokens[] = '\''; $resultTokens[] = 'call'; $resultTokens[] = '\''; $resultTokens[] = ','; $resultTokens[] = $lexer->peek($lexer->key() - 2); $resultTokens[] = ','; $resultTokens[] = $lexer->peek($lexer->key() + 2); $resultTokens[] = ')'; $resultTokens[] = '/'; $resultTokens[] = 'xs:sequence'; $resultTokens[] = '/'; $resultTokens[] = '*'; $lexer->seek($lexer->key() + 2); return $resultTokens; }
/** * @param Lexer $lexer * @param DOMNode $currentElement * @return string[] */ public function replace(Lexer $lexer, DOMNode $currentElement) { $xslForEach = $currentElement->parentNode; if ($xslForEach instanceof DOMElement) { while ($this->isForEachGroupElement($xslForEach) === false && $currentElement->ownerDocument !== $xslForEach) { $xslForEach = $xslForEach->parentNode; } } if ($this->isForEachGroupElement($xslForEach) === false) { throw new \RuntimeException('Feature not implemented. "At other times, it will be an empty sequence."'); } $groupId = $xslForEach->getAttribute('group-id'); $resultTokens = []; $resultTokens[] = '$current-un-grouped-' . $groupId; $resultTokens[] = '['; $resultTokens[] = 'generate-id'; $resultTokens[] = '('; $resultTokens[] = '.'; $resultTokens[] = ')'; $resultTokens[] = '='; $resultTokens[] = '$current-group-' . $groupId; $resultTokens[] = '//'; $resultTokens[] = 'xsl:element-id'; $resultTokens[] = ']'; $lexer->seek($lexer->key() + 2); return $resultTokens; }
/** * @param Lexer $lexer * @param DOMNode $currentElement * @return array|\string[] */ public function replace(Lexer $lexer, DOMNode $currentElement) { if ($this->camelize === true) { $methodName = $this->convertToCamel($this->callback[1]); } else { $methodName = $this->callback[1]; } $resultTokens = []; $resultTokens[] = 'php:function'; $resultTokens[] = '('; $resultTokens[] = '\''; $resultTokens[] = PhpCallback::class . '::callStatic'; $resultTokens[] = '\''; $resultTokens[] = ','; $resultTokens[] = '\''; $resultTokens[] = $this->callback[0]; $resultTokens[] = '\''; $resultTokens[] = ','; $resultTokens[] = '\''; $resultTokens[] = $methodName; $resultTokens[] = '\''; $lexer->next(); if ($lexer->peek($lexer->key() + 1) !== ')') { $resultTokens[] = ','; } return $resultTokens; }
/** * @param Lexer $lexer * @param DOMNode $currentElement * @return array|\string[] */ public function replace(Lexer $lexer, DOMNode $currentElement) { $resultTokens = []; $resultTokens[] = 'php:function'; $resultTokens[] = '('; $resultTokens[] = '\''; $resultTokens[] = PhpCallback::class . '::call'; $resultTokens[] = '\''; $resultTokens[] = ','; $resultTokens[] = '\''; $resultTokens[] = $this->name; $resultTokens[] = '\''; $lexer->next(); if ($lexer->peek($lexer->key() + 1) !== ')') { $resultTokens[] = ','; } return $resultTokens; }
/** * */ private function start() { $this->position = $this->lexer->key() + $this->direction * -1; $this->next(); }
/** * @param Lexer $lexer * @return bool */ public function supports(Lexer $lexer) { return $lexer->current() === 'to' && preg_match('/\\s/', $lexer->peek($lexer->key() - 1)) === 1; }
/** * @param Lexer $lexer * @return bool */ public function supports(Lexer $lexer) { $nextToken = $lexer->peek($lexer->key() + 1); return $nextToken === '('; }