Skip to content

Symfony's UserInterface roles variable #1478

Open
@Terroraapje

Description

@Terroraapje

Hello,

I'm getting the following exception:
Property \"GamePoint\\Entity\\User\\Player:roles\" is an array, but no indication of the array elements are made. Use e.g. string[] for an array of string.

I have a User class with implements Symfony's UserInterface (Symfony\Component\Security\Core\User\UserInterface).

Player extends User.

class User implements UserInterface
{
    const ROLE_ADMIN = 'ROLE_ADMIN';
    const ROLE_SUPERADMIN = 'ROLE_SUPERADMIN';
    const ROLE_TESTER = 'ROLE_TESTER';
    /**
     * @ORM\Column(type="string", length=255, unique=true)
     * @SWG\Property(description="Name used ingame of the User")
     */
    private $username;

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     * @SWG\Property(description="Encrypted password of the User")
     */
    private $password;

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     * @SWG\Property(description="Emailaddress of the User")
     */
    private $email;

    /**
     * @ORM\Column(type="integer", nullable=true)
     * @SWG\Property(description="Status of the User")
     */
    private $status;

    /**
     * @SWG\Property(type="array", @SWG\Items(type="string"))
     * @ORM\Column(type="array", nullable=true)
     */
    private $roles;
}
class Player extends User
{
    /**
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     * @SWG\Property(description="ID of the Player")
     */
    private $id;
}

The really weird part is, is when I move the complete $roles section (getters, setters, has ....) to Player, everything works fine.

What am I doing wrong here? And how to fix?

Thing I have tried:

  • add @var string[] and remove Swagger Annotation

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions