public static function formatRoles(array $roles, $force = false): array
    {
        if ($force || version_compare(Kernel::VERSION, '4.3', '<')) {
            $roles = array_map(static function ($role) {
                return !$role instanceof Role ? new Role((string) $role) : $role;
            }, $roles);
        }

        return $roles;
    }