本文整理汇总了PHP中GraphQL\Utils::charCodeAt方法的典型用法代码示例。如果您正苦于以下问题:PHP Utils::charCodeAt方法的具体用法?PHP Utils::charCodeAt怎么用?PHP Utils::charCodeAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphQL\Utils
的用法示例。
在下文中一共展示了Utils::charCodeAt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: readComment
/**
* Reads a comment token from the source file.
*
* #[\u0009\u0020-\uFFFF]*
*
* @param $start
* @param $line
* @param $col
* @param Token $prev
* @return Token
*/
private function readComment($start, $line, $col, Token $prev)
{
$body = $this->source->body;
$position = $start;
do {
$code = Utils::charCodeAt($body, ++$position);
} while ($code !== null && ($code > 0x1f || $code === 0x9));
return new Token(Token::COMMENT, $start, $position, $line, $col, $prev, mb_substr($body, $start + 1, $position - $start + 1, 'UTF-8'));
}
示例2: positionAfterWhitespace
/**
* Reads from body starting at startPosition until it finds a non-whitespace
* or commented character, then returns the position of that character for
* lexing.
*
* @param $body
* @param $startPosition
* @return int
*/
private function positionAfterWhitespace($body, $startPosition)
{
$bodyLength = mb_strlen($body, 'UTF-8');
$position = $startPosition;
while ($position < $bodyLength) {
$code = Utils::charCodeAt($body, $position);
// Skip whitespace
if ($code === 32 || $code === 44 || $code === 160 || $code === 0x2028 || $code === 0x2029 || $code > 8 && $code < 14) {
++$position;
// Skip comments
} else {
if ($code === 35) {
// #
++$position;
while ($position < $bodyLength && ($code = Utils::charCodeAt($body, $position)) && $code !== 10 && $code !== 13 && $code !== 0x2028 && $code !== 0x2029) {
++$position;
}
} else {
break;
}
}
}
return $position;
}