diff --git a/src/Console/Output/ProcessOutput.php b/src/Console/Output/ProcessOutput.php index c737c871e91..be662e30f82 100644 --- a/src/Console/Output/ProcessOutput.php +++ b/src/Console/Output/ProcessOutput.php @@ -72,7 +72,7 @@ public function __construct(OutputInterface $output, EventDispatcherInterface $d $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); diff --git a/src/Fixer/CastNotation/ModernizeTypesCastingFixer.php b/src/Fixer/CastNotation/ModernizeTypesCastingFixer.php index 13f189b7011..7d13051f8ac 100644 --- a/src/Fixer/CastNotation/ModernizeTypesCastingFixer.php +++ b/src/Fixer/CastNotation/ModernizeTypesCastingFixer.php @@ -101,7 +101,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void $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; } diff --git a/src/Fixer/Comment/SingleLineCommentStyleFixer.php b/src/Fixer/Comment/SingleLineCommentStyleFixer.php index 64a139578c7..7ce0148c038 100644 --- a/src/Fixer/Comment/SingleLineCommentStyleFixer.php +++ b/src/Fixer/Comment/SingleLineCommentStyleFixer.php @@ -105,7 +105,7 @@ public function getDefinition(): FixerDefinitionInterface /** * {@inheritdoc} * - * Must run after HeaderCommentFixer, NoUselessReturnFixer. + * Must run after HeaderCommentFixer, NoUselessReturnFixer, PhpdocToCommentFixer. */ public function getPriority(): int { diff --git a/src/Fixer/Phpdoc/PhpdocAlignFixer.php b/src/Fixer/Phpdoc/PhpdocAlignFixer.php index c37dc0dbfd2..f72635d3488 100644 --- a/src/Fixer/Phpdoc/PhpdocAlignFixer.php +++ b/src/Fixer/Phpdoc/PhpdocAlignFixer.php @@ -154,7 +154,7 @@ public function getDefinition(): FixerDefinitionInterface /** * {@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 { diff --git a/src/Fixer/Phpdoc/PhpdocToCommentFixer.php b/src/Fixer/Phpdoc/PhpdocToCommentFixer.php index 49b55e3e5d8..ecc9ed65629 100644 --- a/src/Fixer/Phpdoc/PhpdocToCommentFixer.php +++ b/src/Fixer/Phpdoc/PhpdocToCommentFixer.php @@ -49,7 +49,7 @@ public function isCandidate(Tokens $tokens): bool /** * {@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 diff --git a/src/Fixer/Semicolon/NoSinglelineWhitespaceBeforeSemicolonsFixer.php b/src/Fixer/Semicolon/NoSinglelineWhitespaceBeforeSemicolonsFixer.php index f20f08a89d9..c3f0d135457 100644 --- a/src/Fixer/Semicolon/NoSinglelineWhitespaceBeforeSemicolonsFixer.php +++ b/src/Fixer/Semicolon/NoSinglelineWhitespaceBeforeSemicolonsFixer.php @@ -39,7 +39,7 @@ public function getDefinition(): FixerDefinitionInterface /** * {@inheritdoc} * - * Must run after CombineConsecutiveIssetsFixer, FunctionToConstantFixer, NoEmptyStatementFixer, SimplifiedIfReturnFixer, SingleImportPerStatementFixer. + * Must run after CombineConsecutiveIssetsFixer, FunctionToConstantFixer, NoEmptyStatementFixer, NoUnneededImportAliasFixer, SimplifiedIfReturnFixer, SingleImportPerStatementFixer. */ public function getPriority(): int { diff --git a/src/RuleSet/Sets/SymfonyRiskySet.php b/src/RuleSet/Sets/SymfonyRiskySet.php index 562ca3b6cd5..e07ae3424cb 100644 --- a/src/RuleSet/Sets/SymfonyRiskySet.php +++ b/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 @@ public function getRules(): array 'string_line_ending' => true, 'ternary_to_elvis_operator' => true, ]; - - ksort($rules); - - return $rules; } public function getDescription(): string diff --git a/tests/AutoReview/FixerFactoryTest.php b/tests/AutoReview/FixerFactoryTest.php index cb7ef72f42d..601c7324346 100644 --- a/tests/AutoReview/FixerFactoryTest.php +++ b/tests/AutoReview/FixerFactoryTest.php @@ -184,27 +184,44 @@ public function testFixersPriorityComment(): void $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 @@ private static function getFixersPriorityGraph(): array 'phpdoc_to_comment' => [ 'no_empty_comment', 'phpdoc_no_useless_inheritdoc', + 'single_line_comment_style', ], 'phpdoc_to_param_type' => [ 'no_superfluous_phpdoc_tags', diff --git a/tests/Fixer/ArrayNotation/NoWhitespaceBeforeCommaInArrayFixerTest.php b/tests/Fixer/ArrayNotation/NoWhitespaceBeforeCommaInArrayFixerTest.php index f0743615364..2fc38503e2c 100644 --- a/tests/Fixer/ArrayNotation/NoWhitespaceBeforeCommaInArrayFixerTest.php +++ b/tests/Fixer/ArrayNotation/NoWhitespaceBeforeCommaInArrayFixerTest.php @@ -36,17 +36,17 @@ public function testFix(string $expected, ?string $input = null): void public function provideFixCases(): array { return [ - //old style array + // old style array [ '