private static function rewriteContents($orig_file, $target_file, $contents) { $traverser = new \PhpParser\NodeTraverser(); $traverser->addVisitor(new SoftMocksTraverser($orig_file)); $prettyPrinter = new SoftMocksPrinter(); $parser = (new \PhpParser\ParserFactory())->create(\PhpParser\ParserFactory::PREFER_PHP7); $stmts = $parser->parse($contents); $stmts = $traverser->traverse($stmts); return $prettyPrinter->prettyPrintFile($stmts); }