本文整理汇总了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;
}