@@ -87,10 +87,12 @@ final class DateTimeFactory
8787{
8888 private Parser $ parser ;
8989 private PropertyFactory $ propertyFactory ;
90+ private bool $ typed ;
9091
9192 public function __construct (Parser $ parser , bool $ typed )
9293 {
9394 $ this ->parser = $ parser ;
95+ $ this ->typed = $ typed ;
9496 $ this ->propertyFactory = new PropertyFactory ($ typed );
9597 }
9698
@@ -149,6 +151,7 @@ public function methodFromDateTime(string $argumentName): NodeVisitor
149151 MethodGenerator::FLAG_STATIC | MethodGenerator::FLAG_PUBLIC ,
150152 new BodyGenerator ($ this ->parser , 'return new self(self::ensureUtc($ ' . $ argumentName . ')); ' )
151153 );
154+ $ method ->setTyped ($ this ->typed );
152155 $ method ->setReturnType ('self ' );
153156
154157 return new ClassMethod ($ method );
@@ -176,6 +179,7 @@ public function methodFromString(string $argumentName): NodeVisitor
176179 MethodGenerator::FLAG_STATIC | MethodGenerator::FLAG_PUBLIC ,
177180 new BodyGenerator ($ this ->parser , $ body )
178181 );
182+ $ method ->setTyped ($ this ->typed );
179183 $ method ->setReturnType ('self ' );
180184
181185 return new ClassMethod ($ method );
@@ -191,6 +195,7 @@ public function methodMagicConstruct(string $argumentName): NodeVisitor
191195 MethodGenerator::FLAG_PRIVATE ,
192196 new BodyGenerator ($ this ->parser , \sprintf ('$this->%s = $%s; ' , $ argumentName , $ argumentName ))
193197 );
198+ $ method ->setTyped ($ this ->typed );
194199
195200 return new ClassMethod ($ method );
196201 }
@@ -216,6 +221,7 @@ public function methodDateTime(string $argumentName): NodeVisitor
216221 MethodGenerator::FLAG_PUBLIC ,
217222 new BodyGenerator ($ this ->parser , 'return $this-> ' . $ argumentName . '; ' )
218223 );
224+ $ method ->setTyped ($ this ->typed );
219225 $ method ->setReturnType ('DateTimeImmutable ' );
220226
221227 return new ClassMethod ($ method );
@@ -229,6 +235,7 @@ public function methodMagicToString(): NodeVisitor
229235 MethodGenerator::FLAG_PUBLIC ,
230236 new BodyGenerator ($ this ->parser , 'return $this->toString(); ' )
231237 );
238+ $ method ->setTyped ($ this ->typed );
232239 $ method ->setReturnType ('string ' );
233240
234241 return new ClassMethod ($ method );
@@ -253,6 +260,7 @@ public function methodEnsureUtc(string $argumentName): NodeVisitor
253260 MethodGenerator::FLAG_STATIC | MethodGenerator::FLAG_PRIVATE ,
254261 new BodyGenerator ($ this ->parser , $ body )
255262 );
263+ $ method ->setTyped ($ this ->typed );
256264 $ method ->setReturnType ('DateTimeImmutable ' );
257265
258266 return new ClassMethod ($ method );
0 commit comments