當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Context::next方法代碼示例

本文整理匯總了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());
 }
開發者ID:th1209,項目名稱:php_design_pattern,代碼行數:8,代碼來源:interpreter.php

示例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;
 }
開發者ID:app2641,項目名稱:DesignPatternOnPHP,代碼行數:15,代碼來源:JobCommand.php

示例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();
     }
 }
開發者ID:trashtoy,項目名稱:peach2,代碼行數:16,代碼來源:WS.php

示例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));
 }
開發者ID:trashtoy,項目名稱:peach2,代碼行數:31,代碼來源:StringExpr.php

示例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})");
 }
開發者ID:trashtoy,項目名稱:peach2,代碼行數:20,代碼來源:StructuralChar.php


注:本文中的Context::next方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。