コード例 #1
0
 /**
  * Render argv array.
  *
  * @param array $argv
  *
  * @return array
  *
  * @SuppressWarnings(PHPMD.StaticAccess)
  */
 public function __invoke(array $argv)
 {
     $script = array_shift($argv);
     $argv = $this->renderCoverage($argv);
     if (Get::value('sugared.debug', $this->config)) {
         $argv[] = '--sugared-debug';
     }
     if (Get::value('colors', $this->config)) {
         $argv[] = '--colors';
     }
     if ($bootstrap = Get::value('bootstrap', $this->config)) {
         $argv[] = '--bootstrap=' . $bootstrap;
     }
     $positionalArgs = array_filter($argv, function ($arg) {
         return substr($arg, 0, 1) !== '-';
     });
     if (empty($positionalArgs)) {
         $tests = Get::value('tests', $this->config, false);
         if ($tests) {
             $argv[] = $tests;
         }
     }
     array_unshift($argv, $script);
     return $argv;
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  *
  * @SuppressWarnings(PHPMD.StaticAccess)
  */
 public function handleArguments(array $argv)
 {
     parent::handleArguments($argv);
     if (Get::value('sugaredDebug', $this->arguments, false)) {
         $this->logDebug('Parsed arguments', $this->arguments);
     }
     $this->addListeners();
 }
コード例 #3
0
 /**
  * Create a new ComposerExtra.
  *
  * @see https://github.com/schnittstabil/get Documentation of `Schnittstabil\Get\getValue`
  *
  * @param string|int|mixed[] $namespace     a `Schnittstabil\Get\getValue` path
  * @param mixed              $defaultConfig default configuration
  * @param string             $presetsPath   presets path (w/o namespace)
  *
  * @throws \KHerGe\File\Exception\FileException
  * @throws \Seld\JsonLint\ParsingException
  *
  * @SuppressWarnings(PHPMD.StaticAccess)
  */
 public function __construct($namespace = array(), $defaultConfig = null, $presetsPath = null)
 {
     $this->namespace = Get::normalizePath($namespace);
     array_unshift($this->namespace, 'extra');
     $this->defaultConfig = $defaultConfig === null ? new \stdClass() : $defaultConfig;
     $this->presetsPath = $presetsPath;
     $this->composerJson = jsonDecodeFile('composer.json');
 }
コード例 #4
0
 /**
  * @SuppressWarnings(PHPMD.StaticAccess)
  */
 public function __invoke(stdClass $config)
 {
     $next = $this->next;
     $filter = Get::value('filter', $config);
     unset($config->filter);
     if (empty($filter)) {
         return $next($config);
     }
     $sami = $next($config);
     $sami['filter'] = function () use($filter) {
         return new $filter();
     };
     return $sami;
 }
コード例 #5
0
 /**
  * @SuppressWarnings(PHPMD.StaticAccess)
  */
 public function __invoke($namespace)
 {
     $composerConfig = $this->getComposerConfig($namespace);
     $config = new Config();
     $config->diff = Get::value('diff', $composerConfig, false);
     $config->{'dry-run'} = Get::value('dry-run', $composerConfig, false);
     $config->setUsingCache(Get::value('cache', $composerConfig, false));
     $path = Get::value('path', $composerConfig);
     if (!empty($path)) {
         $finderByConfig = new FinderByConfig();
         $config->finder($finderByConfig($path));
     }
     return $config;
 }
コード例 #6
0
 /**
  * @SuppressWarnings(PHPMD.StaticAccess)
  */
 protected function parseOptionalOptionValue(&$input, $name, $default)
 {
     if (count($input->getOption($name)) === 0) {
         // no option; use default
         $input->setOption($name, Get::value($name, $this->defaultConfig, $default));
         return;
     }
     $values = $input->getOption($name);
     $value = end($values);
     if ($value === null) {
         // option w/o value
         $value = true;
     }
     $input->setOption($name, filter_var($value, FILTER_VALIDATE_BOOLEAN));
 }