Skip to content

PHPDocBlock for getKey incorrect #2

Description

@burnhamrobertp
/**
     * Gets the key of the provided value.
     *
     * @param string $value The value.
     *
     * **@return boolean The key if found, false otherwise.**
     */
    public static function getKey($value)
    {
        return array_search($value, static::getAll(), true);
    }

array_search will return the element, if found, which would be a string

...

class UserRoles extends AbstractEnum
{
    const ADMIN = 1;
    const MODERATOR = 2;
    const CLIENT = 3;
    const WRITER = 4;
}

UserRoles::getKey(3) will return 'client'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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