original_string: public static function delete_favourites_for_user(approved_contextlist $contextlist, string $component, string $itemtype,
                                                        int $itemid = 0) {
          global $DB;
  
          $userid = $contextlist->get_user()->id;
  
          list($insql, $inparams) = $DB->get_in_or_equal($contextlist->get_contextids(), SQL_PARAMS_NAMED);
  
          $params = [
              'userid' => $userid,
              'component' => $component,
              'itemtype' => $itemtype,
          ];
          $params += $inparams;
  
          $select = "userid = :userid AND component = :component AND itemtype =:itemtype AND contextid $insql";
  
          if (!empty($itemid)) {
              $select .= " AND itemid = :itemid";
              $params['itemid'] = $itemid;
          }
  
          $DB->delete_records_select('favourite', $select, $params);
      }
code: public static function delete_favourites_for_user(approved_contextlist $contextlist, string $component, string $itemtype,
                                                        int $itemid = 0) {
          global $DB;
  
          $userid = $contextlist->get_user()->id;
  
          list($insql, $inparams) = $DB->get_in_or_equal($contextlist->get_contextids(), SQL_PARAMS_NAMED);
  
          $params = [
              'userid' => $userid,
              'component' => $component,
              'itemtype' => $itemtype,
          ];
          $params += $inparams;
  
          $select = "userid = :userid AND component = :component AND itemtype =:itemtype AND contextid $insql";
  
          if (!empty($itemid)) {
              $select .= " AND itemid = :itemid";
              $params['itemid'] = $itemid;
          }
  
          $DB->delete_records_select('favourite', $select, $params);
      }
code_tokens: public static function delete_favourites_for_user ( approved_contextlist $ contextlist , string $ component , string $ itemtype , int $ itemid = 0 ) { global $ DB ; $ userid = $ contextlist -> get_user ( ) -> id ; list ( $ insql , $ inparams ) = $ DB -> get_in_or_equal ( $ contextlist -> get_contextids ( ) , SQL_PARAMS_NAMED ) ; $ params = [ 'userid' => $ userid , 'component' => $ component , 'itemtype' => $ itemtype , ] ; $ params += $ inparams ; $ select = "userid = :userid AND component = :component AND itemtype =:itemtype AND contextid $insql" ; if ( ! empty ( $ itemid ) ) { $ select .= " AND itemid = :itemid" ; $ params [ 'itemid' ] = $ itemid ; } $ DB -> delete_records_select ( 'favourite' , $ select , $ params ) ; }
docstring: Delete all favourites for the specified user, in the specified contexts.
  
  @param approved_contextlist $contextlist The approved contexts and user information to delete information for.
  @param string $component The favourite's component name.
  @param string $itemtype The favourite's itemtype.
  @param int $itemid Optional itemid associated with component.
  @throws \coding_exception
  @throws \dml_exception
docstring_tokens: Delete all favourites for the specified user in the specified contexts .