public function generate(array $ast) : string
    {
        $this->traverser->traverse($ast);

        $generatedCode = parent::generate($ast);
        $className     = trim($this->visitor->getNamespace() . '\\' . $this->visitor->getName(), '\\');
        $fileName      = $this->fileLocator->getGeneratedClassFileName($className);
        $tmpFileName   = $fileName . '.' . uniqid('', true);

        // renaming files is necessary to avoid race conditions when the same file is written multiple times
        // in a short time period
        file_put_contents($tmpFileName, "<?php\n\n" . $generatedCode);
        rename($tmpFileName, $fileName);

        return $generatedCode;
    }
public function generate(array $ast) : string
    {
        $this->traverser->traverse($ast);

        $generatedCode = parent::generate($ast);
        $className     = trim($this->visitor->getNamespace() . '\\' . $this->visitor->getName(), '\\');
        $fileName      = $this->fileLocator->getGeneratedClassFileName($className);
        $tmpFileName   = $fileName . '.' . uniqid('', true);

        // renaming files is necessary to avoid race conditions when the same file is written multiple times
        // in a short time period
        file_put_contents($tmpFileName, "<?php\n\n" . $generatedCode);
        rename($tmpFileName, $fileName);

        return $generatedCode;
    }
public function generate ( array $ ast ) : string { $ this -> traverser -> traverse ( $ ast ) ; $ generatedCode = parent :: generate ( $ ast ) ; $ className = trim ( $ this -> visitor -> getNamespace ( ) . '\\' . $ this -> visitor -> getName ( ) , '\\' ) ; $ fileName = $ this -> fileLocator -> getGeneratedClassFileName ( $ className ) ; $ tmpFileName = $ fileName . '.' . uniqid ( '' , true ) ; // renaming files is necessary to avoid race conditions when the same file is written multiple times // in a short time period file_put_contents ( $ tmpFileName , "<?php\n\n" . $ generatedCode ) ; rename ( $ tmpFileName , $ fileName ) ; return $ generatedCode ; }
Write generated code to disk and return the class code

{@inheritDoc}

@throws \CodeGenerationUtils\Visitor\Exception\UnexpectedValueException
Write generated code to disk and return the class code