public registerFixer ( PhpCsFixer\Fixer\FixerInterface $fixer, boolean $isCustom ) | ||
$fixer | PhpCsFixer\Fixer\FixerInterface | |
$isCustom | boolean |
public function registerFixer(FixerInterface $fixer, $isCustom)
{
$name = $fixer->getName();
if (isset($this->fixersByName[$name])) {
throw new \UnexpectedValueException(sprintf('Fixer named "%s" is already registered.', $name));
}
if (!$this->nameValidator->isValid($name, $isCustom)) {
throw new \UnexpectedValueException(sprintf('Fixer named "%s" has invalid name.', $name));
}
$this->fixers[] = $fixer;
$this->fixersByName[$name] = $fixer;
return $this;
}
public function testHasRuleWithChangedRuleSet() { $factory = new FixerFactory(); $f1 = $this->createFixerMock('f1'); $f2 = $this->createFixerMock('f2'); $factory->registerFixer($f1); $factory->registerFixer($f2); $this->assertTrue($factory->hasRule('f1'), 'Should have f1 fixer'); $this->assertTrue($factory->hasRule('f2'), 'Should have f2 fixer'); $factory->useRuleSet(new RuleSet(array('f2' => true))); $this->assertFalse($factory->hasRule('f1'), 'Should not have f1 fixer'); $this->assertTrue($factory->hasRule('f2'), 'Should have f2 fixer'); }