@@ -236,8 +236,7 @@ public function testProvidedConstPropertiesIsValidWithDifferentImplicitNull(
236236 bool $ implicitNull ,
237237 string $ reqPropertyValue ,
238238 string $ optPropertyValue
239- ): void
240- {
239+ ): void {
241240 $ className = $ this ->generateClassFromFile (
242241 'RequiredAndOptionalConstProperties.json ' ,
243242 new GeneratorConfiguration (),
@@ -249,6 +248,36 @@ public function testProvidedConstPropertiesIsValidWithDifferentImplicitNull(
249248
250249 $ this ->assertSame ($ reqPropertyValue , $ object ->getRequiredProperty ());
251250 $ 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 ());
252281 }
253282
254283 public function requiredAndOptionalPropertiesDataProvider (): array
0 commit comments