Skip to content

Commit

Permalink
bug: Fix priority between modernize_types_casting and `no_unneeded_…
Browse files Browse the repository at this point in the history
…control_parentheses` (#6687)
  • Loading branch information
julienfalque committed Nov 19, 2022
1 parent 046ff90 commit 9c7070b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/Fixer/CastNotation/ModernizeTypesCastingFixer.php
Expand Up @@ -50,6 +50,16 @@ public function getDefinition(): FixerDefinitionInterface
);
}

/**
* {@inheritdoc}
*
* Must run before NoUnneededControlParenthesesFixer.
*/
public function getPriority(): int
{
return 31;
}

/**
* {@inheritdoc}
*/
Expand Down
Expand Up @@ -163,7 +163,7 @@ public function getDefinition(): FixerDefinitionInterface
* {@inheritdoc}
*
* Must run before ConcatSpaceFixer, NoTrailingWhitespaceFixer.
* Must run after NoAlternativeSyntaxFixer.
* Must run after ModernizeTypesCastingFixer, NoAlternativeSyntaxFixer.
*/
public function getPriority(): int
{
Expand Down
3 changes: 3 additions & 0 deletions tests/AutoReview/FixerFactoryTest.php
Expand Up @@ -492,6 +492,9 @@ private static function getFixersPriorityGraph(): array
'php_unit_dedicate_assert',
'single_space_after_construct',
],
'modernize_types_casting' => [
'no_unneeded_control_parentheses',
],
'multiline_whitespace_before_semicolons' => [
'space_after_semicolon',
],
Expand Down
@@ -0,0 +1,13 @@
--TEST--
Integration of fixers: modernize_types_casting,no_unneeded_control_parentheses.
--RULESET--
{"modernize_types_casting": true, "no_unneeded_control_parentheses": {"statements": ["others"]}}
--EXPECT--
<?php

$foo = (int) foo();

--INPUT--
<?php

$foo = intval(foo());

0 comments on commit 9c7070b

Please sign in to comment.