protected function patchExistingFile(TypeGenerator $generator, Type $type, $path)
{
try {
$this->filesystem->createBackup($path);
$file = FileGenerator::fromReflectedFileName($path);
$this->generateType($file, $generator, $type, $path);
} catch (\Exception $e) {
$this->output->writeln('<fg=red>' . $e->getMessage() . '</fg=red>');
$this->filesystem->removeBackup($path);
return false;
}
return true;
}