Error:Path cannot be empty, inside of Closure function

Error:Path cannot be empty, inside of Closure function

我正在尝试构建一个 Model/View/Controller 框架,我想包含我的视图文件。
我从 codeigniter 复制代码,然后编辑它:

if( ! is_file($file_location)){
    throw new Exception("`$name` is Not Found in Views");
}
$output = (function (): string {
    // extract($data);
    ob_start();
    include $file_location;
    return ob_get_clean() ?: '';
})();// this is line 25

我得到了一个异常并且我抓住了它:

Error:Path cannot be empty
line        25  
function        {closure}

也许这应该有效:

if( ! is_file($file_loc)){
    throw new Exception("`$name` is Not Found in Views");
}
$output = (function () use ($file_loc): string {
    // extract($data);
    ob_start();
    include $file_loc;
    return ob_get_clean() ?: '';
})();// this is line 25