Ejemplo n.º 1
0
		if($a){
			noop();
		}
		break;

		case 2:
			noop();
		break;
	}
}

if($a)
	noop3();
';
$fmt = new CodeFormatter();
$fmt->addPass(new TwoCommandsInSameLine());
$fmt->addPass(new RemoveIncludeParentheses());
$fmt->addPass(new NormalizeIsNotEquals());
$fmt->addPass(new OrderUseClauses());
$fmt->addPass(new AddMissingCurlyBraces());
$fmt->addPass(new ExtraCommaInArray());
$fmt->addPass(new NormalizeLnAndLtrimLines());
$fmt->addPass(new MergeParenCloseWithCurlyOpen());
$fmt->addPass(new MergeCurlyCloseAndDoWhile());
$fmt->addPass(new MergeDoubleArrowAndArray());
$fmt->addPass(new ResizeSpaces());
$fmt->addPass(new Tree());
$fmt->addPass(new ReindentColonBlocks());
$fmt->addPass(new ReindentLoopColonBlocks());
$fmt->addPass(new ReindentIfColonBlocks());
$fmt->addPass(new ReindentObjOps());
Ejemplo n.º 2
0
     echo PHP_EOL, 'If <target> is blank, it reads from stdin', PHP_EOL;
     die;
 }
 if (isset($opts['from']) && !isset($opts['to'])) {
     fwrite(STDERR, 'Refactor must have --from and --to parameters' . PHP_EOL);
     exit(255);
 }
 $debug = false;
 $fmt = new CodeFormatter($debug);
 if (isset($opts['from']) && isset($opts['to'])) {
     $argv = array_values(array_filter($argv, function ($v) {
         $param_from = '--from';
         $param_to = '--to';
         return substr($v, 0, strlen($param_from)) !== $param_from && substr($v, 0, strlen($param_to)) !== $param_to;
     }));
     $fmt->addPass(new RefactorPass($opts['from'], $opts['to']));
 }
 if (isset($opts['o'])) {
     unset($argv[1]);
     unset($argv[2]);
     $argv = array_values($argv);
     file_put_contents($opts['o'], $fmt->formatCode(file_get_contents($argv[1])));
 } elseif (isset($argv[1]) && is_file($argv[1])) {
     echo $fmt->formatCode(file_get_contents($argv[1]));
 } elseif (isset($argv[1]) && is_dir($argv[1])) {
     $dir = new RecursiveDirectoryIterator($argv[1]);
     $it = new RecursiveIteratorIterator($dir);
     $files = new RegexIterator($it, '/^.+\\.php$/i', RecursiveRegexIterator::GET_MATCH);
     foreach ($files as $file) {
         $file = $file[0];
         echo $file;
Ejemplo n.º 3
0
 public static function decorate(CodeFormatter $fmt)
 {
     $fmt->addPass(new PSR1OpenTags());
     $fmt->addPass(new PSR1BOMMark());
     $fmt->addPass(new PSR1ClassNames());
     $fmt->addPass(new PSR1ClassConstants());
     $fmt->addPass(new PSR1MethodNames());
     $fmt->addPass(new PSR2IndentWithSpace());
     $fmt->addPass(new PSR2LnAfterNamespace());
     $fmt->addPass(new PSR2CurlyOpenNextLine());
     $fmt->addPass(new PSR2ModifierVisibilityStaticOrder());
     $fmt->addPass(new PSR2SingleEmptyLineAndStripClosingTag());
 }