original_string: protected function add_custom_completion_rules() {
          $modnames = array_keys($this->get_module_names());
          if (count($modnames) != 1 || !plugin_supports('mod', $modnames[0], FEATURE_COMPLETION_HAS_RULES, false)) {
              return [];
          }
  
          try {
              // Add completion rules from the module form to this form.
              $moduleform = $this->get_module_form();
              $moduleform->_form = $this->_form;
              if ($customcompletionelements = $moduleform->add_completion_rules()) {
                  $this->hascustomrules = true;
              }
              return $customcompletionelements;
          } catch (Exception $e) {
              debugging('Could not add custom completion rule of module ' . $modnames[0] .
                  ' to this form, this has to be fixed by the developer', DEBUG_DEVELOPER);
              return [];
          }
      }
code: protected function add_custom_completion_rules() {
          $modnames = array_keys($this->get_module_names());
          if (count($modnames) != 1 || !plugin_supports('mod', $modnames[0], FEATURE_COMPLETION_HAS_RULES, false)) {
              return [];
          }
  
          try {
              // Add completion rules from the module form to this form.
              $moduleform = $this->get_module_form();
              $moduleform->_form = $this->_form;
              if ($customcompletionelements = $moduleform->add_completion_rules()) {
                  $this->hascustomrules = true;
              }
              return $customcompletionelements;
          } catch (Exception $e) {
              debugging('Could not add custom completion rule of module ' . $modnames[0] .
                  ' to this form, this has to be fixed by the developer', DEBUG_DEVELOPER);
              return [];
          }
      }
code_tokens: protected function add_custom_completion_rules ( ) { $ modnames = array_keys ( $ this -> get_module_names ( ) ) ; if ( count ( $ modnames ) != 1 || ! plugin_supports ( 'mod' , $ modnames [ 0 ] , FEATURE_COMPLETION_HAS_RULES , false ) ) { return [ ] ; } try { // Add completion rules from the module form to this form. $ moduleform = $ this -> get_module_form ( ) ; $ moduleform -> _form = $ this -> _form ; if ( $ customcompletionelements = $ moduleform -> add_completion_rules ( ) ) { $ this -> hascustomrules = true ; } return $ customcompletionelements ; } catch ( Exception $ e ) { debugging ( 'Could not add custom completion rule of module ' . $ modnames [ 0 ] . ' to this form, this has to be fixed by the developer' , DEBUG_DEVELOPER ) ; return [ ] ; } }
docstring: If all selected modules are of the same module type, adds custom completion rules from this module type
  
  @return array
docstring_tokens: If all selected modules are of the same module type adds custom completion rules from this module type