setCode() public method

Set code. Clear all current content and replace it by new Token items generated from code directly.
public setCode ( string $code )
$code string PHP code
 /**
  * {@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)
 {
     // [Structure] Use the UNIX line ending character (0x0A) to end lines
     $tokens->setCode(str_replace("\r\n", "\n", $tokens->generateCode()));
 }