Browse Source

minor #6273 Add priority test (SpacePossum)

This PR was merged into the master branch.

Discussion
----------

Add priority test

Commits
-------

7bdb9a27b Add priority test
SpacePossum 3 years ago
parent
commit
db4b9970db

+ 1 - 1
src/Console/Output/ProcessOutput.php

@@ -72,7 +72,7 @@ final class ProcessOutput implements ProcessOutputInterface
         $this->eventDispatcher->addListener(FixerFileProcessedEvent::NAME, [$this, 'onFixerFileProcessed']);
         $this->files = $nbFiles;
 
-        //   max number of characters per line
+        // max number of characters per line
         // - total length x 2 (e.g. "  1 / 123" => 6 digits and padding spaces)
         // - 11               (extra spaces, parentheses and percentage characters, e.g. " x / x (100%)")
         $this->symbolsPerLine = max(1, $width - \strlen((string) $this->files) * 2 - 11);

+ 1 - 1
src/Fixer/CastNotation/ModernizeTypesCastingFixer.php

@@ -101,7 +101,7 @@ final class ModernizeTypesCastingFixer extends AbstractFunctionReferenceFixer
                 $countParamTokens = 0;
 
                 for ($paramContentIndex = $openParenthesis + 1; $paramContentIndex < $paramContentEnd; ++$paramContentIndex) {
-                    //not a space, means some sensible token
+                    // not a space, means some sensible token
                     if (!$tokens[$paramContentIndex]->isGivenKind(T_WHITESPACE)) {
                         ++$countParamTokens;
                     }

+ 1 - 1
src/Fixer/Comment/SingleLineCommentStyleFixer.php

@@ -105,7 +105,7 @@ $c = 3;
     /**
      * {@inheritdoc}
      *
-     * Must run after HeaderCommentFixer, NoUselessReturnFixer.
+     * Must run after HeaderCommentFixer, NoUselessReturnFixer, PhpdocToCommentFixer.
      */
     public function getPriority(): int
     {

+ 1 - 1
src/Fixer/Phpdoc/PhpdocAlignFixer.php

@@ -154,7 +154,7 @@ EOF;
     /**
      * {@inheritdoc}
      *
-     * Must run after AlignMultilineCommentFixer, CommentToPhpdocFixer, CommentToPhpdocFixer, GeneralPhpdocAnnotationRemoveFixer, GeneralPhpdocTagRenameFixer, NoBlankLinesAfterPhpdocFixer, NoEmptyPhpdocFixer, NoSuperfluousPhpdocTagsFixer, PhpdocAddMissingParamAnnotationFixer, PhpdocAddMissingParamAnnotationFixer, PhpdocAnnotationWithoutDotFixer, PhpdocIndentFixer, PhpdocIndentFixer, PhpdocInlineTagNormalizerFixer, PhpdocLineSpanFixer, PhpdocNoAccessFixer, PhpdocNoAliasTagFixer, PhpdocNoEmptyReturnFixer, PhpdocNoPackageFixer, PhpdocNoUselessInheritdocFixer, PhpdocOrderByValueFixer, PhpdocOrderFixer, PhpdocReturnSelfReferenceFixer, PhpdocScalarFixer, PhpdocScalarFixer, PhpdocSeparationFixer, PhpdocSingleLineVarSpacingFixer, PhpdocSummaryFixer, PhpdocTagCasingFixer, PhpdocTagTypeFixer, PhpdocToCommentFixer, PhpdocToCommentFixer, PhpdocToParamTypeFixer, PhpdocToPropertyTypeFixer, PhpdocToReturnTypeFixer, PhpdocTrimConsecutiveBlankLineSeparationFixer, PhpdocTrimFixer, PhpdocTypesFixer, PhpdocTypesFixer, PhpdocTypesOrderFixer, PhpdocVarAnnotationCorrectOrderFixer, PhpdocVarWithoutNameFixer.
+     * Must run after AlignMultilineCommentFixer, CommentToPhpdocFixer, GeneralPhpdocAnnotationRemoveFixer, GeneralPhpdocTagRenameFixer, NoBlankLinesAfterPhpdocFixer, NoEmptyPhpdocFixer, NoSuperfluousPhpdocTagsFixer, PhpdocAddMissingParamAnnotationFixer, PhpdocAnnotationWithoutDotFixer, PhpdocIndentFixer, PhpdocInlineTagNormalizerFixer, PhpdocLineSpanFixer, PhpdocNoAccessFixer, PhpdocNoAliasTagFixer, PhpdocNoEmptyReturnFixer, PhpdocNoPackageFixer, PhpdocNoUselessInheritdocFixer, PhpdocOrderByValueFixer, PhpdocOrderFixer, PhpdocReturnSelfReferenceFixer, PhpdocScalarFixer, PhpdocSeparationFixer, PhpdocSingleLineVarSpacingFixer, PhpdocSummaryFixer, PhpdocTagCasingFixer, PhpdocTagTypeFixer, PhpdocToCommentFixer, PhpdocToParamTypeFixer, PhpdocToPropertyTypeFixer, PhpdocToReturnTypeFixer, PhpdocTrimConsecutiveBlankLineSeparationFixer, PhpdocTrimFixer, PhpdocTypesFixer, PhpdocTypesOrderFixer, PhpdocVarAnnotationCorrectOrderFixer, PhpdocVarWithoutNameFixer.
      */
     public function getPriority(): int
     {

+ 1 - 1
src/Fixer/Phpdoc/PhpdocToCommentFixer.php

@@ -49,7 +49,7 @@ final class PhpdocToCommentFixer extends AbstractFixer implements ConfigurableFi
     /**
      * {@inheritdoc}
      *
-     * Must run before GeneralPhpdocAnnotationRemoveFixer, GeneralPhpdocTagRenameFixer, NoBlankLinesAfterPhpdocFixer, NoEmptyCommentFixer, NoEmptyPhpdocFixer, NoSuperfluousPhpdocTagsFixer, PhpdocAddMissingParamAnnotationFixer, PhpdocAlignFixer, PhpdocAnnotationWithoutDotFixer, PhpdocIndentFixer, PhpdocInlineTagNormalizerFixer, PhpdocLineSpanFixer, PhpdocNoAccessFixer, PhpdocNoAliasTagFixer, PhpdocNoEmptyReturnFixer, PhpdocNoPackageFixer, PhpdocNoUselessInheritdocFixer, PhpdocOrderByValueFixer, PhpdocOrderFixer, PhpdocReturnSelfReferenceFixer, PhpdocSeparationFixer, PhpdocSingleLineVarSpacingFixer, PhpdocSummaryFixer, PhpdocTagCasingFixer, PhpdocTagTypeFixer, PhpdocToParamTypeFixer, PhpdocToPropertyTypeFixer, PhpdocToReturnTypeFixer, PhpdocTrimConsecutiveBlankLineSeparationFixer, PhpdocTrimFixer, PhpdocTypesOrderFixer, PhpdocVarAnnotationCorrectOrderFixer, PhpdocVarWithoutNameFixer.
+     * Must run before GeneralPhpdocAnnotationRemoveFixer, GeneralPhpdocTagRenameFixer, NoBlankLinesAfterPhpdocFixer, NoEmptyCommentFixer, NoEmptyPhpdocFixer, NoSuperfluousPhpdocTagsFixer, PhpdocAddMissingParamAnnotationFixer, PhpdocAlignFixer, PhpdocAnnotationWithoutDotFixer, PhpdocIndentFixer, PhpdocInlineTagNormalizerFixer, PhpdocLineSpanFixer, PhpdocNoAccessFixer, PhpdocNoAliasTagFixer, PhpdocNoEmptyReturnFixer, PhpdocNoPackageFixer, PhpdocNoUselessInheritdocFixer, PhpdocOrderByValueFixer, PhpdocOrderFixer, PhpdocReturnSelfReferenceFixer, PhpdocSeparationFixer, PhpdocSingleLineVarSpacingFixer, PhpdocSummaryFixer, PhpdocTagCasingFixer, PhpdocTagTypeFixer, PhpdocToParamTypeFixer, PhpdocToPropertyTypeFixer, PhpdocToReturnTypeFixer, PhpdocTrimConsecutiveBlankLineSeparationFixer, PhpdocTrimFixer, PhpdocTypesOrderFixer, PhpdocVarAnnotationCorrectOrderFixer, PhpdocVarWithoutNameFixer, SingleLineCommentStyleFixer.
      * Must run after CommentToPhpdocFixer.
      */
     public function getPriority(): int

+ 1 - 1
src/Fixer/Semicolon/NoSinglelineWhitespaceBeforeSemicolonsFixer.php

@@ -39,7 +39,7 @@ final class NoSinglelineWhitespaceBeforeSemicolonsFixer extends AbstractFixer
     /**
      * {@inheritdoc}
      *
-     * Must run after CombineConsecutiveIssetsFixer, FunctionToConstantFixer, NoEmptyStatementFixer, SimplifiedIfReturnFixer, SingleImportPerStatementFixer.
+     * Must run after CombineConsecutiveIssetsFixer, FunctionToConstantFixer, NoEmptyStatementFixer, NoUnneededImportAliasFixer, SimplifiedIfReturnFixer, SingleImportPerStatementFixer.
      */
     public function getPriority(): int
     {

+ 1 - 5
src/RuleSet/Sets/SymfonyRiskySet.php

@@ -23,7 +23,7 @@ final class SymfonyRiskySet extends AbstractRuleSetDescription
 {
     public function getRules(): array
     {
-        $rules = [
+        return [
             '@PHP56Migration:risky' => true,
             '@PSR12:risky' => true,
             'array_push' => true,
@@ -67,10 +67,6 @@ final class SymfonyRiskySet extends AbstractRuleSetDescription
             'string_line_ending' => true,
             'ternary_to_elvis_operator' => true,
         ];
-
-        ksort($rules);
-
-        return $rules;
     }
 
     public function getDescription(): string

+ 25 - 7
tests/AutoReview/FixerFactoryTest.php

@@ -184,27 +184,44 @@ final class FixerFactoryTest extends TestCase
             $fixers[$name] = ['reflection' => $reflection, 'short_classname' => $reflection->getShortName()];
         }
 
-        $graph = array_merge_recursive(
+        $mergedGraph = array_merge_recursive(
             self::getFixersPriorityGraph(),
             self::getPhpDocFixersPriorityGraph()
         );
 
-        foreach ($graph as $fixerName => $edges) {
-            $after = [];
+        // expend $graph
+
+        $graph = [];
+
+        foreach ($mergedGraph as $fixerName => $edges) {
+            if (!isset($graph[$fixerName]['before'])) {
+                $graph[$fixerName] = ['before' => []];
+            }
 
-            foreach ($graph as $candidateFixer => $candidateEdges) {
+            foreach ($mergedGraph as $candidateFixer => $candidateEdges) {
                 if (\in_array($fixerName, $candidateEdges, true)) {
-                    $after[] = $candidateFixer;
+                    $graph[$fixerName]['after'][$candidateFixer] = true;
+                }
+            }
+
+            foreach ($edges as $edge) {
+                if (!isset($graph[$edge]['after'])) {
+                    $graph[$edge] = ['after' => []];
                 }
+
+                $graph[$edge]['after'][$fixerName] = true;
+                $graph[$fixerName]['before'][$edge] = true;
             }
+        }
 
+        foreach ($graph as $fixerName => $edges) {
             $expectedMessage = "/**\n     * {@inheritdoc}\n     *";
 
-            foreach (['before' => $edges, 'after' => $after] as $label => $others) {
+            foreach ($edges as $label => $others) {
                 if (\count($others) > 0) {
                     $shortClassNames = [];
 
-                    foreach ($others as $other) {
+                    foreach ($others as $other => $foo) {
                         $shortClassNames[$other] = $fixers[$other]['short_classname'];
                     }
 
@@ -675,6 +692,7 @@ final class FixerFactoryTest extends TestCase
             'phpdoc_to_comment' => [
                 'no_empty_comment',
                 'phpdoc_no_useless_inheritdoc',
+                'single_line_comment_style',
             ],
             'phpdoc_to_param_type' => [
                 'no_superfluous_phpdoc_tags',

+ 4 - 4
tests/Fixer/ArrayNotation/NoWhitespaceBeforeCommaInArrayFixerTest.php

@@ -36,17 +36,17 @@ final class NoWhitespaceBeforeCommaInArrayFixerTest extends AbstractFixerTestCas
     public function provideFixCases(): array
     {
         return [
-            //old style array
+            // old style array
             [
                 '<?php $x = array(1, "2",3);',
                 '<?php $x = array(1 , "2",3);',
             ],
-            //old style array with comments
+            // old style array with comments
             [
                 '<?php $x = array /* comment */ (1,  "2", 3);',
                 '<?php $x = array /* comment */ (1  ,  "2", 3);',
             ],
-            //old style array with comments
+            // old style array with comments
             [
                 '<?php $x = array(1#
 ,#
@@ -56,7 +56,7 @@ final class NoWhitespaceBeforeCommaInArrayFixerTest extends AbstractFixerTestCas
 "2"  , 3);',
             ],
 
-            //short array
+            // short array
             [
                 '<?php $x = [1,  "2", 3,$y];',
                 '<?php $x = [1 ,  "2", 3 ,$y];',

+ 3 - 3
tests/Fixer/ArrayNotation/WhitespaceAfterCommaInArrayFixerTest.php

@@ -36,18 +36,18 @@ final class WhitespaceAfterCommaInArrayFixerTest extends AbstractFixerTestCase
     public function provideFixCases(): array
     {
         return [
-            //old style array
+            // old style array
             [
                 '<?php $x = array( 1 , "2", 3);',
                 '<?php $x = array( 1 ,"2",3);',
             ],
-            //old style array with comments
+            // old style array with comments
             [
                 '<?php $x = array /* comment */ ( 1 ,  "2", 3);',
                 '<?php $x = array /* comment */ ( 1 ,  "2",3);',
             ],
 
-            //short array
+            // short array
             [
                 '<?php $x = [ 1 ,  "2", 3 , $y];',
                 '<?php $x = [ 1 ,  "2",3 ,$y];',

Some files were not shown because too many files changed in this diff