Код: Выделить всё
------ -----------------------------------------------------------------------------------------------------------------------------------------------
Line src/Entity/User.php
------ -----------------------------------------------------------------------------------------------------------------------------------------------
93 Return type (array) of method App\Entity\User::getRoles() should be compatible with return type (array) of method
Symfony\Component\Security\Core\User\UserInterface::getRoles()
------ -----------------------------------------------------------------------------------------------------------------------------------------------
Код: Выделить всё
namespace App\Security;
enum Roles: string
{
case Admin = 'ROLE_ADMIN';
case User = 'ROLE_USER';
}
Код: Выделить всё
/**
* @see UserInterface
* @return array
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = Roles::User->value;
return array_unique($roles);
}
/**
* @param array $roles
*/
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
Код: Выделить всё
/**
* @return string[]
*/
public function getRoles(): array;
Подробнее здесь: https://stackoverflow.com/questions/714 ... th-phpstan
Мобильная версия