annotations icon indicating copy to clipboard operation
annotations copied to clipboard

Document default values in annotations

Open apfelbox opened this issue 7 years ago • 2 comments

Hi,

I have found nothing in the documentation (and no test, but didn't search for too long).

Are there some docs about annotations that I can use without explicitly naming the parameters? I guess it just injects an array with the key "value" but I am not to sure.

For reference, I mean code like this:

/**
 * @SomeAnnot("ohai")
 */

How is this unnamed parameter injected? It would be great if we could add a note about that on https://www.doctrine-project.org/projects/doctrine-annotations/en/latest/custom.html

apfelbox avatar Sep 11 '18 07:09 apfelbox

I think it is called value and passed to the constructor of your annotation as such, but not sure about it either: would indeed need test and documentation additions.

Ocramius avatar Sep 11 '18 07:09 Ocramius

There is a test here: https://github.com/doctrine/annotations/blob/f173cdc80791e747cfad36a27df262acc2ef77bb/tests/Doctrine/Tests/Annotations/DocParserTest.php#L103-L123

But I agree it's a bit magic, maybe something to re-think in 2.0 (i.e. explciitly marking specific property as @Default).

Majkl578 avatar Oct 17 '18 16:10 Majkl578