Currently logged in user's roles
Something like:

$current_user = \Drupal::currentUser();
$roles = $current_user-&gt;getRoles();


will return an array like:

Array
(
  [0] =&gt; authenticated
  [1] =&gt; administrator
  [2] =&gt; some_other_role
)


where the array values are role IDs (equivalent to the machine name of the role in Drupal 7).  In OO code, use the appropriate mechanism get the current user from the container, eg

$current_user = $container-&gt;get('current_user');