Cannot access empty property error in Advanced Access Manager

Here is the solution I’ve made that it’s now working properly:

function getCurrentUserRole() {
  if (isset($this->data) && isset($this->data->{$this->cap_key}) && is_object($this->data) && is_array($this->data->{$this->cap_key}) ) {
     $result = array_keys($this->data->{$this->cap_key});
  } else {
     $result = array();
  }

  return $result;
}