private static function collectClosures(&$input) {
        static $closureNo = 1;
        $closures = [];
        if (is_array($input)) {
            foreach ($input as &$value) {
                if (is_array($value) || $value instanceof Closure) {
                    $closures = array_merge($closures, self::collectClosures($value));
                }
            }
        } elseif ($input instanceof Closure) {
            $closureNo++;
            $key = "--==<<[[((Closure#$closureNo))]]>>==--";
            $closures[$key] = $input;
            $input = $key;
        }

        return $closures;
    }