本文整理汇总了PHP中Context::next方法的典型用法代码示例。如果您正苦于以下问题:PHP Context::next方法的具体用法?PHP Context::next怎么用?PHP Context::next使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Context
的用法示例。
在下文中一共展示了Context::next方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute(Context $context)
{
if ($context->getCurrentCommand() !== 'begin') {
throw new RuntimeException('illegal command ' . $context->getCurrentCommand());
}
$command_list = new CommandListCommand();
$command_list->execute($context->next());
}
示例2: execute
/**
* @param Context $context
* @return boolean
**/
public function execute(Context $context)
{
if ($context->getCurrentCommand() != 'begin') {
throw new \Exception('構文が正しくありません');
}
if (is_null($this->next_command)) {
throw new \Exception('次のコマンドが指定されていません');
}
$this->next_command->execute($context->next());
return true;
}
示例3: handle
/**
* 文字 %x20, %x09, %x0A, %x0D を読み飛ばします.
*
* @param Context $context
*/
public function handle(Context $context)
{
static $wsList = array("\r", "\n", "\r\n", "\t", " ");
while ($context->hasNext()) {
$current = $context->current();
if (!in_array($current, $wsList)) {
break;
}
$context->next();
}
}
示例4: decodeEscapedChar
/**
* "\" で始まる文字列を対応する文字に変換します.
*
* @param Context $context
* @return string
*/
private function decodeEscapedChar(Context $context)
{
// @codeCoverageIgnoreStart
static $specials = null;
if ($specials === null) {
$specials = array("\\" => "\\", '"' => '"', "/" => "/", "b" => chr(0x8), "f" => chr(0xc), "n" => "\n", "r" => "\r", "t" => "\t");
}
// @codeCoverageIgnoreEnd
$current = $context->current();
if (array_key_exists($current, $specials)) {
$context->next();
return $specials[$current];
}
// decode \uXXXX
if ($current !== "u") {
$context->throwException("Invalid escape sequence ('\\{$current}')");
}
$context->next();
$hex = $context->getSequence(4);
if (!preg_match("/^[0-9A-Fa-f]{4}\$/", $hex)) {
$context->throwException("Invalid hexadecimal sequence (Expected: \\uXXXX)");
}
$context->skip(4);
return $context->encodeCodepoint(hexdec($hex));
}
示例5: handleChar
/**
*
* @param Context $context
* @throws DecodeException 期待されている文字以外の文字を検知した場合
*/
private function handleChar(Context $context)
{
$chr = $context->current();
$expected = $this->expected;
if (in_array($chr, $expected, true)) {
$this->result = $chr;
$context->next();
return;
}
$quote = function ($chr) {
return "'{$chr}'";
};
$expectedList = implode(", ", array_map($quote, $expected));
$context->throwException("'{$chr}' is not allowed (expected: {$expectedList})");
}