Php-cs-fixer: fully_qualified_strict_types does not work with phpdoc

Created on 2 Aug 2018  路  6Comments  路  Source: FriendsOfPHP/PHP-CS-Fixer

First of all i know it's not a bug or really an issue, but i would like to have it as a feature request.
Reason for that, is currently using this fixer, leaves code base in inconsistent state.

If i use fully_qualified_strict_types to transforms imported FQCN parameters and return types in function arguments to short version, i would also expect that if it can also transforms for the types that are mentioned within Phpdoc.

When reporting an issue (bug) please provide the following information:

The PHP version you are using ($ php -v):

=> 7.1.16

PHP CS Fixer version you are using ($ php-cs-fixer -V):

=> 2.10.0

If applicable, please provide minimum samples of PHP code (as plain text, not screenshots):

  • before running PHP CS Fixer (no changes):
/** @param \This\Is\Param\Namespace\User $x **/
public function beforePhpCsFixer(\This\Is\Param\Namespace\User $x, string $y): void
{
    // function body
}
  • with unexpected changes applied when running PHP CS Fixer:
/** @param \This\Is\Param\Namespace\User $x **/
public function beforePhpCsFixer(User $x, string $y): void
{
    // function body
}
  • with the changes you expected instead:
/** @param User $x **/
public function beforePhpCsFixer(User $x, string $y): void
{
    // function body
}

Thank you!

Most helpful comment

Definitely should be an option

shouldn't be changed in minor

That thus depends on which version you target 馃槈 but I agree.
However, (in the case this feature gets built) enabling by default for next major, 馃憤 or 馃憥?

All 6 comments

馃憤 for this feature. Btw, you have \This\Is\Param\Namespace\Use instead of \This\Is\Param\Namespace\User 馃槈

Updated it!

Just as a thought: should it be an option (but enabled by default)? I know people who prefer docs to always be FQCN even while code might use short version.

Definitely should be an option, the default behaviour of a fixer shouldn't be changed in minor releases.

Definitely should be an option

shouldn't be changed in minor

That thus depends on which version you target 馃槈 but I agree.
However, (in the case this feature gets built) enabling by default for next major, 馃憤 or 馃憥?

Thank you @ntzm and @dmvdbrugge for supporting my request.

Was this page helpful?
0 / 5 - 0 ratings