src/Lib/TreeScanner.php
protected static function branch(array $paths, array $branches): array
    {
        $twig = array_shift($branches);
        if (count($branches) == 0) {
            $paths[] = $twig;

            return $paths;
        }

        if (!isset($paths[$twig])) {
            $paths[$twig] = [];
        }

        $paths[$twig] = static::branch($paths[$twig], $branches);

        return $paths;
    }
protected static function branch(array $paths, array $branches): array
    {
        $twig = array_shift($branches);
        if (count($branches) == 0) {
            $paths[] = $twig;

            return $paths;
        }

        if (!isset($paths[$twig])) {
            $paths[$twig] = [];
        }

        $paths[$twig] = static::branch($paths[$twig], $branches);

        return $paths;
    }
protected static function branch ( array $ paths , array $ branches ) : array { $ twig = array_shift ( $ branches ) ; if ( count ( $ branches ) == 0 ) { $ paths [ ] = $ twig ; return $ paths ; } if ( ! isset ( $ paths [ $ twig ] ) ) { $ paths [ $ twig ] = [ ] ; } $ paths [ $ twig ] = static :: branch ( $ paths [ $ twig ] , $ branches ) ; return $ paths ; }
Create a branch for the current level and push a twig on it.

@param array $paths    Paths to append.
@param array $branches Branches to use untill only one left.

@return array
Create a branch for the current level and push a twig on it .