Beispiel #1
0
#!/usr/bin/php
<?php 
require_once 'PHP/Beautifier.php';
// Create the instance
$oBeautifier = new PHP_Beautifier();
echo "Filter Directory: " . dirname(__FILE__) . '/beautifier_filters' . "\n";
$oBeautifier->addFilterDirectory(dirname(__FILE__) . '/beautifier_filters');
// Add a filter, without any parameter
$oBeautifier->addFilter('TTDefault');
// Set the indent char, number of chars to indent and newline char
$oBeautifier->setIndentChar(' ');
$oBeautifier->setIndentNumber(4);
$oBeautifier->setNewLine("\n");
// Define the input file
$oBeautifier->setInputFile($argv[1]);
// Define an output file.
//$oBeautifier->setOutputFile( $argv[1] .'.beautified.php');
$oBeautifier->setOutputFile($argv[1]);
// Process the file. DONT FORGET TO USE IT
$oBeautifier->process();
// Show the file (echo to screen)
//$oBeautifier->show();
// Save the file
$oBeautifier->save();
    $constructorcode .= "    \$directory = dirname(__FILE__).DIRECTORY_SEPARATOR;\n";
    $constructorcode .= "    foreach(\$options['classmap'] as \$key => \$value) if(file_exists('{\$directory}../structures/{\$value}.php')) include_once('{\$directory}../structures/{\$value}.php');\n";
    $constructorcode .= "    parent::__construct(\$wsdl, \$options);";
    $aliascode = <<<EOD
class_alias("{$serviceName}", "{$oldServiceName}");
?>

EOD;
    $file = str_replace($oldServiceName, $serviceName, $file);
    $file = str_replace("parent::__construct(\$wsdl, \$options);", $constructorcode, $file);
    $file = str_replace("?>", $aliascode, $file);
    file_put_contents($serviceFile, $file);
    rename($serviceFile, "splitteroutput/services/{$serviceName}.php");
    file_put_contents("splitteroutput/services/{$oldServiceName}.php", "<?php include_once(\"{$serviceName}.php\"); ?>\n");
}
foreach (glob("splitteroutput/*.php") as $structureFile) {
    rename($structureFile, "splitteroutput/structures/" . basename($structureFile));
}
include_once "PHP/Beautifier.php";
if (class_exists('PHP_Beautifier')) {
    $beautifier = new PHP_Beautifier();
    $beautifier->addFilter('ArrayNested');
    $beautifier->setIndentChar("\t");
    $beautifier->setIndentNumber(1);
    foreach (glob("splitteroutput/*/*.php") as $file) {
        $beautifier->setInputFile($file);
        $beautifier->setOutputFile($file);
        $beautifier->process();
        $beautifier->save();
    }
}