8000 Better getRoles() annotation in UserInterface · Issue #13530 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Better getRoles() annotation in UserInterface #13530
Closed
@lrlopez

Description

@lrlopez

Hi,

When I run one of my projects over Scrutinizer I realized that the return type stated in the annotation of the method UserInterface::getRoles()is Role[]. This is correct, but most (if not all) examples return an array of strings instead. It works, but it just doesn't look right.

Have you considered to modify the annotation in the interface so it look like this?

interface UserInterface
{
    /**
     * Returns the roles granted to the user.
     *
     * <code>
     * public function getRoles()
     * {
     *     return array('ROLE_USER');
     * }
     * </code>
     *
     * [...]
     *
     * @return Role[]|array The user roles
     */
    public function getRoles();

(notice the alternate return type in the @return annotation)

Even the provided example returns an array of strings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0