getRules() public method

Keys of array are names of fixers/sets, values are true/false.
public getRules ( ) : array
return array
Exemplo n.º 1
0
 /**
  * @param ConfigInterface $config
  * @param bool            $isDryRun
  *
  * @return CacheManagerInterface
  */
 private function createCacheManager(ConfigInterface $config, $isDryRun)
 {
     if ($config->usingCache() && (ToolInfo::isInstalledAsPhar() || ToolInfo::isInstalledByComposer())) {
         return new FileCacheManager(new FileHandler($config->getCacheFile()), new Signature(PHP_VERSION, ToolInfo::getVersion(), $config->usingLinter(), $config->getRules()), $isDryRun);
     }
     return new NullCacheManager();
 }
 /**
  * Compute rules.
  *
  * @return array
  */
 private function parseRules()
 {
     if (null === $this->options['rules']) {
         return $this->config->getRules();
     }
     $rules = array();
     foreach (array_map('trim', explode(',', $this->options['rules'])) as $rule) {
         if ('-' === $rule[0]) {
             $rules[ltrim($rule, '-')] = false;
         } else {
             $rules[$rule] = true;
         }
     }
     return $rules;
 }
 /**
  * Compute rules.
  *
  * @return array
  */
 private function parseRules()
 {
     if (null === $this->options['rules']) {
         return $this->config->getRules();
     }
     $rules = array();
     foreach (array_map('trim', explode(',', $this->options['rules'])) as $rule) {
         if ('' === $rule) {
             throw new InvalidConfigurationException('Empty rule name is not allowed.');
         }
         if ('-' === $rule[0]) {
             $rules[substr($rule, 1)] = false;
         } else {
             $rules[$rule] = true;
         }
     }
     return $rules;
 }
Exemplo n.º 4
0
 /**
  * Fixes all files for the given finder.
  *
  * @param ConfigInterface $config A ConfigInterface instance
  * @param bool            $dryRun Whether to simulate the changes or not
  * @param bool            $diff   Whether to provide diff
  *
  * @return array
  */
 public function fix(ConfigInterface $config, $dryRun = false, $diff = false)
 {
     $changed = array();
     $fixers = $config->getFixers();
     $this->stopwatch->openSection();
     $fileCacheManager = new FileCacheManager($config->usingCache(), $config->getCacheFile(), $config->getRules());
     foreach ($config->getFinder() as $file) {
         if ($file->isDir() || $file->isLink()) {
             continue;
         }
         $name = $this->getFileRelativePathname($file);
         $this->stopwatch->start($name);
         if ($fixInfo = $this->fixFile($file, $fixers, $dryRun, $diff, $fileCacheManager)) {
             $changed[$name] = $fixInfo;
         }
         $this->stopwatch->stop($name);
     }
     $this->stopwatch->stopSection('fixFile');
     return $changed;
 }
Exemplo n.º 5
0
 /**
  * Fixes all files for the given finder.
  *
  * @param ConfigInterface $config A ConfigInterface instance
  * @param bool            $dryRun Whether to simulate the changes or not
  * @param bool            $diff   Whether to provide diff
  *
  * @return array
  */
 public function fix(ConfigInterface $config, $dryRun = false, $diff = false)
 {
     $changed = array();
     $fixers = $config->getFixers();
     $this->stopwatch->openSection();
     $fileCacheManager = new FileCacheManager($config->usingCache(), $config->getCacheFile(), $config->getRules());
     $finder = $config->getFinder();
     $finderIterator = $finder instanceof \IteratorAggregate ? $finder->getIterator() : $finder;
     foreach (new UniqueFileIterator($finderIterator) as $file) {
         $name = $this->getFileRelativePathname($file);
         $this->stopwatch->start($name);
         if ($fixInfo = $this->fixFile($file, $fixers, $dryRun, $diff, $fileCacheManager)) {
             $changed[$name] = $fixInfo;
         }
         $this->stopwatch->stop($name);
     }
     $this->stopwatch->stopSection('fixFile');
     return $changed;
 }