Skip to content

Review what annotations are to be considered standard #65

Closed

Description

@aik099

I've found 2 pages with a list of standard annotations:

Here is a comparison table of tags, shown there:

Annotation PHPDoc v1 PHPDoc v2
api x
abstract x
access x
author x x
category x x
copyright x x
deprecated x x
example x x
final x
filesource x x
global x x
ignore x x
internal x x
license x x
link x x
method x x
name x
package x x
param x x
property x x
property-read x
property-write x
return x x
see x x
since x x
source x
static x
staticvar x
subpackage x x
throws x
todo x x
tutorial x
uses x x
var x x
version x x

If we consider that standard annotations are any of listed above (combined list from both PhpDoc versions), then here is the list of what's left (looking at current code):

  • display
  • editable
  • editor
  • enum
  • format
  • length
  • match
  • range
  • required
  • text
  • usage - this one isn't standard, but we use it to configure annotations, we keep it 😄
  • validate
  • view

I propose to remove all but usage annotations from above list (gladly they all map to false in the AnnotationManager::registry anyway).

@mindplay-dk , do you agree?

Activity

  1. added this to the 1.2.0 milestone on Aug 17, 2014
  2. aik099 commented on Aug 17, 2014

    @aik099
    MemberAuthor

    In fact if we also miss some of PHPDoc v2 ones, like @api, then adding them would be a plus as well, because I know for certain that Symfony is using @api tag extensively.

  3. mindplay-dk commented on Aug 18, 2014

    @mindplay-dk
    Member

    You should probably go by PSR-5 which looks like it will be the first official standard.

    https://github.com/phpDocumentor/fig-standards/blob/master/proposed/phpdoc.md

    The annotations you listed above (display, editable, editor, etc.) were a proposed set of default standard annotations - the list was based on part on referencing C# and Java standard annotations.

    The point of standardizing those, is that they are common enough that anyone may need them - C# for example standardizes most of these, without providing services that consume most of them, but the point is that once third parties need this metadata, they will write services that consistently consume these standard types using the same names and properties.

    Better than scrapping them would be implementing them, which I never got around to. But, as they are, they aren't really any use, since they aren't implemented, so... do whatever feels right :-)

  4. aik099 commented on Aug 18, 2014

    @aik099
    MemberAuthor

    I'd be careful with removing any annotations (except ones I proposed) since we're not in perfect world and classes that might be introspected for annotations by this library might contain all sort of old PHPDoc tags in them. We don't want for users to have exceptions throwing at them just because they haven't made their DocBlocks PSR-5 ready 😄

    I might add some comments next to each annotation mapped to false in the registry to indicate from where it comes.

    Looking at fact, that @var is deprecated is PSR-5 and now @type annotation supersedes it makes me a bit worried, since we don't have @type annotation support. I think they deprecated @var because it reminds of times, where var was used to define class property instead of private/protected/public word 😄

    Adding @type support however will be piece of cake, since it just will extend VarAnnotation

  5. mindplay-dk commented on Aug 18, 2014

    @mindplay-dk
    Member

    I'd be careful with removing any annotations

    Oh no, I'm saying you might want to add new annotations defined in PSR-5 - you don't want to remove any, even deprecated ones most likely, if there are any...

    Looking at fact, that @var is deprecated is PSR-5 and now @type annotation supersedes it makes me a bit worried

    I think they use the same syntax? You can probably just map @type to VarAnnotation, and possibly rename the class to TypeAnnotation which might be more descriptive... @var should definitely still work, even if it is deprecated.

    I might add some comments next to each annotation mapped to false in the registry to indicate from where it comes.

    A single comment should do it? Just explain briefly that those mapped to false are standard PHP-DOC annotations that aren't useful at run-time, but we don't want run-time errors when encountering them.

  6. mindplay-dk commented on Aug 18, 2014

    @mindplay-dk
    Member

    On a related note, you might want to start thinking about @typedef, which looks like it's going to be difficult to support - it uses nested annotations, which is an entirely new concept and syntax. It's syntax isn't final yet though, so I don't recommend implementing it yet, but you might want to think about it. (or prototype it in a feature branch, since it looks like it's going to happen.)

  7. aik099 commented on Aug 19, 2014

    @aik099
    MemberAuthor

    I think they use the same syntax? You can probably just map @type to VarAnnotation, and possibly rename the class to TypeAnnotation which might be more descriptive... @var should definitely still work, even if it is deprecated.

    OK.

    A single comment should do it? Just explain briefly that those mapped to false are standard PHP-DOC annotations that aren't useful at run-time, but we don't want run-time errors when encountering them.

    I thought to have more historical data, e.g. split annotations in 3 groups: PhpDoc v1, PhpDoc v2, PSR-5.

  8. self-assigned this
    on Aug 27, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions