src/ModuleDependencyResolver.php
private function getModuleDependencyList(string $module, array $module_dependency_map, array $cyclic_reference_list) : array
    {
        if (!in_array($module, $cyclic_reference_list)){
            $cyclic_reference_list[] = $module;
        }
        else{
            throw new CyclicReferencedModuleException($module, $cyclic_reference_list);
        }

        $dependency_list = [];
        $depended_modules = $module_dependency_map[$module] ?? [];
        foreach($depended_modules as $depended_module){
            $list = $this->getModuleDependencyList($depended_module, $module_dependency_map, $cyclic_reference_list);
            if (!empty($list)){
                foreach($list as $m){
                    if (!in_array($m, $dependency_list)){
                        $dependency_list[] = $m;
                    }
                }
            }
            if (!in_array($depended_module, $dependency_list)) {
                $dependency_list[] = $depended_module;
            }
        }
        return $dependency_list;
    }
private function getModuleDependencyList(string $module, array $module_dependency_map, array $cyclic_reference_list) : array
    {
        if (!in_array($module, $cyclic_reference_list)){
            $cyclic_reference_list[] = $module;
        }
        else{
            throw new CyclicReferencedModuleException($module, $cyclic_reference_list);
        }

        $dependency_list = [];
        $depended_modules = $module_dependency_map[$module] ?? [];
        foreach($depended_modules as $depended_module){
            $list = $this->getModuleDependencyList($depended_module, $module_dependency_map, $cyclic_reference_list);
            if (!empty($list)){
                foreach($list as $m){
                    if (!in_array($m, $dependency_list)){
                        $dependency_list[] = $m;
                    }
                }
            }
            if (!in_array($depended_module, $dependency_list)) {
                $dependency_list[] = $depended_module;
            }
        }
        return $dependency_list;
    }
@param string $module
@param array $module_dependency_map
@param array $cyclic_reference_list

@return string[]

@throws CyclicReferencedModuleException