Skip to content

Commit

Permalink
MDL-73869 reportbuilder: Fix casting to string in report actions
Browse files Browse the repository at this point in the history
  • Loading branch information
dravek committed Feb 14, 2022
1 parent d24a4ab commit af84b16
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions reportbuilder/classes/local/report/action.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ final class action {
*
* @param moodle_url $url
* @param pix_icon $icon
* @param array $attributes
* @param string[] $attributes Array of attributes to include in action, each will be cast to string prior to use
* @param bool $popup
* @param ?lang_string $title
*/
Expand Down Expand Up @@ -136,15 +136,15 @@ public function get_action_link(stdClass $row): ?string {
/**
* Given an array of values, replace all placeholders with corresponding property of the given row
*
* @param array $values
* @param string[] $values
* @param stdClass $row
* @return array
*/
private static function replace_placeholders(array $values, stdClass $row): array {
return array_map(static function($value) use ($row) {
return preg_replace_callback('/^:(?<property>.*)$/', static function(array $matches) use ($row): string {
return (string) ($row->{$matches['property']} ?? '');
}, $value);
}, (string) $value);
}, $values);
}
}

0 comments on commit af84b16

Please sign in to comment.