original_string: public function getRolesByUser($userGuid)
      {
          if (!isset($userGuid) || $userGuid === '') {
              return [];
          }
          
          if ($userGuid instanceof User) {
              $userGuid = $userGuid->getGUID();
          }
  
          $query = (new Query)->select('b.*')
              ->from(['a' => $this->assignmentTable, 'b' => $this->itemTable])
              ->where('{{a}}.[[item_name]]={{b}}.[[name]]')
              ->andWhere(['a.user_guid' => (string) $userGuid])
              ->andWhere(['b.type' => Item::TYPE_ROLE]);
  
          $roles = [];
          foreach ($query->all($this->db) as $row) {
              $roles[$row['name']] = $this->populateItem($row);
          }
          return $roles;
      }
code: public function getRolesByUser($userGuid)
      {
          if (!isset($userGuid) || $userGuid === '') {
              return [];
          }
          
          if ($userGuid instanceof User) {
              $userGuid = $userGuid->getGUID();
          }
  
          $query = (new Query)->select('b.*')
              ->from(['a' => $this->assignmentTable, 'b' => $this->itemTable])
              ->where('{{a}}.[[item_name]]={{b}}.[[name]]')
              ->andWhere(['a.user_guid' => (string) $userGuid])
              ->andWhere(['b.type' => Item::TYPE_ROLE]);
  
          $roles = [];
          foreach ($query->all($this->db) as $row) {
              $roles[$row['name']] = $this->populateItem($row);
          }
          return $roles;
      }
code_tokens: public function getRolesByUser ( $ userGuid ) { if ( ! isset ( $ userGuid ) || $ userGuid === '' ) { return [ ] ; } if ( $ userGuid instanceof User ) { $ userGuid = $ userGuid -> getGUID ( ) ; } $ query = ( new Query ) -> select ( 'b.*' ) -> from ( [ 'a' => $ this -> assignmentTable , 'b' => $ this -> itemTable ] ) -> where ( '{{a}}.[[item_name]]={{b}}.[[name]]' ) -> andWhere ( [ 'a.user_guid' => ( string ) $ userGuid ] ) -> andWhere ( [ 'b.type' => Item :: TYPE_ROLE ] ) ; $ roles = [ ] ; foreach ( $ query -> all ( $ this -> db ) as $ row ) { $ roles [ $ row [ 'name' ] ] = $ this -> populateItem ( $ row ) ; } return $ roles ; }
docstring: Get roles by user.
  @param string|User $userGuid
  @return array
docstring_tokens: Get roles by user .