当前位置: 首页>>代码示例>>PHP>>正文


PHP Token::getId方法代码示例

本文整理汇总了PHP中Token::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Token::getId方法的具体用法?PHP Token::getId怎么用?PHP Token::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Token的用法示例。


在下文中一共展示了Token::getId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testFind

 function testFind()
 {
     $patron_id = 1;
     $menu_id = 2;
     $sender_id = 3;
     $test_token = new Token($patron_id, $menu_id, $sender_id);
     $test_token->save();
     $patron_id2 = 4;
     $menu_id2 = 5;
     $sender_id2 = 6;
     $test_token2 = new Token($patron_id2, $menu_id2, $sender_id2);
     $test_token2->save();
     $result = Token::find($test_token->getId());
     $this->assertEquals($test_token, $result);
 }
开发者ID:CaseyH33,项目名称:Beer_Me,代码行数:15,代码来源:TokenTest.php

示例2: testGetId

 /**
  * @covers spriebsch\PHPca\Token::__construct
  * @covers spriebsch\PHPca\Token::getId
  */
 public function testGetId()
 {
     $t = new Token(T_OPEN_TAG, '<?php');
     $this->assertEquals(T_OPEN_TAG, $t->getId());
 }
开发者ID:spriebsch,项目名称:phpca,代码行数:9,代码来源:TokenTest.php

示例3: seekMatchingCurlyBrace

 /**
  * Seeks to the matching curly brace.
  *
  * @param Token $token
  */
 public function seekMatchingCurlyBrace(Token $token)
 {
     $id = $token->getId();
     $level = $token->getBlockLevel();
     if ($id != T_OPEN_CURLY && $id != T_CLOSE_CURLY) {
         throw new Exception($token->getName() . ' is not a curly brace');
     }
     // Forward search
     if ($id == T_OPEN_CURLY) {
         $this->next();
         while ($this->valid()) {
             $token = $this->current()->getId();
             $closeLevel = $this->current()->getBlockLevel();
             if ($token == T_CLOSE_CURLY && $closeLevel == $level) {
                 return;
             }
             $this->next();
         }
     }
     // Backward search
     if ($id == T_CLOSE_CURLY) {
         $this->prev();
         while ($this->valid()) {
             $token = $this->current()->getId();
             $openLevel = $this->current()->getBlockLevel();
             if ($token == T_OPEN_CURLY && $level == $openLevel) {
                 return;
             }
             $this->prev();
         }
     }
     // This should be impossible since in a syntactically valid
     // PHP file, every opened curly brace must be closed.
     throw new Exception('No matching curly brace found');
 }
开发者ID:spriebsch,项目名称:phpca,代码行数:40,代码来源:File.php

示例4: tokenize

 /**
  * Tokenize a file
  *
  * @param string $fileName    the file name
  * @param string $sourceCode  the source code
  * @return File
  */
 public static function tokenize($fileName, $sourceCode)
 {
     Constants::init();
     $class = '';
     $classFound = false;
     $waitForClassBegin = false;
     $classCurlyLevel = 0;
     $interface = '';
     $interfaceFound = false;
     $waitForInterfaceBegin = false;
     $interfaceCurlyLevel = 0;
     $function = '';
     $functionFound = false;
     $waitForFunctionBegin = false;
     $functionCurlyLevel = 0;
     $namespace = '\\';
     $newNamespace = '';
     $namespaceFound = false;
     $namespaceStarted = false;
     $level = 0;
     $line = 1;
     $column = 1;
     $file = new File($fileName, $sourceCode);
     foreach (token_get_all($sourceCode) as $token) {
         if (is_array($token)) {
             $id = $token[0];
             $text = $token[1];
             $line = $token[2];
         } else {
             try {
                 // it's not a PHP token, so we use one we have defined
                 $id = Constants::getTokenId($token);
                 $text = $token;
             } catch (UnkownTokenException $e) {
                 throw new TokenizerException('Unknown token ' . $e->getTokenName() . ' in file ' . $fileName);
             }
             // This exception is not testable, because we _have_ defined all
             // tokens, hopefully. It's just a safeguard to provide a decent
             // error message should we ever encounter an undefined token.
             // @codeCoverageIgnoreEnd
         }
         $tokenObj = new Token($id, $text, $line, $column);
         if ($tokenObj->hasNewline()) {
             // a newline resets the column count
             $line += $tokenObj->getNewLineCount();
             $column = 1 + $tokenObj->getTrailingWhitespaceCount();
         } else {
             $column += $tokenObj->getLength();
         }
         // We have encountered a T_NAMESPACE token before (this is indicated
         // by $namespaceFound being true, so the T_STRING contains the class
         // name (there will be T_WHITESPACE between T_NAMESPACE and T_STRING).
         // We remember the namespace name, but do not set it until we have
         // encountered the next opening brace or semicolon. We set
         // $waitForNamespaceBegin to true so that we can wait for one of these.
         if ($namespaceFound && $tokenObj->getId() == T_STRING || $namespaceFound && $tokenObj->getId() == T_NS_SEPARATOR) {
             $newNamespace .= $tokenObj->getText();
         }
         // We have encountered a T_CLASS token before (this is indicated
         // by $classFound being true, so the T_STRING contains the class
         // name (there will be T_WHITESPACE between T_CLASS and T_STRING).
         // We remember the class name, but do not set it until we have
         // encountered the next opening brace. We set $waitForClassBegin
         // to true so that we can wait for the next opening curly brace.
         if ($classFound && $tokenObj->getId() == T_STRING) {
             $class = $tokenObj->getText();
             $waitForClassBegin = true;
             $classFound = false;
         }
         // We have encountered a T_INTERFACE token before (this is indicated
         // by $interfaceFound being true, so the T_STRING contains the class
         // name (there will be T_WHITESPACE between T_INTERFACE and T_STRING).
         // We remember the interface name, but do not set it until we have
         // encountered the next opening brace. We set $waitForInterfaceBegin
         // to true so that we can wait for the next opening curly brace.
         if ($interfaceFound && $tokenObj->getId() == T_STRING) {
             $interface = $tokenObj->getText();
             $waitForInterfaceBegin = true;
             $interfaceFound = false;
         }
         // We have encountered a T_FUNCTION token before (this is indicated
         // by $functionFound being true, so the T_STRING contains the class
         // name (there will be T_WHITESPACE between T_FUNCTION and T_STRING).
         // We remember the function name, but do not set it until we have
         // encountered the next opening brace. We set $waitForFunctionBegin
         // to true so that we can wait for the next opening curly brace.
         if ($functionFound && $tokenObj->getId() == T_STRING) {
             $function = $tokenObj->getText();
             $waitForFunctionBegin = true;
             $functionFound = false;
         }
         // T_NAMESPACE token starts a namespace. We set $namespaceFound
         // to true so that we can watch out for the namespace name (see above).
//.........这里部分代码省略.........
开发者ID:spriebsch,项目名称:phpca,代码行数:101,代码来源:Tokenizer.php


注:本文中的Token::getId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。