' . $publicProperty->getName() . ' = null;'; }, Properties::fromReflectionClass($originalClass) ->onlyNullableProperties() ->getPublicProperties() ); $this->setReturnType($originalClass->getName()); $this->setDocBlock('Constructor for null object initialization'); $this->setBody( 'static $reflection;' . "\n\n" . '$reflection = $reflection ?? new \ReflectionClass(__CLASS__);' . "\n" . '$instance = $reflection->newInstanceWithoutConstructor();' . "\n\n" . ($nullableProperties ? implode("\n", $nullableProperties) . "\n\n" : '') . 'return $instance;' ); } }