本文整理匯總了PHP中Symfony\CS\Tokenizer\Token::getPrototype方法的典型用法代碼示例。如果您正苦於以下問題:PHP Token::getPrototype方法的具體用法?PHP Token::getPrototype怎麽用?PHP Token::getPrototype使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\CS\Tokenizer\Token
的用法示例。
在下文中一共展示了Token::getPrototype方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: equals
/**
* Check if token is equals to given one.
*
* If tokens are arrays, then only keys defined in parameter token are checked.
*
* @param Token|array|string $other token or it's prototype
* @param bool $caseSensitive perform a case sensitive comparison
*
* @return bool
*/
public function equals($other, $caseSensitive = true)
{
$otherPrototype = $other instanceof Token ? $other->getPrototype() : $other;
if ($this->isArray() !== is_array($otherPrototype)) {
return false;
}
if (!$this->isArray()) {
return $this->content === $otherPrototype;
}
$selfPrototype = $this->getPrototype();
foreach ($otherPrototype as $key => $val) {
// make sure the token has such key
if (!isset($selfPrototype[$key])) {
return false;
}
if (1 === $key && !$caseSensitive) {
// case-insensitive comparison only applies to the content (key 1)
if (0 !== strcasecmp($val, $selfPrototype[1])) {
return false;
}
} else {
// regular comparison
if ($selfPrototype[$key] !== $val) {
return false;
}
}
}
return true;
}
示例2: fromBaseToken
public static function fromBaseToken(BaseToken $token)
{
$extended = new self($token->getPrototype());
if ($token->isChanged()) {
$extended->setContent('__CHANGE_HOLDER__' . $token->getContent());
$extended->setContent($token->getContent());
}
return $extended;
}
示例3: override
/**
* Override token.
*
* If called on Token inside Tokens collection please use `Tokens::overrideAt` instead.
*
* @param Token|array|string $other token prototype
*/
public function override($other)
{
$prototype = $other instanceof self ? $other->getPrototype() : $other;
if ($this->equals($prototype)) {
return;
}
$this->changed = true;
if (is_array($prototype)) {
$this->isArray = true;
$this->id = $prototype[0];
$this->content = $prototype[1];
return;
}
$this->isArray = false;
$this->id = null;
$this->content = $prototype;
}