Can you try the following snippet:
$user = \Drupal::currentUser();
$user_roles = $user->getRoles();
$roles_permissions = user_role_permissions($user_roles);
This will give you permissions grouped by roles.
But most likely you want them in one array.
Therefore you can use this
$final_array = array();
foreach ($roles_permissions as $role_key => $permissions) {
foreach ($permissions as $permission) {
$final_array[] = $permission;
}
}
In case you want to load different user than the currently logged-in user, you can use
$some_user = \Drupal\user\Entity\User::load(123);
Where 123 stands for the user id.
For more information:
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21Entity.php/function/Entity%3A%3Aload/8.2.x
Best regards,
Oleg