public static function addRepositoryInstance(IOInterface $io, RepositoryManager $rm, array &$repos, $name, RepositoryInterface $repo, Pool $pool = null)
    {
        $notAddedRepo = null;

        if (!isset($repos[$name])) {
            static::writeAddRepository($io, $name);
            $notAddedRepo = $repo;
            $repos[$name] = $repo;
            $rm->addRepository($repo);

            if (null !== $pool) {
                $pool->addRepository($repo);
                $notAddedRepo = null;
            }
        }

        return $notAddedRepo;
    }