本文整理汇总了PHP中Symfony\CS\Tokenizer\Tokens::setCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Tokens::setCode方法的具体用法?PHP Tokens::setCode怎么用?PHP Tokens::setCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\CS\Tokenizer\Tokens
的用法示例。
在下文中一共展示了Tokens::setCode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fix
/**
* {@inheritdoc}
*/
public function fix(\SplFileInfo $file, Tokens $tokens)
{
$this->deepestLevel = 0;
// This fixer works partially on Tokens and partially on string representation of code.
// During the process of fixing internal state of single Token may be affected by injecting ALIGNABLE_PLACEHOLDER to its content.
// The placeholder will be resolved by `replacePlaceholder` method by removing placeholder or changing it into spaces.
// That way of fixing the code causes disturbances in marking Token as changed - if code is perfectly valid then placeholder
// still be injected and removed, which will cause the `changed` flag to be set.
// To handle that unwanted behavior we work on clone of Tokens collection and then override original collection with fixed collection.
$tokensClone = clone $tokens;
$this->injectAlignmentPlaceholders($tokensClone);
$content = $this->replacePlaceholder($tokensClone);
$tokens->setCode($content);
}
示例2: fix
/**
* {@inheritdoc}
*/
public function fix(\SplFileInfo $file, Tokens $tokens)
{
$tokens->setCode(preg_replace('/^\\h+$/m', '', $tokens->generateCode()));
}
示例3: fix
/**
* {@inheritdoc}
*/
public function fix(\SplFileInfo $file, Tokens $tokens)
{
// [Structure] Use the linefeed character (0x0A) to end lines
$tokens->setCode(str_replace("\r\n", "\n", $tokens->generateCode()));
}