original_string: public static function add_userids_for_context(\core_privacy\local\request\userlist $userlist,
                                                     string $itemtype = null) {
          if (empty($userlist)) {
              return;
          }
  
          $params = [
              'contextid' => $userlist->get_context()->id,
              'component' => $userlist->get_component()
          ];
  
          $sql = "SELECT userid
                    FROM {favourite}
                   WHERE contextid = :contextid
                         AND component = :component";
  
          if (!is_null($itemtype)) {
              $sql .= " AND itemtype = :itemtype";
              $params['itemtype'] = $itemtype;
          }
  
          $userlist->add_from_sql('userid', $sql, $params);
      }
code: public static function add_userids_for_context(\core_privacy\local\request\userlist $userlist,
                                                     string $itemtype = null) {
          if (empty($userlist)) {
              return;
          }
  
          $params = [
              'contextid' => $userlist->get_context()->id,
              'component' => $userlist->get_component()
          ];
  
          $sql = "SELECT userid
                    FROM {favourite}
                   WHERE contextid = :contextid
                         AND component = :component";
  
          if (!is_null($itemtype)) {
              $sql .= " AND itemtype = :itemtype";
              $params['itemtype'] = $itemtype;
          }
  
          $userlist->add_from_sql('userid', $sql, $params);
      }
code_tokens: public static function add_userids_for_context ( \ core_privacy \ local \ request \ userlist $ userlist , string $ itemtype = null ) { if ( empty ( $ userlist ) ) { return ; } $ params = [ 'contextid' => $ userlist -> get_context ( ) -> id , 'component' => $ userlist -> get_component ( ) ] ; $ sql = "SELECT userid
                    FROM {favourite}
                   WHERE contextid = :contextid
                         AND component = :component" ; if ( ! is_null ( $ itemtype ) ) { $ sql .= " AND itemtype = :itemtype" ; $ params [ 'itemtype' ] = $ itemtype ; } $ userlist -> add_from_sql ( 'userid' , $ sql , $ params ) ; }
docstring: Add users to a userlist who have favourites within the specified context.
  
  @param \core_privacy\local\request\userlist $userlist The userlist to add the users to.
  @param string $itemtype the type of the favourited items.
  @return void
docstring_tokens: Add users to a userlist who have favourites within the specified context .