当前位置: 首页>>代码示例>>PHP>>正文


PHP Tokens::setCode方法代码示例

本文整理汇总了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);
 }
开发者ID:nazimodi,项目名称:PHP-CS-Fixer,代码行数:17,代码来源:AlignEqualsFixer.php

示例2: fix

 /**
  * {@inheritdoc}
  */
 public function fix(\SplFileInfo $file, Tokens $tokens)
 {
     $tokens->setCode(preg_replace('/^\\h+$/m', '', $tokens->generateCode()));
 }
开发者ID:rafwlaz,项目名称:PHP-CS-Fixer,代码行数:7,代码来源:WhitespacyLinesFixer.php

示例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()));
 }
开发者ID:skillberto,项目名称:PHP-CS-Fixer,代码行数:8,代码来源:LinefeedFixer.php


注:本文中的Symfony\CS\Tokenizer\Tokens::setCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。