Skip to content

Commit df48620

Browse files
authored
Merge pull request #17 from veewee/less-spammy-options
Wrap option during parse-time, not during read-time
2 parents b81101c + 2c36406 commit df48620

2 files changed

Lines changed: 212 additions & 160 deletions

File tree

src/Metadata/Model/MethodMeta.php

Lines changed: 81 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -9,92 +9,113 @@
99
final class MethodMeta
1010
{
1111
/**
12-
* @var string|null
12+
* @var Option<string>
1313
*/
14-
private $docs;
14+
private Option $docs;
1515

1616
/**
17-
* @var string|null
17+
* @var Option<string>
1818
*/
19-
private $action;
19+
private Option $action;
2020

2121
/**
22-
* @var string|null
22+
* @var Option<string>
2323
*/
24-
private $operationName;
24+
private Option $operationName;
2525

2626
/**
27-
* @var string|null
27+
* @var Option<string>
2828
*/
29-
private $location;
29+
private Option $location;
3030

3131
/**
32-
* @var string|null
32+
* @var Option<string>
3333
*/
34-
private $targetNamespace;
34+
private Option $targetNamespace;
3535

3636
/**
37-
* @var string|null
37+
* @var Option<string>
3838
*/
39-
private $soapVersion;
39+
private Option $soapVersion;
4040

4141
/**
42-
* @var string|null
42+
* @var Option<string>
4343
*/
44-
private $transport;
44+
private Option $transport;
4545

4646
/**
47-
* @var string|null
47+
* @var Option<string>
4848
*/
49-
private $bindingStyle;
49+
private Option $bindingStyle;
5050

5151
/**
52-
* @var string|null
52+
* @var Option<string>
5353
*/
54-
private $inputBindingUsage;
54+
private Option $inputBindingUsage;
5555

5656
/**
57-
* @var string|null
57+
* @var Option<string>
5858
*/
59-
private $inputNamespace;
59+
private Option $inputNamespace;
6060

6161
/**
62-
* @var string|null
62+
* @var Option<string>
6363
*/
64-
private $inputEncodingStyle;
64+
private Option $inputEncodingStyle;
6565

6666
/**
67-
* @var string|null
67+
* @var Option<string>
6868
*/
69-
private $outputBindingUsage;
69+
private Option $outputBindingUsage;
7070

7171
/**
72-
* @var string|null
72+
* @var Option<string>
7373
*/
74-
private $outputNamespace;
74+
private Option $outputNamespace;
7575

7676
/**
77-
* @var string|null
77+
* @var Option<string>
7878
*/
79-
private $outputEncodingStyle;
79+
private Option $outputEncodingStyle;
8080

8181
/**
82-
* @var bool|null
82+
* @var Option<bool>
8383
*/
84-
private $isOneWay;
84+
private Option $isOneWay;
85+
86+
public function __construct()
87+
{
88+
$none = Option::none();
89+
90+
$this->docs = $none;
91+
$this->action = $none;
92+
$this->operationName = $none;
93+
$this->location = $none;
94+
$this->targetNamespace = $none;
95+
$this->soapVersion = $none;
96+
$this->transport = $none;
97+
$this->bindingStyle = $none;
98+
$this->isOneWay = $none;
99+
$this->inputBindingUsage = $none;
100+
$this->inputNamespace = $none;
101+
$this->inputEncodingStyle = $none;
102+
$this->outputBindingUsage = $none;
103+
$this->outputNamespace = $none;
104+
$this->outputEncodingStyle = $none;
105+
}
85106

86107
/**
87108
* @return Option<string>
88109
*/
89110
public function docs(): Option
90111
{
91-
return from_nullable($this->docs);
112+
return $this->docs;
92113
}
93114

94115
public function withDocs(?string $docs): self
95116
{
96117
$new = clone $this;
97-
$new->docs = $docs;
118+
$new->docs = from_nullable($docs);
98119

99120
return $new;
100121
}
@@ -104,13 +125,13 @@ public function withDocs(?string $docs): self
104125
*/
105126
public function action(): Option
106127
{
107-
return from_nullable($this->action);
128+
return $this->action;
108129
}
109130

110131
public function withAction(?string $action): self
111132
{
112133
$new = clone $this;
113-
$new->action = $action;
134+
$new->action = from_nullable($action);
114135

115136
return $new;
116137
}
@@ -120,13 +141,13 @@ public function withAction(?string $action): self
120141
*/
121142
public function operationName(): Option
122143
{
123-
return from_nullable($this->operationName);
144+
return $this->operationName;
124145
}
125146

126147
public function withOperationName(?string $operationName): self
127148
{
128149
$new = clone $this;
129-
$new->operationName = $operationName;
150+
$new->operationName = from_nullable($operationName);
130151

131152
return $new;
132153
}
@@ -136,13 +157,13 @@ public function withOperationName(?string $operationName): self
136157
*/
137158
public function location(): Option
138159
{
139-
return from_nullable($this->location);
160+
return $this->location;
140161
}
141162

142163
public function withlocation(?string $location): self
143164
{
144165
$new = clone $this;
145-
$new->location = $location;
166+
$new->location = from_nullable($location);
146167

147168
return $new;
148169
}
@@ -152,13 +173,13 @@ public function withlocation(?string $location): self
152173
*/
153174
public function targetNamespace(): Option
154175
{
155-
return from_nullable($this->targetNamespace);
176+
return $this->targetNamespace;
156177
}
157178

158179
public function withTargetNamespace(?string $targetNamespace): self
159180
{
160181
$new = clone $this;
161-
$new->targetNamespace = $targetNamespace;
182+
$new->targetNamespace = from_nullable($targetNamespace);
162183

163184
return $new;
164185
}
@@ -168,13 +189,13 @@ public function withTargetNamespace(?string $targetNamespace): self
168189
*/
169190
public function soapVersion(): Option
170191
{
171-
return from_nullable($this->soapVersion);
192+
return $this->soapVersion;
172193
}
173194

174195
public function withSoapVersion(?string $soapVersion): self
175196
{
176197
$new = clone $this;
177-
$new->soapVersion = $soapVersion;
198+
$new->soapVersion = from_nullable($soapVersion);
178199

179200
return $new;
180201
}
@@ -184,13 +205,13 @@ public function withSoapVersion(?string $soapVersion): self
184205
*/
185206
public function transport(): Option
186207
{
187-
return from_nullable($this->transport);
208+
return $this->transport;
188209
}
189210

190211
public function withTransport(?string $transport): self
191212
{
192213
$new = clone $this;
193-
$new->transport = $transport;
214+
$new->transport = from_nullable($transport);
194215

195216
return $new;
196217
}
@@ -200,13 +221,13 @@ public function withTransport(?string $transport): self
200221
*/
201222
public function bindingStyle(): Option
202223
{
203-
return from_nullable($this->bindingStyle);
224+
return $this->bindingStyle;
204225
}
205226

206227
public function withBindingStyle(?string $bindingStyle): self
207228
{
208229
$new = clone $this;
209-
$new->bindingStyle = $bindingStyle;
230+
$new->bindingStyle = from_nullable($bindingStyle);
210231

211232
return $new;
212233
}
@@ -216,13 +237,13 @@ public function withBindingStyle(?string $bindingStyle): self
216237
*/
217238
public function isOneWay(): Option
218239
{
219-
return from_nullable($this->isOneWay);
240+
return $this->isOneWay;
220241
}
221242

222243
public function withIsOneWay(?bool $isOneWay): self
223244
{
224245
$new = clone $this;
225-
$new->isOneWay = $isOneWay;
246+
$new->isOneWay = from_nullable($isOneWay);
226247

227248
return $new;
228249
}
@@ -232,13 +253,13 @@ public function withIsOneWay(?bool $isOneWay): self
232253
*/
233254
public function inputBindingUsage(): Option
234255
{
235-
return from_nullable($this->inputBindingUsage);
256+
return $this->inputBindingUsage;
236257
}
237258

238259
public function withInputBindingUsage(?string $inputBindingUsage): self
239260
{
240261
$new = clone $this;
241-
$new->inputBindingUsage = $inputBindingUsage;
262+
$new->inputBindingUsage = from_nullable($inputBindingUsage);
242263

243264
return $new;
244265
}
@@ -248,13 +269,13 @@ public function withInputBindingUsage(?string $inputBindingUsage): self
248269
*/
249270
public function inputNamespace(): Option
250271
{
251-
return from_nullable($this->inputNamespace);
272+
return $this->inputNamespace;
252273
}
253274

254275
public function withInputNamespace(?string $inputNamespace): self
255276
{
256277
$new = clone $this;
257-
$new->inputNamespace = $inputNamespace;
278+
$new->inputNamespace = from_nullable($inputNamespace);
258279

259280
return $new;
260281
}
@@ -264,13 +285,13 @@ public function withInputNamespace(?string $inputNamespace): self
264285
*/
265286
public function inputEncodingStyle(): Option
266287
{
267-
return from_nullable($this->inputEncodingStyle);
288+
return $this->inputEncodingStyle;
268289
}
269290

270291
public function withInputEncodingStyle(?string $inputEncodingStyle): self
271292
{
272293
$new = clone $this;
273-
$new->inputEncodingStyle = $inputEncodingStyle;
294+
$new->inputEncodingStyle = from_nullable($inputEncodingStyle);
274295

275296
return $new;
276297
}
@@ -281,13 +302,13 @@ public function withInputEncodingStyle(?string $inputEncodingStyle): self
281302
*/
282303
public function outputBindingUsage(): Option
283304
{
284-
return from_nullable($this->outputBindingUsage);
305+
return $this->outputBindingUsage;
285306
}
286307

287308
public function withOutputBindingUsage(?string $outputBindingUsage): self
288309
{
289310
$new = clone $this;
290-
$new->outputBindingUsage = $outputBindingUsage;
311+
$new->outputBindingUsage = from_nullable($outputBindingUsage);
291312

292313
return $new;
293314
}
@@ -297,13 +318,13 @@ public function withOutputBindingUsage(?string $outputBindingUsage): self
297318
*/
298319
public function outputNamespace(): Option
299320
{
300-
return from_nullable($this->outputNamespace);
321+
return $this->outputNamespace;
301322
}
302323

303324
public function withOutputNamespace(?string $outputNamespace): self
304325
{
305326
$new = clone $this;
306-
$new->outputNamespace = $outputNamespace;
327+
$new->outputNamespace = from_nullable($outputNamespace);
307328

308329
return $new;
309330
}
@@ -313,13 +334,13 @@ public function withOutputNamespace(?string $outputNamespace): self
313334
*/
314335
public function outputEncodingStyle(): Option
315336
{
316-
return from_nullable($this->outputEncodingStyle);
337+
return $this->outputEncodingStyle;
317338
}
318339

319340
public function withOutputEncodingStyle(?string $outputEncodingStyle): self
320341
{
321342
$new = clone $this;
322-
$new->outputEncodingStyle = $outputEncodingStyle;
343+
$new->outputEncodingStyle = from_nullable($outputEncodingStyle);
323344

324345
return $new;
325346
}

0 commit comments

Comments
 (0)