Check if the user has at least one role.

@param array $roles
@return bool
481385
protected function isOne(array $roles)
    {
        foreach ($roles as $role) {
            if ($this->hasRole($role)) {
                return true;
            }
        }

        return false;
    }
1022892
public function hasRole(Role $role)
    {
        $this->initializeRoles();
        return array_key_exists($role->getIdentifier(), $this->roles);
    }
956769
public function hasUserRoles($roles)
	{
		if ($this->session_machine === null) {
			throw new RuntimeException('Session machine not ready ‒ '.__METHOD__.' called too soon.');
		}

		if (is_array($roles)) {
			return count(array_intersect($this->getUserRoles(), $roles)) > 0;
		} else {
			return in_array($roles, $this->getUserRoles());
		}
	}
591874
public function beforeRole($roles)
    {
        $roles = is_array($roles) ? $roles : func_get_args();

        $this->beforeFilter(function () use ($roles) {
            Trusty::filterByRole($roles);
        });
    }
653066
public function personalWorkspaceAllowed($roles)
    {
        $roles[] = $this->roleManager->getRoleByName('ROLE_USER');

        foreach ($roles as $role) {
            if ($role->isPersonalWorkspaceCreationEnabled()) {
                return true;
            }
        }

        return false;
    }
177037
public function hasRoles($roles)
    {
        if ($this->user() === null) {
            return null;
        }

        if (!is_array($roles)) {
            $roles = func_get_args();
        }

        // Count roles because user need user to have all roles passed as parameter
        return count(array_intersect($roles, $this->roles)) === count($roles);
    }
357217
public function hasRoles($roles): bool
    {
        $userRoles = $this->getRoles()->all();

        // We should ensure that all given roles match the current user,
        // consider it as a AND condition instead of OR.
        foreach ((array) $roles as $role) {
            if (! \in_array($role, $userRoles)) {
                return false;
            }
        }

        return true;
    }
1324580
public function isGranted($user, $role)
    {
        if (true === $user->hasRole($role)) {
            return true;
        }

        $roleHierarchy = new RoleHierarchy($this->getRoleHierarchyRoles());

        $userRoles = array_map(function ($role) {
            return new Role($role);
        }, $user->getRoles());

        $roles = $roleHierarchy->getReachableRoles($userRoles);
        $roles = array_map(function (Role $role) {
            return $role->getRole();
        }, $roles);

        return in_array($role, $roles);
    }
477500
public function hasRole($role) {
		if (empty($role) || !\is_numeric($role)) {
			return false;
		}

		if (isset($_SESSION) && isset($_SESSION[self::SESSION_FIELD_ROLES])) {
			$role = (int) $role;

			return (((int) $_SESSION[self::SESSION_FIELD_ROLES]) & $role) === $role;
		}
		else {
			return false;
		}
	}
905214
public function hasRole($role)
    {
        if ($this->user() === null) {
            return null;
        }

        return in_array($role, $this->roles, true);
    }
286826
public function hasRoleForUser($name, $role)
    {
        $roles = $this->getRolesForUser($name);

        $hasRole = false;
        foreach ($roles as $r) {
            if ($r == $role) {
                $hasRole = true;

                break;
            }
        }

        return $hasRole;
    }
582569
public function hasOneRole($role)
    {
        foreach ($this->getArrayFrom($role) as $role) {
            if ($this->checkRole($role)) {
                return true;
            }
        }

        return false;
    }
1288132
public function satisfiedByRoles(Roles $roles = null): bool
    {
        if (null === $roles) {
            return false;
        }

        if ($this->callbackAnnotatedWith->rolesAware()) {
            return true;
        }

        return $roles->contain($this->requiredRole());
    }
641367
public function hasRole($role)
    {
        if (is_string($role)) {
            return $this->roles->contains('name', $role);
        }

        if (is_array($role)) {
            foreach ($role as $r) {
                if ($this->hasRole($r)) {
                    return true;
                }
            }

            return false;
        }

        return !!$role->intersect($this->roles)->count();
    }
1015011
public function hasRoleWithName(string $role): bool
    {
        $this->compileUserRoles();

        return in_array($role, $this->userRoles);
    }
237406
public function hasRoles($roles)
    {
        $roles = is_array($roles) ? $roles : func_get_args();

        foreach ($roles as $role) {
            if ($this->hasRole($role)) {
                return true;
            }
        }

        return false;
    }
779122
public function isAll($roles, &$failed = null)
    {
        $this->isOne($roles, $failed);

        return $failed->isEmpty();
    }