src/Rbac/DbManager.php
public function getRolesByUser($userId)
    {
        if ($this->isEmptyUserId($userId)) {
            return resolve([]);
        }

        $query = (new Query())->select('b.*')
            ->from(['a' => $this->assignmentTable, 'b' => $this->itemTable])
            ->where('{{a}}.[[item_name]]={{b}}.[[name]]')
            ->andWhere(['a.user_id' => (string)$userId])
            ->andWhere(['b.type' => Item::TYPE_ROLE]);

        $roles = $this->getDefaultRoleInstances();

        return $query->all($this->db)->then(
            function($rows) use ($roles) {
                foreach ($rows as $row) {
                    $roles[$row['name']] = $this->populateItem($row);
                }
                return $roles;
            }
        );
    }
public function getRolesByUser($userId)
    {
        if ($this->isEmptyUserId($userId)) {
            return resolve([]);
        }

        $query = (new Query())->select('b.*')
            ->from(['a' => $this->assignmentTable, 'b' => $this->itemTable])
            ->where('{{a}}.[[item_name]]={{b}}.[[name]]')
            ->andWhere(['a.user_id' => (string)$userId])
            ->andWhere(['b.type' => Item::TYPE_ROLE]);

        $roles = $this->getDefaultRoleInstances();

        return $query->all($this->db)->then(
            function($rows) use ($roles) {
                foreach ($rows as $row) {
                    $roles[$row['name']] = $this->populateItem($row);
                }
                return $roles;
            }
        );
    }
{@inheritdoc}
The roles returned by this method include the roles assigned via [[$defaultRoles]].