命名空间问题。使用错误对象的方法

Issue with namespace. Using method from wrong object

我的以下代码有问题。我得到的错误是:

Catchable fatal error: Argument 1 passed to Closure::QuizApp\Routes{closure}() must be an instance of QuizApp\Routes\ServerRequestInterface, instance of Slim\Http\Request given in /var/www/QuizApp/Routes/AuthRoutes.php on line 8

这是因为我在顶部声明了一个命名空间吗?我可以通过使用别名来解决它,但我很好奇为什么它首先会发生。

<?php

namespace QuizApp\Routes;

use \Psr\Http\Message\ServiceRequestInterface;
use \Psr\Http\Message\ResponseInterface;

$app->get('/login', function(ServerRequestInterface $req, ResponseInterface $resp) use ($config) {

    $callback = $config['site']['domain'] . $this->router->pathFor('fb_callback');
    return $this->FBAuthServices->redirect_to_auth_page($config['facebook']['permission'],
                                                        $callback);

});

编辑 查看我自己的代码后,我意识到我什至不需要命名空间。此文件中的 class 现在已被移出。不过我还是很想知道答案,我很好奇。

比较这些

must be an instance of QuizApp\Routes\ServerRequestInterface

use \Psr\Http\Message\ServiceRequestInterface;

打错了,应该在use中命名为ServerRequestInterface