/**
  * {@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);
 }
 /**
  * {@inheritdoc}
  */
 public function fix(\SplFileInfo $file, Tokens $tokens)
 {
     $tokens->setCode(preg_replace('/^\\h+$/m', '', $tokens->generateCode()));
 }
示例#3
0
 /**
  * {@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()));
 }
 /**
  * {@inheritdoc}
  */
 public function fix(\SplFileInfo $file, Tokens $tokens)
 {
     // [Structure] Don't add trailing spaces at the end of non-blank lines
     $tokens->setCode(preg_replace('/(?<=\\S)[ \\t]+$/m', '', $tokens->generateCode()));
 }