1

Is there a documentation about the psr standards for doc comments in php.

example:

/** @var string $str */
$str = "test";
/** @var array $arr */
$arr = [];

is this allowed or do I need to do it like this:

/** @var string $str */
$str = "test";

/** @var array $arr */
$arr = [];
nusje2000
  • 493
  • 9
  • 25

1 Answers1

3

PSR does not recommend anything about the kind of comments you are talking about. Personally, I would recommend you to use the second one, because it is easier to read.

If you are interested in other PSR annotations and commenting standards, you can check them here, at GitHub under the "Commenting Code" section of the page.

thexpand
  • 641
  • 13
  • 28
  • As a german php developer I wasn't sure if I should use german comments or english. Your link recommends english which is in my opinion reasonable because this language is used worldwide. Furthermore, it is often difficult to write the comment in the respective national language, since a large part of the designations has English names whose country-specific translation sounds strange. From my own experience I can say, that comments in national language are a pain in the ass if a third party developer has to understand the code. – Alexander Behling Sep 17 '21 at 08:03