Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-56372

use static:: for late binding instead of self:: in clean_returnvalue class

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.2
    • 3.1
    • Web Services

      use static:: for late binding instead of self:: in clean_returnvalue class
      I'm wanting to override the clean_returnvalue function tofor my external api class
      I only want to override the external_multiple_structure bit
      It almost works like so:

      class external extends external_api {
          public static function clean_returnvalue(external_description $description, $response) {
              if ($description instanceof external_multiple_structure) {
                  if (!is_array($response)) {
                      throw new invalid_response_exception('Only arrays accepted. The bad value is: \'' .
                                                           print_r($response, true) . '\'');
                  }
                  $result = array();
                  foreach ($response as $key=> $param) {
                      $result[$key] = static::clean_returnvalue($description->content, $param);
                  }
                  return $result;
       
              } else {
                  return parent::clean_returnvalue($description, $response);
              }
          }
      

      But because the parent clean_returnvalue refers to itself with self:: instead of static:: future recursion calls only call the parent class not my extended version.

      Would be great if we could get policy added/changed to use static for late binding always instead of self::

            berserkk Ben Kelada
            berserkk Ben Kelada
            Russell Smith Russell Smith (Inactive)
            Dan Poltawski Dan Poltawski
            John Okely John Okely
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.