@@ -53,10 +53,11 @@ array{
53
53
> second
54
54
> }
55
55
> ```
56
+ >
57
+ > An error similar to the one below should occur.
56
58
> ```
57
- > Cannot mix numeric and named keys.
59
+ > ParseException: Cannot mix numeric and named keys.
58
60
> ```
59
- > {collapsible="true" collapsed-title="TypeLang\Parser\Exception\ParseException"}
60
61
{style="warning"}
61
62
62
63
> Support for other types of **keys**, such as const mask (`Class::CONST_*`)
@@ -67,12 +68,34 @@ array{
67
68
> ...
68
69
> }
69
70
> ```
71
+ >
72
+ > An error similar to the one below should occur.
70
73
> ```
71
- > Syntax error, unexpected ":"
74
+ > ParseException: Syntax error, unexpected ":"
72
75
> ```
73
- > {collapsible="true" collapsed-title="TypeLang\Parser\Exception\ParseException"}
74
76
{style="warning"}
75
77
78
+ ### Optional Fields
79
+
80
+ Specifying fields (keys) allows the optionality of the presence of a field.
81
+ Such fields are indicated by a question mark (`?`) **before** the colon (`:`)
82
+ symbol: `key?: Type`.
83
+
84
+ <compare first-title =" Optional Key" second-title =" Optional Value" >
85
+
86
+ ```php
87
+ array{
88
+ key?: Type,
89
+ }
90
+ ```
91
+
92
+ ``` php
93
+ array{
94
+ key: Type?,
95
+ }
96
+ ```
97
+ </compare >
98
+
76
99
### Unsealed Shapes
77
100
78
101
Unsealed (unclosed) shapes mean that the composite type can contain additional
@@ -168,10 +191,11 @@ An attribute is additional metadata for a field.
168
191
> test ?: App \Domain \User ,
169
192
> }
170
193
> ` ` `
194
+ >
195
+ > An error similar to the one below should occur
171
196
> ` ` `
172
- > Syntax error , unexpected " 42"
197
+ > ParseException : Syntax error , unexpected " 42"
173
198
> ` ` `
174
- > {collapsible="true" collapsed-title="TypeLang\P arser\E xception\P arseException"}
175
199
> {style="warning"}
176
200
177
201
</tab>
0 commit comments