Esempio n. 1
1
 public function run()
 {
     $params = array('help' => true, 'version' => 'php-auto-format 0.1');
     $args = \Docopt::handle(get_doc(), $params);
     if (isset($args['<filepath>'])) {
         $filepath = $args['<filepath>'];
         if (!file_exists($filepath)) {
             die("File {$filepath} does not exist\n");
         }
         $out = $this->formatter->parseFile($filepath);
         if ($args['--inplace']) {
             $handler = fopen($filepath, 'w+');
             fwrite($handler, $out);
             fclose($handler);
         } else {
             echo $out;
         }
     }
 }
Esempio n. 2
0
 public function run(\PHPUnit_Framework_TestResult $result = null)
 {
     if (!$result) {
         $result = new \PHPUnit_Framework_TestResult();
     }
     $opt = null;
     \PHP_Timer::start();
     $result->startTest($this);
     try {
         $opt = \Docopt::handle($this->doc, array('argv' => $this->argv, 'exit' => false));
     } catch (\Exception $ex) {
         // gulp
     }
     $found = null;
     if ($opt) {
         if (!$opt->success) {
             $found = array('user-error');
         } elseif (empty($opt->args)) {
             $found = array();
         } else {
             $found = $opt->args;
         }
     }
     $time = \PHP_Timer::stop();
     try {
         \PHPUnit_Framework_Assert::assertEquals($this->expect, $found);
     } catch (\PHPUnit_Framework_AssertionFailedError $e) {
         $result->addFailure($this, $e, $time);
     }
     $result->endTest($this, $time);
     return $result;
 }
Esempio n. 3
0
function main()
{
    $args = \Docopt::handle(<<<s
A PHP class autoload generator with support for functions and constants.

Example:

    generate-autoload src/autoload.php

        Will write an autoloader for everything in "src/" to "src/autoload.php".

    generate-autoload autoload.php src --exclude src/Bar lib/functions.php

        Will write to an autoloader for everything in "src/" and
        "lib/functions.php", except for everything in "src/Bar", to "autoload.php".

Usage:
    generate-autoload [options] <outfile> [<files>...] [--exclude <file>]...
    generate-autoload -h|--help

Options:
    --require-method=<method>  One of "include", "require", "include_once" or
                               "require_once". [default: require_once]
    --case-insensitive         Autoload classes case insensitively. Will involve
                               a strtolower() call every time a class is loaded.
    --prepend                  Third parameter to spl_autoload_register().
    --exclude <file>           Exclude a file/directory.

s
);
    $outFile = $args['<outfile>'];
    $files = array_diff(iterator_to_array(flatten_input_paths($args['<files>'] ?: [dirname($outFile)])), iterator_to_array(flatten_input_paths($args['--exclude'])));
    global $argv;
    $options = new GeneratorOptions();
    $options->requireMethod = $args['--require-method'];
    $options->prependAutoload = $args['--prepend'];
    $options->caseInsensitive = $args['--case-insensitive'];
    $options->generatedBy = join(' ', $argv);
    $generator = new Generator();
    foreach ($files as $file) {
        print "Scanning {$file}\n";
        $generator->addFile($file);
    }
    print "\n";
    file_put_contents($outFile, $generator->generate(dirname($outFile), $options));
    print "Output written to {$outFile}\n";
}
 public static function main(array $argv)
 {
     $args = \Docopt::handle(self::DOC, array('argv' => \array_slice($argv, 1)));
     $self = new self($args['<outfile>']);
     $self->generatedBy = \join(' ', \array_map('escapeshellarg', $argv));
     $self->followSymlinks = $args['--follow-symlinks'];
     $self->requireMethod = $args['--require-method'];
     $self->prependAutoload = $args['--prepend'];
     $self->caseInsensitive = $args['--case-insensitive'];
     $self->useHack = $args['--hack'];
     $self->noCache = $args['--no-cache'];
     if (isset($args['--cache-path'])) {
         $self->cachePath = $args['--cache-path'];
     }
     $files = $self->flattenInputPaths($args['<files>'] ?: array($self->baseDir));
     // Remove excluded files
     $files = \array_diff($files, $self->flattenInputPaths($args['--exclude']));
     // Ignore the output file
     $files = \array_diff($files, array(\realpath($self->outFile)));
     $scanner = new RealFileScanner();
     if (!$self->noCache) {
         $scanner = CachingFileScanner::create($self->cachePath, $scanner);
     }
     foreach ($files as $file) {
         $parsed = $scanner->scanFile($file);
         if ($parsed->getConstants() || $parsed->getFunctions()) {
             $self->eagerFiles[] = $file;
         }
         foreach ($parsed->getClasses() as $class) {
             $self->classMap[$class] = $file;
         }
     }
     $scanner->finish();
     print "Writing autoloader to {$self->outFile}\n";
     \file_put_contents($self->outFile, $self->generate());
 }
Esempio n. 5
0
function main()
{
    $args = \Docopt::handle(<<<'s'
Usage:
  bugsnag-csv-export PATH [options]

Options:
  --token=AUTH_TOKEN     Authorization token
  --username=AUTH_USER   Authorization username
  --password=AUTH_PASS   Authorization password
  --save=PATH            Save output to the specified file instead of stdout [default: php://output]
  --limit=LIMIT          Maximum number of rows [default: 1000]
s
);
    $client = new BugsnagAPI($args['--token'], $args['--username'], $args['--password']);
    file_put_contents($args['--save'], to_csv($client->get($args['PATH'], $args['--limit'])));
}
Esempio n. 6
0
use Jimdo\Payment\Billing\ReplayAndCompare\Compare;
use Jimdo\Payment\Billing\ReplayAndCompare\ServiceProvider;
require_once __DIR__ . '/../vendor/autoload.php';
$app = new Silex\Application();
$serviceProvider = new ServiceProvider();
$app->register($serviceProvider);
$serviceProvider->boot($app);
/** @var Compare compare */
$compare = $app['compare'];
$doc = <<<DOC
COMPAAAARE

Usage:
  compare.php <zuoraAccountId> <billingServiceAccountId>

Options:
  -h --help                 Show this screen.
  zuoraAccountId            Id of the account in Zuora
  billingServiceAccountId   Id of the account in the Billing Service
DOC;
$args = Docopt::handle($doc);
$zuoraAccountId = $args['<zuoraAccountId>'];
$billingServiceAccountId = $args['<billingServiceAccountId>'];
$result = $compare($zuoraAccountId, $billingServiceAccountId);
if (!$result->equal()) {
    echo "The accounts '{$zuoraAccountId}' and '{$billingServiceAccountId}' are different:\n";
    echo json_encode($result->diff(), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
    exit(1);
}
echo "The accounts '{$zuoraAccountId}' and '{$billingServiceAccountId}' are equal.\n";