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

Fix priority between PHPDoc return type fixers #3835

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
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -44,7 +44,7 @@
"php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.0.1",
"php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.0.1",
"phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1",
"phpunitgoodpractices/traits": "^1.5",
"phpunitgoodpractices/traits": "^1.5.1",
"symfony/phpunit-bridge": "^4.0"
},
"suggest": {
Expand Down
4 changes: 2 additions & 2 deletions src/Fixer/FunctionNotation/PhpdocToReturnTypeFixer.php
Expand Up @@ -128,8 +128,8 @@ public function isCandidate(Tokens $tokens)
public function getPriority()
{
// should be run after PhpdocScalarFixer.
// should be run before ReturnTypeDeclarationFixer, FullyQualifiedStrictTypesFixer.
return 1;
// should be run before ReturnTypeDeclarationFixer, FullyQualifiedStrictTypesFixer, NoSuperfluousPhpdocTagsFixer.
return 8;
}

/**
Expand Down
1 change: 1 addition & 0 deletions tests/AutoReview/FixerFactoryTest.php
Expand Up @@ -183,6 +183,7 @@ public function provideFixersPriorityCases()
[$fixers['phpdoc_to_comment'], $fixers['no_empty_comment']],
[$fixers['phpdoc_to_comment'], $fixers['phpdoc_no_useless_inheritdoc']],
[$fixers['phpdoc_to_return_type'], $fixers['fully_qualified_strict_types']],
[$fixers['phpdoc_to_return_type'], $fixers['no_superfluous_phpdoc_tags']],
[$fixers['phpdoc_to_return_type'], $fixers['return_type_declaration']],
[$fixers['pow_to_exponentiation'], $fixers['binary_operator_spaces']],
[$fixers['pow_to_exponentiation'], $fixers['method_argument_space']],
Expand Down
@@ -0,0 +1,28 @@
--TEST--
Integration of fixers: phpdoc_to_return_type,no_superfluous_phpdoc_tags.
--RULESET--
{"phpdoc_to_return_type": true, "no_superfluous_phpdoc_tags": true}
--REQUIREMENTS--
{"php": 70000}
--EXPECT--
<?php

class Test {
/**
*/
public function foo(): int {
return 1;
}
}

--INPUT--
<?php

class Test {
/**
* @return int
*/
public function foo() {
return 1;
}
}