Exemplo n.º 1
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
if (empty($argv) || !is_array($argv) || 2 > count($argv)) {
    $input = file_get_contents('php://stdin');
} else {
    $input = file_get_contents($argv[1]);
}
$phpStringCleaner = new \PHPCleanup\StringCleaner();
echo $phpStringCleaner->magic($input);
Exemplo n.º 2
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
$string = file_get_contents(realpath(__FILE__));
$phpStringCleaner = new \PHPCleanup\StringCleaner();
$codeOnly = $phpStringCleaner->setOriginalString($string);
$a = array('a' => 'foo');
$b = "bar";
$testString = "foo {$a['a']} bar" . "baz {$b} monkey" . 'pirate "ninja" lion' . "zombie 'samurai' wolf";
$testString .= <<<EOF
    wibble unicorn bigfoot
EOF;
ob_start();
?>
WTF SON? IS THE BROOKLYN ZOO IN THE MF HOUSE?
<?php 
ob_get_clean();
$phpStringCleaner->reindent();
echo $phpStringCleaner->getCleanedString();
Exemplo n.º 3
0
#!/usr/bin/env php
<?php 
require_once __DIR__ . '/../vendor/autoload.php';
if (empty($argv) || !is_array($argv) || 2 > count($argv)) {
    echo "You must supply a file to clean\n";
    die;
}
foreach (array_slice($argv, 1) as $filename) {
    $phpStringCleaner = new \PHPCleanup\StringCleaner();
    $input = file_get_contents($filename);
    $output = $phpStringCleaner->magic($input);
    if ($input != $output) {
        $backup = $filename . '.bak';
        echo "Changed {$filename}\n";
        file_put_contents($backup, $input) && file_put_contents($filename, $output);
    }
}