src/CodeGeneration/Generator/RelationsGenerator.php
public function getRelativePathRelationsGenerator(): \Generator
    {
        try {
            $recursiveIterator = new \RecursiveIteratorIterator(
                new \RecursiveDirectoryIterator(
                    \realpath(AbstractGenerator::RELATIONS_TEMPLATE_PATH),
                    \RecursiveDirectoryIterator::SKIP_DOTS
                ),
                \RecursiveIteratorIterator::SELF_FIRST
            );
            foreach ($recursiveIterator as $path => $fileInfo) {
                $relativePath = rtrim(
                    $this->getFilesystem()->makePathRelative(
                        $path,
                        \realpath(AbstractGenerator::RELATIONS_TEMPLATE_PATH)
                    ),
                    '/'
                );
                yield $relativePath => $fileInfo;
            }
        } finally {
            $recursiveIterator = null;
            unset($recursiveIterator);
        }
    }
public function getRelativePathRelationsGenerator(): \Generator
    {
        try {
            $recursiveIterator = new \RecursiveIteratorIterator(
                new \RecursiveDirectoryIterator(
                    \realpath(AbstractGenerator::RELATIONS_TEMPLATE_PATH),
                    \RecursiveDirectoryIterator::SKIP_DOTS
                ),
                \RecursiveIteratorIterator::SELF_FIRST
            );
            foreach ($recursiveIterator as $path => $fileInfo) {
                $relativePath = rtrim(
                    $this->getFilesystem()->makePathRelative(
                        $path,
                        \realpath(AbstractGenerator::RELATIONS_TEMPLATE_PATH)
                    ),
                    '/'
                );
                yield $relativePath => $fileInfo;
            }
        } finally {
            $recursiveIterator = null;
            unset($recursiveIterator);
        }
    }
public function getRelativePathRelationsGenerator ( ) : \ Generator { try { $ recursiveIterator = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( \ realpath ( AbstractGenerator :: RELATIONS_TEMPLATE_PATH ) , \ RecursiveDirectoryIterator :: SKIP_DOTS ) , \ RecursiveIteratorIterator :: SELF_FIRST ) ; foreach ( $ recursiveIterator as $ path => $ fileInfo ) { $ relativePath = rtrim ( $ this -> getFilesystem ( ) -> makePathRelative ( $ path , \ realpath ( AbstractGenerator :: RELATIONS_TEMPLATE_PATH ) ) , '/' ) ; yield $ relativePath => $ fileInfo ; } } finally { $ recursiveIterator = null ; unset ( $ recursiveIterator ) ; } }
Generator that yields relative paths of all the files in the relations template path and the SplFileInfo objects

Use a PHP Generator to iterate over a recursive iterator iterator and then yield:
- key: string $relativePath
- value: \SplFileInfo $fileInfo

The `finally` step unsets the recursiveIterator once everything is done

@return \Generator
Generator that yields relative paths of all the files in the relations template path and the SplFileInfo objects