File tree Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Original file line number Diff line number Diff line change @@ -16,4 +16,8 @@ interface AnnotatedType extends Type
16
16
public function entitled (string $ title );
17
17
18
18
public function describedAs (string $ description );
19
+
20
+ public function withDefault ($ default );
21
+
22
+ public function withExamples (...$ examples );
19
23
}
Original file line number Diff line number Diff line change @@ -23,6 +23,16 @@ trait HasAnnotations
23
23
*/
24
24
protected $ description ;
25
25
26
+ /**
27
+ * @var mixed
28
+ */
29
+ protected $ default ;
30
+
31
+ /**
32
+ * @var array<mixed>
33
+ */
34
+ protected $ examples ;
35
+
26
36
public function entitled (string $ title ): self
27
37
{
28
38
$ cp = clone $ this ;
@@ -51,6 +61,43 @@ public function description(): ?string
51
61
return $ this ->description ;
52
62
}
53
63
64
+ /**
65
+ * @param mixed $default
66
+ */
67
+ public function withDefault ($ default ): self
68
+ {
69
+ $ cp = clone $ this ;
70
+
71
+ $ cp ->default = $ default ;
72
+
73
+ return $ cp ;
74
+ }
75
+
76
+ /**
77
+ * @return mixed
78
+ */
79
+ public function defaultValue ()
80
+ {
81
+ return $ this ->default ;
82
+ }
83
+
84
+ public function withExamples (...$ examples ): self
85
+ {
86
+ $ cp = clone $ this ;
87
+
88
+ $ cp ->examples = $ examples ;
89
+
90
+ return $ cp ;
91
+ }
92
+
93
+ /**
94
+ * @return array<mixed>
95
+ */
96
+ public function examples (): array
97
+ {
98
+ return $ this ->examples ;
99
+ }
100
+
54
101
public function annotations (): array
55
102
{
56
103
$ annotations = [];
@@ -63,6 +110,14 @@ public function annotations(): array
63
110
$ annotations ['description ' ] = $ this ->description ;
64
111
}
65
112
113
+ if (null !== $ this ->default ) {
114
+ $ annotations ['default ' ] = $ this ->default ;
115
+ }
116
+
117
+ if (null !== $ this ->examples ) {
118
+ $ annotations ['examples ' ] = $ this ->examples ;
119
+ }
120
+
66
121
return $ annotations ;
67
122
}
68
123
}
You can’t perform that action at this time.
0 commit comments