diff --git a/src/FileGenerator.php b/src/FileGenerator.php deleted file mode 100644 index 6517107..0000000 --- a/src/FileGenerator.php +++ /dev/null @@ -1,71 +0,0 @@ -classInfoList = $classInfoList; - } - - /** - * @param FileCollection $fileCollection - * @param Parser $parser - * @param PrettyPrinterAbstract $printer - * @param callable|null $currentFileAst Callable to return current file AST, if null, file will be overwritten - * @return array List of filename => code - */ - public function generateFiles( - FileCollection $fileCollection, - Parser $parser, - PrettyPrinterAbstract $printer, - callable $currentFileAst = null - ): array { - $files = []; - - if ($currentFileAst === null) { - $currentFileAst = static function (File $file, ClassInfo $classInfo) { - return []; - }; - } - - $previousNamespace = '__invalid//namespace__'; - - foreach ($fileCollection as $classBuilder) { - if ($previousNamespace !== $classBuilder->getNamespace()) { - $previousNamespace = $classBuilder->getNamespace(); - $classInfo = $this->classInfoList->classInfoForNamespace($previousNamespace); - $path = $classInfo->getPath($classBuilder->getNamespace() . '\\' . $classBuilder->getName()); - } - $filename = $classInfo->getFilenameFromPathAndName($path, $classBuilder->getName()); - - $nodeTraverser = new NodeTraverser(); - $classBuilder->injectVisitors($nodeTraverser, $parser); - - $files[$filename] = $printer->prettyPrintFile( - $nodeTraverser->traverse($currentFileAst($classBuilder, $classInfo)) - ); - } - - return $files; - } -}