Exemple #1
0
 /**
  * @param FixerInterface $fixer
  *
  * @return bool
  */
 private function isFixerConfigurable(FixerInterface $fixer)
 {
     try {
         $fixer->configure(array());
         return true;
     } catch (UnallowedFixerConfigurationException $e) {
         return false;
     } catch (\Exception $e) {
         return true;
     }
 }
 /**
  * {@inheritdoc}
  */
 public function fix(\SplFileInfo $file, Tokens $tokens)
 {
     $this->proxyFixer->fix($file, $tokens);
 }
 /**
  * @dataProvider getFixersPriorityCases
  */
 public function testFixersPriority(FixerInterface $first, FixerInterface $second)
 {
     $this->assertLessThan($first->getPriority(), $second->getPriority());
 }
Exemple #4
0
 /**
  * @param FixerInterface $fixer
  *
  * @return string[]|null
  */
 private function getFixersConflicts(FixerInterface $fixer)
 {
     static $conflictMap = array('short_array_syntax' => array('long_array_syntax'), 'align_double_arrow' => array('unalign_double_arrow'), 'align_equals' => array('unalign_equals'), 'concat_with_spaces' => array('concat_without_spaces'), 'echo_to_print' => array('print_to_echo'), 'no_blank_lines_before_namespace' => array('single_blank_line_before_namespace'), 'phpdoc_type_to_var' => array('phpdoc_var_to_type'));
     $fixerName = $fixer->getName();
     return array_key_exists($fixerName, $conflictMap) ? $conflictMap[$fixerName] : array();
 }
 /**
  * Register fixer.
  *
  * @param FixerInterface $fixer
  *
  * @return $this
  */
 public function registerFixer(FixerInterface $fixer)
 {
     $name = $fixer->getName();
     if (isset($this->fixersByName[$name])) {
         throw new \UnexpectedValueException(sprintf('Fixer named "%s" is already registered.', $name));
     }
     $this->fixers[] = $fixer;
     $this->fixersByName[$name] = $fixer;
     return $this;
 }
Exemple #6
0
 /**
  * @dataProvider provideFixersDescriptionConsistencyCases
  */
 public function testFixersDescriptionConsistency(FixerInterface $fixer)
 {
     $this->assertRegExp('/^[A-Z@].*\\.$/', $fixer->getDescription(), 'Description must start with capital letter or an @ and end with dot.');
 }