本文整理匯總了PHP中Symfony\CS\Tokenizer\Tokens::isLambda方法的典型用法代碼示例。如果您正苦於以下問題:PHP Tokens::isLambda方法的具體用法?PHP Tokens::isLambda怎麽用?PHP Tokens::isLambda使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\CS\Tokenizer\Tokens
的用法示例。
在下文中一共展示了Tokens::isLambda方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: replaceNameOccurrences
private function replaceNameOccurrences(Tokens $tokens, $name, $startIndex, $endIndex)
{
for ($i = $startIndex; $i < $endIndex; ++$i) {
$token = $tokens[$i];
if ($token->isGivenKind(T_FUNCTION) && $tokens->isLambda($i)) {
$i = $tokens->getNextTokenOfKind($i, array('{'));
$i = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $i);
continue;
}
if (!$token->equals(array(T_STRING, $name), false)) {
continue;
}
$prevToken = $tokens[$tokens->getPrevMeaningfulToken($i)];
$nextToken = $tokens[$tokens->getNextMeaningfulToken($i)];
if ($prevToken->isGivenKind(T_NS_SEPARATOR) || $nextToken->isGivenKind(T_NS_SEPARATOR)) {
continue;
}
if (
$prevToken->isGivenKind(array(T_INSTANCEOF, T_NEW)) ||
$nextToken->isGivenKind(T_PAAMAYIM_NEKUDOTAYIM)
) {
$token->setContent('self');
}
}
}
示例2: fixLambdas
private function fixLambdas(Tokens $tokens)
{
for ($index = $tokens->count() - 1; 0 <= $index; --$index) {
$token = $tokens[$index];
if (!$token->isGivenKind(T_FUNCTION) || !$tokens->isLambda($index)) {
continue;
}
$nextIndex = $tokens->getNextTokenOfKind($index, array('{'));
$tokens->ensureWhitespaceAtIndex($nextIndex - 1, 1, ' ');
}
}
示例3: fixLambdas
private function fixLambdas(Tokens $tokens)
{
for ($index = $tokens->count() - 1; 0 <= $index; --$index) {
$token = $tokens[$index];
if (!$token->isGivenKind(T_FUNCTION) || !$tokens->isLambda($index)) {
continue;
}
$braceIndex = $tokens->getNextTokenOfKind($index, array('{'));
$commentIndex = $tokens->getPrevNonWhitespace($braceIndex);
$comment = $tokens[$commentIndex];
if ($comment->isGivenKind(T_COMMENT) && '/*' !== substr($comment->getContent(), 0, 2)) {
$commentPrototype = $comment->getPrototype();
$commentPrototype[1] = rtrim($commentPrototype[1]);
$tokens[$commentIndex]->override($tokens[$braceIndex]->getPrototype());
$tokens[$braceIndex]->override($commentPrototype);
$braceIndex = $commentIndex;
if ($tokens[$commentIndex + 1]->isWhitespace()) {
$tokens[$commentIndex + 1]->clear();
}
}
$tokens->ensureWhitespaceAtIndex($braceIndex - 1, 1, ' ');
}
}