@@ -236,8 +236,7 @@ public function testProvidedConstPropertiesIsValidWithDifferentImplicitNull(
236
236
bool $ implicitNull ,
237
237
string $ reqPropertyValue ,
238
238
string $ optPropertyValue
239
- ): void
240
- {
239
+ ): void {
241
240
$ className = $ this ->generateClassFromFile (
242
241
'RequiredAndOptionalConstProperties.json ' ,
243
242
new GeneratorConfiguration (),
@@ -249,6 +248,36 @@ public function testProvidedConstPropertiesIsValidWithDifferentImplicitNull(
249
248
250
249
$ this ->assertSame ($ reqPropertyValue , $ object ->getRequiredProperty ());
251
250
$ this ->assertSame ($ optPropertyValue , $ object ->getOptionalProperty ());
251
+
252
+ // typing for required const
253
+ $ this ->assertSame ('string ' , $ this ->getPropertyTypeAnnotation ($ object , 'requiredProperty ' ));
254
+
255
+ $ this ->assertSame ('string ' , $ this ->getReturnTypeAnnotation ($ object , 'getRequiredProperty ' ));
256
+ $ returnType = $ this ->getReturnType ($ object , 'getRequiredProperty ' );
257
+ $ this ->assertSame ('string ' , $ returnType ->getName ());
258
+ $ this ->assertFalse ($ returnType ->allowsNull ());
259
+
260
+ $ this ->assertSame ('string ' , $ this ->getParameterTypeAnnotation ($ className , 'setRequiredProperty ' ),
261
+ );
262
+ $ setAgeParamType = $ this ->getParameterType ($ className , 'setRequiredProperty ' );
263
+ $ this ->assertSame ('string ' , $ setAgeParamType ->getName ());
264
+ $ this ->assertFalse ($ returnType ->allowsNull ());
265
+
266
+ // typing for optional const
267
+ $ this ->assertSame ('string|null ' , $ this ->getPropertyTypeAnnotation ($ object , 'optionalProperty ' ));
268
+
269
+ $ this ->assertSame ('string|null ' , $ this ->getReturnTypeAnnotation ($ object , 'getOptionalProperty ' ));
270
+ $ returnType = $ this ->getReturnType ($ object , 'getOptionalProperty ' );
271
+ $ this ->assertSame ('string ' , $ returnType ->getName ());
272
+ $ this ->assertTrue ($ returnType ->allowsNull ());
273
+
274
+ $ this ->assertSame (
275
+ $ implicitNull ? 'string|null ' : 'string ' ,
276
+ $ this ->getParameterTypeAnnotation ($ className , 'setOptionalProperty ' ),
277
+ );
278
+ $ setAgeParamType = $ this ->getParameterType ($ className , 'setOptionalProperty ' );
279
+ $ this ->assertSame ('string ' , $ setAgeParamType ->getName ());
280
+ $ this ->assertSame ($ implicitNull , $ setAgeParamType ->allowsNull ());
252
281
}
253
282
254
283
public function requiredAndOptionalPropertiesDataProvider (): array
0 commit comments