本文整理汇总了PHP中Token::is方法的典型用法代码示例。如果您正苦于以下问题:PHP Token::is方法的具体用法?PHP Token::is怎么用?PHP Token::is使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Token
的用法示例。
在下文中一共展示了Token::is方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIs
function testIs()
{
$token = new Token('$');
$this->assertTrue($token->is('$'));
$this->assertTrue($token->is('$', ':', '!'));
$this->assertTrue($token->is('!', '?', ':', '$'));
$this->assertFalse($token->is('!', '?', ':'));
$this->assertFalse($token->is('$!'));
$token = new Token(T_STRING);
$this->assertFalse($token->is(T_OPEN_TAG, T_YIELD));
$this->assertTrue($token->is(T_STRING));
$token = new Token(T_STRING, '"value"', null);
$this->assertFalse($token->is(T_OPEN_TAG, T_YIELD));
$this->assertTrue($token->is(T_CLOSE_TAG, T_STRING));
}
示例2: addToken
public function addToken(Token $token)
{
switch ($token->getType()) {
// This block is basically a whitelist of token types permissible before
// seeing a T_FUNCTION. If we hit anything else, the docblock isn't
// attached to something we care about.
case T_DOC_COMMENT:
$this->docblock = $token;
// fall through
// fall through
case T_WHITESPACE:
case T_PUBLIC:
case T_PROTECTED:
case T_PRIVATE:
case T_STATIC:
case T_ABSTRACT:
break;
case Token::SINGLE_CHARACTER:
if ($token->is('{')) {
$this->has_started = true;
$this->depth++;
} elseif ($token->is('}')) {
$this->depth--;
}
break;
case T_FUNCTION:
$this->track = false;
break;
case T_STRING:
if (!$this->has_started) {
$this->name = $token->getValue();
}
// fall through
// fall through
default:
if ($this->track) {
$this->no_op = true;
}
break;
}
if ($this->has_started) {
$this->body[] = $token;
} else {
$this->head[] = $token;
}
return $this;
}
示例3: addToken
public function addToken(Token $token)
{
switch ($token->getType()) {
case T_WHITESPACE:
break;
case T_VARIABLE:
if ($this->current_th) {
} else {
$this->addProvidedTypehint();
}
break;
default:
$this->current_th .= $token;
break;
}
$this->tokens[] = $token;
if ($token->is(',')) {
$this->argno++;
$this->current_th = '';
}
}
示例4: compareType
/**
* @internal
*/
protected function compareType(Token $token, $type)
{
if (!is_array($type)) {
$type = array($type);
}
foreach ($type as $name) {
if ($token->is($name)) {
return true;
}
}
return false;
}