/** * This method tries to patch an existing type class. * * @param TypeGenerator $generator * @param Type $type * @param string $path * * @return bool */ 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; }