Laravel 5.3控制器构造函数中的中间件回调函数

as mentioned in the documentation of Laravel 5.3 i am trying to add a middleware callback in the constructor of a controller

Controller's also allow you to register middleware using a Closure. This provides a convenient way to define a middleware for a single controller without defining an entire middleware class:

$this->middleware(function ($request, $next) {
    // ...
    return $next($request);
});

unfortunately i am getting the error:

Illegal offset type

which is logical because the middleware method of the Illuminate\Routing\Controller class accepts a the first param as an array only, i am not confused why would they add this code sample to the documentation although its not gonna work, or am I doing something wrong or missing something ?

documentation page

the laravel version should be at least:

5.3.4