我正在尝试使用fosoauthserverbundle,但遇到崩溃问题,崩溃消息是:
PHP Fatal error: Declaration of MP\OAuthBundle\Entity\AccessToken::setUser() must be compatible with that of FOS\OAuthServerBundle\Model\TokenInterface::setUser() in /home/bitnami..../OAuthBundle/Entity/AccessToken.php on line 13
accessToken.Class:类:
<?php
namespace MP\OAuthBundle\Entity;
use FOS\OAuthServerBundle\Entity\AccessToken as BaseAccessToken;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="oauth_access_tokens")
*/
class AccessToken extends BaseAccessToken
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\ManyToOne(targetEntity="Client")
* @ORM\JoinColumn(nullable=false)
*/
protected $client;
/**
* @ORM\ManyToOne(targetEntity="\MP\UserBundle\Entity\User")
*/
protected $user;
}
令牌接口::设置用户:
/**
* @param UserInterface $user
*/
function setUser(UserInterface $user);
小精灵
namespace MP\UserBundle\Entity;
use Symfony\Component\Security\Core\User\UserInterface;
use Doctrine\ORM\Mapping as ORM;
use FOS\UserBundle\Model\User as BaseUser;
/**
* User
*/
class User extends BaseUser
{
const ROLE_ADMIN = 'ROLE_ADMIN';
/**
* @var integer
...
我还是看不出问题在哪里!我的用户正在最后实现用户界面!
有什么想法吗?
最佳答案
确保MP\OAuthBundle\Entity\AccessToken
中有以下两个use语句
use Symfony\Component\Security\Core\User\UserInterface;
use FOS\OAuthServerBundle\Model\ClientUserInterface;
您必须确保
AccessToken
实现FOS\OAuthServerBundle\Model\TokenInterface
,其中包括具有相同接口的函数声明。如果你有…
function setUser(UserInterface $user)
…在
AccessToken
内部尝试实现TokenInterface
但没有use语句……
UserInterface
将转换为MP\OAuthBundle\Entity\UserInterface
…但必须是
Symfony\Component\Security\Core\User\UserInterface
。结论
参数类型不匹配是php抱怨这两个函数声明不匹配的原因。