/** * Parses the '--CONFIG--' block of a '.test' file and determines what fixers should be used. * * @param string $config * * @return FixerInterface[] */ protected function determineFixers($config) { $ruleSet = json_decode($config, true); if (JSON_ERROR_NONE !== json_last_error()) { throw new \InvalidArgumentException('Malformed JSON configuration.'); } return FixerFactory::create()->registerBuiltInFixers()->useRuleSet(new RuleSet($ruleSet))->getFixers(); }
/** * @covers PhpCsFixer\FixerFactory::useRuleSet * @expectedException \UnexpectedValueException * @expectedExceptionMessage Rule "non_existing_rule" does not exist. */ public function testUseRuleSetWithNonExistingRule() { $factory = FixerFactory::create()->registerBuiltInFixers()->useRuleSet(new RuleSet(array('non_existing_rule' => true))); $fixers = $factory->getFixers(); $this->assertCount(1, $fixers); $this->assertSame('strict', $fixers[0]->getName()); }
/** * Create fixer factory with all needed fixers registered. * * @return FixerFactory */ protected function createFixerFactory() { return FixerFactory::create()->registerBuiltInFixers(); }
/** * @dataProvider provideConflictingFixersRules * @expectedException \UnexpectedValueException * @expectedExceptionMessageRegExp #^Rule contains conflicting fixers:\n# */ public function testConflictingFixers(RuleSet $ruleSet) { FixerFactory::create()->registerBuiltInFixers()->useRuleSet($ruleSet); }
/** * Parses the '--RULESET--' block of a '.test' file and determines what fixers should be used. * * @param string $config * @param WhitespacesFixerConfig $sharedFixerConfig * * @return FixerInterface[] */ protected function determineFixers($config, WhitespacesFixerConfig $sharedFixerConfig) { return FixerFactory::create()->registerBuiltInFixers()->useRuleSet(new RuleSet($this->parseJson($config)))->setWhitespacesConfig($sharedFixerConfig)->getFixers(); }
/** * @param IntegrationCase $case * * @return FixerInterface[] */ private function createFixers(IntegrationCase $case) { $config = $case->getConfig(); return FixerFactory::create()->registerBuiltInFixers()->useRuleSet($case->getRuleset())->setWhitespacesConfig(new WhitespacesFixerConfig($config['indent'], $config['lineEnding']))->getFixers(); }