getRules() public method

Keys of array are names of fixers/sets, values are true/false.
public getRules ( ) : array
return array
コード例 #1
0
ファイル: Runner.php プロジェクト: thekabal/tki
 /**
  * @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();
 }
コード例 #2
0
 /**
  * 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;
 }
コード例 #3
0
 /**
  * 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;
 }
コード例 #4
0
ファイル: Fixer.php プロジェクト: cryode/PHP-CS-Fixer
 /**
  * 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;
 }
コード例 #5
0
ファイル: Fixer.php プロジェクト: SEOshop/PHP-CS-Fixer
 /**
  * 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;
 }