Skip to content

Commit

Permalink
style(php): fix coding style problems
Browse files Browse the repository at this point in the history
  • Loading branch information
jboulen committed Oct 15, 2023
1 parent 3101965 commit 7671f5e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 26 deletions.
2 changes: 1 addition & 1 deletion classes/setting/admin_setting_plugin_activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class admin_setting_plugin_activation extends admin_setting_configcheckbox {
* @return array
*/
public function get_overrided_settings() {
$settings = array();
$settings = [];
$settings['debug'] = DEBUG_DEVELOPER;
$settings['debugdisplay'] = true;
$settings['perfdebug'] = 15;
Expand Down
49 changes: 25 additions & 24 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function local_debugtoolbar_after_config() {

$PAGE->add_body_class('local-debugtoolbar-enabled');

$PERF->local_debugtoolbar = array('errors' => [], 'warnings' => [], 'notices' => [], 'deprecated' => []);
$PERF->local_debugtoolbar = ['errors' => [], 'warnings' => [], 'notices' => [], 'deprecated' => []];

if (empty(get_config('local_debugtoolbar', 'enable_error_handler')) === false) {
set_error_handler('local_debugtoolbar_error_handler');
Expand Down Expand Up @@ -124,7 +124,7 @@ function local_debugtoolbar_before_footer() {
}

$data = new stdClass();
$data->records = array();
$data->records = [];

// Moodle.
$i = 0;
Expand All @@ -135,7 +135,7 @@ function local_debugtoolbar_before_footer() {
$data->records[$i]->items[] = (object) ['title' => get_string('maturity_X', 'local_debugtoolbar', $maturitylabel)];
$data->records[$i]->items[] = (object) ['title' => get_string('php_X', 'local_debugtoolbar', phpversion())];
$data->records[$i]->items[] = (object) [
'title' => get_string('http_response_code_X', 'local_debugtoolbar', http_response_code())
'title' => get_string('http_response_code_X', 'local_debugtoolbar', http_response_code()),
];

switch ($maturity) {
Expand All @@ -159,7 +159,7 @@ function local_debugtoolbar_before_footer() {
}
}

$parameters = array('minmaturity' => $CFG->updateminmaturity, 'notifybuilds' => $CFG->updatenotifybuilds);
$parameters = ['minmaturity' => $CFG->updateminmaturity, 'notifybuilds' => $CFG->updatenotifybuilds];
if (empty($updateschecker->get_update_info('core', $parameters)) === false) {
$data->records[$i]->style = 'btn-info';
$item = (object) ['title' => get_string('updateavailable', 'admin'), 'style' => 'bg-info'];
Expand All @@ -169,7 +169,7 @@ function local_debugtoolbar_before_footer() {
// PHP alerts.
if (empty(get_config('local_debugtoolbar', 'enable_error_handler')) === false) {
$i++;
$data->alerts = array();
$data->alerts = [];
$label = get_string('no_alerts', 'local_debugtoolbar');
$data->records[$i] = (object) ['title' => $label, 'fa' => 'exclamation-circle', 'items' => []];

Expand Down Expand Up @@ -206,10 +206,10 @@ function local_debugtoolbar_before_footer() {
$label = get_string('X_secs', 'local_debugtoolbar', $performance['realtime']);
$data->records[$i] = (object) ['title' => $label, 'fa' => 'clock-o', 'items' => []];
$data->records[$i]->items[] = (object) [
'title' => get_string('total_time_X', 'local_debugtoolbar', $performance['realtime'])
'title' => get_string('total_time_X', 'local_debugtoolbar', $performance['realtime']),
];
$data->records[$i]->items[] = (object) [
'title' => get_string('load_average_X', 'local_debugtoolbar', $performance['serverload'])
'title' => get_string('load_average_X', 'local_debugtoolbar', $performance['serverload']),
];
if (isset($ticks)) {
$data->records[$i]->items[] = (object) ['title' => $ticks];
Expand All @@ -227,16 +227,16 @@ function local_debugtoolbar_before_footer() {
$label = display_size($performance['memory_total']);
$data->records[$i] = (object) ['title' => $label, 'fa' => 'microchip', 'items' => []];
$data->records[$i]->items[] = (object) [
'title' => get_string('ram_X', 'local_debugtoolbar', display_size($performance['memory_total']))
'title' => get_string('ram_X', 'local_debugtoolbar', display_size($performance['memory_total'])),
];
$data->records[$i]->items[] = (object) [
'title' => get_string('ram_growth_X', 'local_debugtoolbar', display_size($performance['memory_growth']))
'title' => get_string('ram_growth_X', 'local_debugtoolbar', display_size($performance['memory_growth'])),
];
$data->records[$i]->items[] = (object) [
'title' => get_string('ram_peak_X', 'local_debugtoolbar', display_size($performance['memory_peak']))
'title' => get_string('ram_peak_X', 'local_debugtoolbar', display_size($performance['memory_peak'])),
];
$data->records[$i]->items[] = (object) [
'title' => get_string('extra_memory_limit_X', 'local_debugtoolbar', $CFG->extramemorylimit)
'title' => get_string('extra_memory_limit_X', 'local_debugtoolbar', $CFG->extramemorylimit),
];

// Database.
Expand All @@ -248,7 +248,7 @@ function local_debugtoolbar_before_footer() {
$data->records[$i]->items[] = (object) ['title' => get_string('db_reads_X', 'local_debugtoolbar', $countread)];
$data->records[$i]->items[] = (object) ['title' => get_string('db_writes_X', 'local_debugtoolbar', $countwrite)];
$data->records[$i]->items[] = (object) [
'title' => get_string('db_queries_time_X', 'local_debugtoolbar', $performance['dbtime'])
'title' => get_string('db_queries_time_X', 'local_debugtoolbar', $performance['dbtime']),
];

if ($countread >= get_config('local_debugtoolbar', 'dbqueries_critical_threshold')) {
Expand All @@ -262,7 +262,7 @@ function local_debugtoolbar_before_footer() {
// Cache.
$i++;
list($cachehits, $cachemisses, $cachesets) = explode('/', $performance['cachesused']);
foreach (array('cachehits', 'cachemisses', 'cachesets') as $variable) {
foreach (['cachehits', 'cachemisses', 'cachesets'] as $variable) {
${$variable} = trim(${$variable});
}
$cachecalls = $cachehits + $cachemisses;
Expand All @@ -277,33 +277,34 @@ function local_debugtoolbar_before_footer() {
$data->records[$i]->items[] = (object) ['title' => get_string('cache_misses_X', 'local_debugtoolbar', $cachemisses)];
$data->records[$i]->items[] = (object) ['title' => get_string('cache_sets_X', 'local_debugtoolbar', $cachesets)];
$data->records[$i]->items[] = (object) [
'title' => get_string('included_X_files', 'local_debugtoolbar', $performance['includecount'])
'title' => get_string('included_X_files', 'local_debugtoolbar', $performance['includecount']),
];
$data->records[$i]->items[] = (object) [
'title' => get_string('more...', 'local_debugtoolbar'), 'modal' => 'local-debugtoolbar-cache'
'title' => get_string('more...', 'local_debugtoolbar'), 'modal' => 'local-debugtoolbar-cache',
];

// String.
$i++;
$label = get_string('filters_and_strings', 'local_debugtoolbar');
$data->records[$i] = (object) ['title' => $label, 'fa' => 'book', 'items' => []];
$label = get_string('contexts_for_which_filters_were_loaded_X', 'local_debugtoolbar', $performance['contextswithfilters']);
$data->records[$i]->items[] = (object) [
'title' => get_string('contexts_for_which_filters_were_loaded_X', 'local_debugtoolbar', $performance['contextswithfilters'])
'title' => $label,
];
$data->records[$i]->items[] = (object) [
'title' => get_string('filters_created_X', 'local_debugtoolbar', $performance['filterscreated'])
'title' => get_string('filters_created_X', 'local_debugtoolbar', $performance['filterscreated']),
];
$data->records[$i]->items[] = (object) [
'title' => get_string('pieces_of_content_filtered_X', 'local_debugtoolbar', $performance['textsfiltered'])
'title' => get_string('pieces_of_content_filtered_X', 'local_debugtoolbar', $performance['textsfiltered']),
];
$data->records[$i]->items[] = (object) [
'title' => get_string('strings_filtered_X', 'local_debugtoolbar', $performance['stringsfiltered'])
'title' => get_string('strings_filtered_X', 'local_debugtoolbar', $performance['stringsfiltered']),
];
$data->records[$i]->items[] = (object) [
'title' => get_string('get_string_calls_X', 'local_debugtoolbar', $performance['langcountgetstring'])
'title' => get_string('get_string_calls_X', 'local_debugtoolbar', $performance['langcountgetstring']),
];
$data->records[$i]->items[] = (object) [
'title' => get_string('included_X_files', 'local_debugtoolbar', $performance['includecount'])
'title' => get_string('included_X_files', 'local_debugtoolbar', $performance['includecount']),
];

// Sessions.
Expand All @@ -313,10 +314,10 @@ function local_debugtoolbar_before_footer() {
$si = \core\session\manager::get_performance_info();
$data->records[$i]->items[] = (object) ['title' => $si['txt']];
$data->records[$i]->items[] = (object) [
'title' => get_string('session_wait_X', 'local_debugtoolbar', number_format($PERF->sessionlock['wait'], 3))
'title' => get_string('session_wait_X', 'local_debugtoolbar', number_format($PERF->sessionlock['wait'], 3)),
];
$data->records[$i]->items[] = (object) [
'title' => get_string('more...', 'local_debugtoolbar'), 'modal' => 'local-debugtoolbar-sessions'
'title' => get_string('more...', 'local_debugtoolbar'), 'modal' => 'local-debugtoolbar-sessions',
];

// User.
Expand All @@ -331,7 +332,7 @@ function local_debugtoolbar_before_footer() {
$data->records[$i]->items[] = (object) ['title' => get_string('general_type_X', 'local_debugtoolbar', $PAGE->pagelayout)];
$data->records[$i]->items[] = (object) ['title' => get_string('contextid_X', 'local_debugtoolbar', $PAGE->context->id)];
$data->records[$i]->items[] = (object) [
'title' => get_string('context_X', 'local_debugtoolbar', $PAGE->context->get_context_name())
'title' => get_string('context_X', 'local_debugtoolbar', $PAGE->context->get_context_name()),
];
$data->records[$i]->items[] = (object) ['title' => get_string('page_type_X', 'local_debugtoolbar', $PAGE->pagetype)];
if ($PAGE->subpage) {
Expand Down
2 changes: 1 addition & 1 deletion settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
$ADMIN->add('localplugins', $settings);

// Add warnings about usage.
$content = html_writer::tag('div', get_string('usage_warning', 'local_debugtoolbar'), array('class' => 'alert alert-warning'));
$content = html_writer::tag('div', get_string('usage_warning', 'local_debugtoolbar'), ['class' => 'alert alert-warning']);
$settings->add(new admin_setting_heading('local_debugtoolbar/header', get_string('settings'), $content));

// Add a checkbox to enable/disable module.
Expand Down

0 comments on commit 7671f5e

Please sign in to comment.