src/Application/App.php
public function addGroup(string $path, callable $callable, $middleware = null): self
    {
        $reflection = new \ReflectionFunction($callable);
        $params = $reflection->getParameters();

        if (1 !== count($params)) {
            throw new \InvalidArgumentException('Invalid number argument');
        }

        $arg = $params[0];

        if (!$arg->getClass()->isInstance($this)) {
            throw new \InvalidArgumentException('Callback argument must be implement ' . get_class($this));
        }

        $previousGroupPath = $this->groupPath;
        $this->groupPath = $previousGroupPath . $path;

        if (null !== $middleware) {
            $previousGroupMiddleware = $this->groupMiddleware;
            $this->groupMiddleware[] = $middleware;
        }

        $callable($this);

        $this->groupPath = $previousGroupPath;

        if (null !== $middleware) {
            $this->groupMiddleware = $previousGroupMiddleware;
        }

        return $this;
    }
public function addGroup(string $path, callable $callable, $middleware = null): self
    {
        $reflection = new \ReflectionFunction($callable);
        $params = $reflection->getParameters();

        if (1 !== count($params)) {
            throw new \InvalidArgumentException('Invalid number argument');
        }

        $arg = $params[0];

        if (!$arg->getClass()->isInstance($this)) {
            throw new \InvalidArgumentException('Callback argument must be implement ' . get_class($this));
        }

        $previousGroupPath = $this->groupPath;
        $this->groupPath = $previousGroupPath . $path;

        if (null !== $middleware) {
            $previousGroupMiddleware = $this->groupMiddleware;
            $this->groupMiddleware[] = $middleware;
        }

        $callable($this);

        $this->groupPath = $previousGroupPath;

        if (null !== $middleware) {
            $this->groupMiddleware = $previousGroupMiddleware;
        }

        return $this;
    }
@param string   $path
@param callable $callable
@param null     $middleware

@return App