-
Improvement
-
Resolution: Fixed
-
Minor
-
3.1
-
MOODLE_31_STABLE
-
MOODLE_32_STABLE
-
MDL-56372_static_bind_clean_return_val -
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::
- has a non-specific relationship to
-
MDL-56330 clean_returnvalue removes keys from external_multiple_structure
-
- Closed
-