2

Is there a PHP coding standard that defines unambiguously how to write docblock annotations for properties and methods:

  • @var
  • @param
  • @return
  • @throws

including the correct spacing between them?

PSR-2 covers the code itself, but does not enforce the usage of annotations.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
  • 1
    This becomes even more interesting when you consider that frameworks like Symfony2 actually use those annotations as a form of macrocoding – Mark Baker Dec 07 '12 at 16:57
  • They use the Doctrine Common annotations library, which has somewhat become a standard among frameworks. But it looks like there is no "official" standard neither for these annotations, nor for the phpDoc ones, sadly. – BenMorel Dec 07 '12 at 16:59

1 Answers1

3

There's no annotations in PHP. If you use phpdoc to generate documentation, you need to follow phpdoc guides.

http://www.phpdoc.org/

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
  • 2
    Yes, I mean phpDoc annotations, but while phpDoc is a de-facto standard, it's not the only documentation tool available. Furthermore, it fails to define the proper spacing etc. for annotations, AFAIK. I was hoping that there was a defined standard somewhere that documentation tools would be built upon. – BenMorel Dec 07 '12 at 16:47
  • Thanks anyway for your answer. For information, I asked a similar question regarding [whether a PHPCS standard exists for this purpose](http://stackoverflow.com/q/13767550/759866). – BenMorel Dec 07 '12 at 17:01