Php-cs-fixer: HeaderComment - PHPDoc of class is removed

Created on 23 Oct 2018  路  4Comments  路  Source: FriendsOfPHP/PHP-CS-Fixer

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

=> 7.2.8 (cli)

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

=> 2.13.0

The command you use to run PHP CS Fixer:

=> php-cs-fixer fix test.php

The configuration file you are using, if any:

return PhpCsFixer\Config::create()
    ->setRules([
        'header_comment' => [
            'header' => 'header',
        ],
    ])
;

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

  • before running PHP CS Fixer (no changes):
<?php

/**
 * Class A.
 */
class A
{
}

  • with unexpected changes applied when running PHP CS Fixer:
<?php

/*
 * header 
 */

class A
{
}

  • with the changes you expected instead:
<?php

/*
 * header
 */

/**
 * Class A.
 */
class A
{
}

kinbug

All 4 comments

Hi @maidmaid , thanks for the report!

Sadly you've been bitten by a long standing issue about the header-rule and how the fixer should detect if a PHPDoc or comment is a header or actually belongs to the class.
Hope someone can pick this one up in the near future, till than I'll leave your report open as it is valid.

Hi @SpacePossum, thanks for your answer. At least, it's clear now.

Hmm, but a header start with /* and the class phpdoc start with /** or is a header allowed to start with /**, too?

I always thought it is fine to have a header starting with /** , however it has been removed from the PSR5 proposal https://github.com/php-fig/fig-standards/commit/03457b81d2ece8071bfa8978da9bdd3fac8612d9#diff-9a10a11696dc38209c125ea9c57a565fL62 ...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Bilge picture Bilge  路  3Comments

UksusoFF picture UksusoFF  路  3Comments

amitbisht511 picture amitbisht511  路  3Comments

Bilge picture Bilge  路  3Comments

grachevko picture grachevko  路  3Comments