Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Fix priority between modernize_types_casting and no_unneeded_control_parentheses #6687

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Fixer/CastNotation/ModernizeTypesCastingFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ public function getDefinition(): FixerDefinitionInterface
);
}

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

/**
* {@inheritdoc}
*/
Expand Down
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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());