registerCustomFixers() публичный Метод

Register fixers.
public registerCustomFixers ( array $fixers )
$fixers array
 /**
  * Resolve configuration.
  *
  * @return ConfigurationResolver
  */
 public function resolve()
 {
     $this->resolvePath();
     $this->resolveIsStdIn();
     $this->resolveIsDryRun();
     $this->resolveFormat();
     $this->resolveConfig();
     $this->resolveConfigPath();
     $this->resolveRiskyAllowed();
     $this->fixerFactory->registerCustomFixers($this->getConfig()->getCustomFixers());
     $this->fixerFactory->attachConfig($this->getConfig());
     $this->resolveRules();
     $this->resolveFixers();
     $this->resolveProgress();
     $this->resolveUsingCache();
     $this->resolveCacheFile();
     $this->config->fixers($this->getFixers());
     $this->config->setRules($this->getRules());
     $this->config->setUsingCache($this->usingCache);
     $this->config->setCacheFile($this->cacheFile);
     $this->config->setRiskyAllowed($this->allowRisky);
     return $this;
 }
Пример #2
0
 public function testHasRule()
 {
     $factory = new FixerFactory();
     $f1 = $this->createFixerMock('f1');
     $f2 = $this->createFixerMock('f2');
     $f3 = $this->createFixerMock('f3');
     $factory->registerFixer($f1);
     $factory->registerCustomFixers(array($f2, $f3));
     $this->assertTrue($factory->hasRule('f1'), 'Should have f1 fixer');
     $this->assertTrue($factory->hasRule('f2'), 'Should have f2 fixer');
     $this->assertTrue($factory->hasRule('f3'), 'Should have f3 fixer');
     $this->assertFalse($factory->hasRule('dummy'), 'Should not have dummy fixer');
 }
Пример #3
0
 /**
  * Returns fixers.
  *
  * @return FixerInterface[] An array of FixerInterface
  */
 public function getFixers()
 {
     if (null === $this->fixers) {
         $fixerFactory = new FixerFactory();
         $fixerFactory->registerBuiltInFixers();
         $fixerFactory->registerCustomFixers($this->getConfig()->getCustomFixers());
         $this->fixers = $fixerFactory->useRuleSet($this->getRuleSet())->setWhitespacesConfig(new WhitespacesFixerConfig($this->config->getIndent(), $this->config->getLineEnding()))->getFixers();
         if (false === $this->getRiskyAllowed()) {
             $riskyFixers = array_map(function (FixerInterface $fixer) {
                 return $fixer->getName();
             }, array_filter($this->fixers, function (FixerInterface $fixer) {
                 return $fixer->isRisky();
             }));
             if (count($riskyFixers)) {
                 throw new InvalidConfigurationException(sprintf('The rules contain risky fixers (%s), but they are not allowed to run. Perhaps you forget to use --allow-risky option?', implode(', ', $riskyFixers)));
             }
         }
     }
     return $this->fixers;
 }