1

I have this kind of annotation in php files, to build my swagger :

/**
 * @OA\Get(
 *      path="/additional_roles",
 *      tags={"additional_roles"},
 *      summary="Get list of additional roles",
 *      description="Returns list of additional roles",

Each time I run php-cs-fixer, then the annotation is replaced by :

/*
 * @OA\Get(
 *      path="/additional_roles",
 *      tags={"additional_roles"},
 *      summary="Get list of additional roles",
 *      description="Returns list of additional roles",

See the tranformation /** ==> /* at the first line. Consequences : my swagger file is no more generated.

I have a .php_cs.dist file which contains some rules for php-cs-fixer. I am searching which parameter to change to prevent this transformation.

I tried to change this parameter/value :

'align_multiline_comment' => [
            'comment_type' => 'phpdocs_only',
        ],

without success. What is the correct parameter to change in this configuration file ?

halfer
  • 19,824
  • 17
  • 99
  • 186
Dom
  • 2,984
  • 3
  • 34
  • 64
  • 1
    Check option `phpdoc_to_comment` – u_mulder May 15 '20 at 16:04
  • Thanks u_mulder. Exactly what I was looking for. **'phpdoc_to_comment' => false,** – Dom May 15 '20 at 16:15
  • Hi Dom. Please refrain from adding signatures and thanks to your posts. They are removed here, in the interests of brevity and technical writing. There are some references to these guidelines in the help centre, links available on request. – halfer May 22 '20 at 14:57

1 Answers1

4

According to manual this is phpdoc_to_comment option, set it to false, so as not to remove extra * from phpdoc comments.

But read the description of phpdoc_to_comment option:

Docblocks should only be used on structural elements.

So, maybe your comment is not on structural element and shoud indeed have /* and not /**?

u_mulder
  • 54,101
  • 5
  • 48
  • 64
  • 3
    Sure these annotations are not in a structural element. They are at the end of the class. To isolate them (for the documentation swagger). But perhaps it should be better to move them. I will do that later. but for the moment this option is perfect for my need. Thanks one more time. – Dom May 15 '20 at 16:26
  • There are also cases where PHPStan needs a docblock, not a comment. So the tag should not be modified otherwise we would have to revert the modication at each php-cs-fixer run. – COil Jun 20 '22 at 11:00