MDL-76362 core: Coding style fixes

This commit is contained in:
Andrew Nicols
2023-01-23 09:15:55 +08:00
parent ce85ef1e49
commit 7000a99de3
7 changed files with 13 additions and 12 deletions
@@ -55,8 +55,10 @@ class restore_structure_parser_processor extends grouped_parser_processor {
return '';
} else if (is_numeric($cdata)) {
return $cdata;
} else if (strlen($cdata ?? '') < 32) { // Impossible to have one link in 32cc
return $cdata; // (http://10.0.0.1/file.php/1/1.jpg, http://10.0.0.1/mod/url/view.php?id=)
} else if (strlen($cdata ?? '') < 32) {
// Impossible to have one link in 32cc.
// (http://10.0.0.1/file.php/1/1.jpg, http://10.0.0.1/mod/url/view.php?id=).
return $cdata;
}
if (strpos($cdata, '$@FILEPHP@$') !== false) {
+1 -1
View File
@@ -107,7 +107,7 @@ abstract class xml_output {
if (!$this->running) {
throw new xml_output_exception('xml_output_not_started');
}
$lenc = strlen($content ?? ''); // Get length in bytes
$lenc = strlen($content ?? ''); // Get length in bytes.
if ($lenc == 0) { // 0 length contents, nothing to do
return;
}
+1 -1
View File
@@ -260,7 +260,7 @@ class xml_writer {
* ignores the rest of characters. Also normalize linefeeds and return chars.
*/
protected function xml_safe_utf8($content) {
$content = preg_replace('/[\x-\x8\xb-\xc\xe-\x1f\x7f]/is','', $content ?? ''); // clean CTRL chars
$content = preg_replace('/[\x-\x8\xb-\xc\xe-\x1f\x7f]/is', '', $content ?? ''); // clean CTRL chars.
$content = preg_replace("/\r\n|\r/", "\n", $content); // Normalize line&return=>line
return $content;
}
@@ -405,16 +405,15 @@ class user extends tablelike implements selectable_items {
$gradeitem = grade_item::fetch([
'courseid' => $this->courseid,
'id' => $matches[1]
'id' => $matches[1],
]);
$isscale = ($gradeitem->gradetype == GRADE_TYPE_SCALE);
$empties = (trim($value ?? '') === '' or ($isscale and $value == -1));
$empties = (trim($value ?? '') === '' || ($isscale && $value == -1));
if ($filter == 'all' or $empties) {
$data->$varname = ($isscale and empty($insertvalue)) ?
-1 : $insertvalue;
if ($filter == 'all' || $empties) {
$data->$varname = ($isscale && empty($insertvalue)) ? -1 : $insertvalue;
}
}
}
+1 -1
View File
@@ -1800,7 +1800,7 @@ class file_storage {
// the latter of which can go to 100, we need to make sure that quality here is
// in a safe range or PHP WILL CRASH AND DIE. You have been warned.
$quality = $quality > 9 ? (int)(max(1.0, (float)$quality / 100.0) * 9.0) : $quality;
imagepng($img, NULL, $quality, PNG_NO_FILTER);
imagepng($img, null, $quality, PNG_NO_FILTER);
break;
default:
+1 -1
View File
@@ -123,7 +123,7 @@ class calc_formula {
* @return string localised formula
*/
public static function localize($formula) {
$formula = str_replace('.', '$', $formula ?? ''); // temp placeholder
$formula = str_replace('.', '$', $formula ?? ''); // Temp placeholder.
$formula = str_replace(',', get_string('listsep', 'langconfig'), $formula);
$formula = str_replace('$', get_string('decsep', 'langconfig'), $formula);
return $formula;
+1 -1
View File
@@ -342,7 +342,7 @@ class mod_workshop_portfolio_caller extends portfolio_module_caller_base {
}
if ($this->workshop->overallfeedbackmode) {
if ($assessment->feedbackauthorattachment or trim($assessment->feedbackauthor ?? '') !== '') {
if ($assessment->feedbackauthorattachment || trim($assessment->feedbackauthor ?? '') !== '') {
$output .= html_writer::tag('h3', get_string('overallfeedback', 'mod_workshop'));
$content = $this->format_exported_text($assessment->feedbackauthor, $assessment->feedbackauthorformat);
$content = portfolio_rewrite_pluginfile_urls($content, $this->workshop->context->id, 'mod_workshop',