mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-71807 cleanup: Replace deprecated codingStandardsIgnore annotations
The PHP_CodeSniffer @codingStandardsIgnore annotations are deprecated and, since version 3.x, the new // phpcs:ignore comments should be used instead. This commits just reviews all the uses in core, replacing them for the better new candidate, or removing when no longer needed.
This commit is contained in:
parent
01eb6d2e9b
commit
a5c91474ee
21 changed files with 30 additions and 57 deletions
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
// @codingStandardsIgnoreFile
|
||||
// phpcs:ignoreFile
|
||||
// @codeCoverageIgnoreStart
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
|
|
|
@ -33,8 +33,8 @@ use tool_policy\output\page_agreedocs;
|
|||
// Do not check for the site policies in require_login() to avoid the redirect loop.
|
||||
define('NO_SITEPOLICY_CHECK', true);
|
||||
|
||||
// @codingStandardsIgnoreLine See the {@link page_agreedocs} for the access control checks.
|
||||
require(__DIR__.'/../../../config.php');
|
||||
// See the {@see page_agreedocs} for the access control checks.
|
||||
require(__DIR__.'/../../../config.php'); // phpcs:ignore
|
||||
|
||||
$submit = optional_param('submit', null, PARAM_NOTAGS);
|
||||
$cancel = optional_param('cancel', null, PARAM_NOTAGS);
|
||||
|
|
|
@ -35,8 +35,8 @@ use tool_policy\output\page_viewdoc;
|
|||
// Do not check for the site policies in require_login() to avoid the redirect loop.
|
||||
define('NO_SITEPOLICY_CHECK', true);
|
||||
|
||||
// @codingStandardsIgnoreLine See the {@link page_viewdoc} for the access control checks.
|
||||
require(__DIR__.'/../../../config.php');
|
||||
// See the {@see page_viewdoc} for the access control checks.
|
||||
require(__DIR__.'/../../../config.php'); // phpcs:ignore
|
||||
|
||||
$versionid = optional_param('versionid', null, PARAM_INT);
|
||||
$policyid = $versionid ? optional_param('policyid', null, PARAM_INT) : required_param('policyid', PARAM_INT);
|
||||
|
|
|
@ -31,8 +31,8 @@ use tool_policy\output\page_viewalldoc;
|
|||
// Do not check for the site policies in require_login() to avoid the redirect loop.
|
||||
define('NO_SITEPOLICY_CHECK', true);
|
||||
|
||||
// @codingStandardsIgnoreLine See the {@link page_viewalldoc} for the access control checks.
|
||||
require(__DIR__.'/../../../config.php');
|
||||
// See the {@see page_viewalldoc} for the access control checks.
|
||||
require(__DIR__.'/../../../config.php'); // phpcs:ignore
|
||||
|
||||
$returnurl = optional_param('returnurl', '', PARAM_LOCALURL); // A return URL.
|
||||
|
||||
|
|
|
@ -32,8 +32,8 @@
|
|||
// comment out when debugging or better look into error log!
|
||||
define('NO_DEBUG_DISPLAY', true);
|
||||
|
||||
// @codingStandardsIgnoreLine This script does not require login.
|
||||
require("../../config.php");
|
||||
// This script does not require login.
|
||||
require("../../config.php"); // phpcs:ignore
|
||||
require_once("lib.php");
|
||||
require_once($CFG->libdir.'/enrollib.php');
|
||||
require_once($CFG->libdir . '/filelib.php');
|
||||
|
|
|
@ -27,9 +27,7 @@
|
|||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
require('../config.php');
|
||||
// @codingStandardsIgnoreEnd
|
||||
require('../config.php'); // phpcs:ignore
|
||||
|
||||
$context = context_system::instance();
|
||||
$title = get_string('pagenotexisttitle', 'error');
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
// phpcs:ignoreFile
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html <?php echo $htmllang ?>>
|
||||
|
|
|
@ -129,7 +129,7 @@ class chart_axis implements JsonSerializable {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize() { // @codingStandardsIgnoreLine (CONTRIB-6469).
|
||||
public function jsonSerialize() {
|
||||
return [
|
||||
'label' => $this->label,
|
||||
'labels' => $this->labels,
|
||||
|
|
|
@ -43,7 +43,7 @@ class chart_bar extends chart_base {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize() { // @codingStandardsIgnoreLine (CONTRIB-6469).
|
||||
public function jsonSerialize() {
|
||||
$data = parent::jsonSerialize();
|
||||
$data['horizontal'] = $this->get_horizontal();
|
||||
$data['stacked'] = $this->get_stacked();
|
||||
|
|
|
@ -77,7 +77,7 @@ class chart_base implements JsonSerializable, renderable {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize() { // @codingStandardsIgnoreLine (CONTRIB-6469).
|
||||
public function jsonSerialize() {
|
||||
global $CFG;
|
||||
return [
|
||||
'type' => $this->get_type(),
|
||||
|
|
|
@ -42,7 +42,7 @@ class chart_line extends chart_base {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize() { // @codingStandardsIgnoreLine (CONTRIB-6469).
|
||||
public function jsonSerialize() {
|
||||
$data = parent::jsonSerialize();
|
||||
$data['smooth'] = $this->get_smooth();
|
||||
return $data;
|
||||
|
|
|
@ -42,7 +42,7 @@ class chart_pie extends chart_base {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize() { // @codingStandardsIgnoreLine (CONTRIB-6469).
|
||||
public function jsonSerialize() {
|
||||
$data = parent::jsonSerialize();
|
||||
$data['doughnut'] = $this->get_doughnut();
|
||||
return $data;
|
||||
|
|
|
@ -183,7 +183,7 @@ class chart_series implements JsonSerializable {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize() { // @codingStandardsIgnoreLine (CONTRIB-6469).
|
||||
public function jsonSerialize() {
|
||||
$data = [
|
||||
'label' => $this->label,
|
||||
'labels' => $this->labels,
|
||||
|
|
|
@ -711,9 +711,7 @@ class manager {
|
|||
}
|
||||
// This will emit an error if debugging is on, even if $CFG->enable_read_only_sessions
|
||||
// is not true as we need to surface this class of errors.
|
||||
// @codingStandardsIgnoreStart
|
||||
error_log($error);
|
||||
// @codingStandardsIgnoreEnd
|
||||
error_log($error); // phpcs:ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -476,10 +476,9 @@ class redis extends handler {
|
|||
// It should not happen very often - all pages that need long time to execute
|
||||
// should close session immediately after access control checks.
|
||||
$whohaslock = $this->connection->get($lockkey);
|
||||
// @codingStandardsIgnoreStart
|
||||
// phpcs:ignore
|
||||
error_log("Cannot obtain session lock for sid: $id within $this->acquiretimeout seconds. " .
|
||||
"It is likely another page ($whohaslock) has a long session lock, or the session lock was never released.");
|
||||
// @codingStandardsIgnoreEnd
|
||||
throw new exception("Unable to obtain session lock");
|
||||
}
|
||||
|
||||
|
|
|
@ -102,9 +102,8 @@ class core_shutdown_manager {
|
|||
array_unshift($params, $signo);
|
||||
$shouldexit = call_user_func_array($callback, $params) && $shouldexit;
|
||||
} catch (Throwable $e) {
|
||||
// @codingStandardsIgnoreStart
|
||||
// phpcs:ignore
|
||||
error_log('Exception ignored in signal function ' . get_callable_name($callback) . ': ' . $e->getMessage());
|
||||
// @codingStandardsIgnoreEnd
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,9 +123,7 @@ class core_shutdown_manager {
|
|||
*/
|
||||
public static function register_signal_handler($callback, array $params = null): void {
|
||||
if (!is_callable($callback)) {
|
||||
// @codingStandardsIgnoreStart
|
||||
error_log('Invalid custom signal function detected ' . var_export($callback, true));
|
||||
// @codingStandardsIgnoreEnd
|
||||
error_log('Invalid custom signal function detected ' . var_export($callback, true)); // phpcs:ignore
|
||||
}
|
||||
self::$signalcallbacks[] = [$callback, $params ?? []];
|
||||
}
|
||||
|
@ -140,9 +137,7 @@ class core_shutdown_manager {
|
|||
*/
|
||||
public static function register_function($callback, array $params = null): void {
|
||||
if (!is_callable($callback)) {
|
||||
// @codingStandardsIgnoreStart
|
||||
error_log('Invalid custom shutdown function detected '.var_export($callback, true));
|
||||
// @codingStandardsIgnoreEnd
|
||||
error_log('Invalid custom shutdown function detected '.var_export($callback, true)); // phpcs:ignore
|
||||
}
|
||||
self::$callbacks[] = [$callback, $params ? array_values($params) : []];
|
||||
}
|
||||
|
@ -159,9 +154,8 @@ class core_shutdown_manager {
|
|||
try {
|
||||
call_user_func_array($callback, $params);
|
||||
} catch (Throwable $e) {
|
||||
// @codingStandardsIgnoreStart
|
||||
// phpcs:ignore
|
||||
error_log('Exception ignored in shutdown function '.get_callable_name($callback).': '.$e->getMessage());
|
||||
// @codingStandardsIgnoreEnd
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -195,15 +195,13 @@ trait moodle_read_slave_trait {
|
|||
}
|
||||
$dboptions['dbport'] = isset($slave['dbport']) ? $slave['dbport'] : $dbport;
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
try {
|
||||
$this->raw_connect($rodb['dbhost'], $rodb['dbuser'], $rodb['dbpass'], $dbname, $prefix, $dboptions);
|
||||
$this->dbhreadonly = $this->get_db_handle();
|
||||
break;
|
||||
} catch (dml_connection_exception $e) {
|
||||
} catch (dml_connection_exception $e) { // phpcs:ignore
|
||||
// If readonly slave is not connectable we'll have to do without it.
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
||||
}
|
||||
// ... lock_db queries always go to master.
|
||||
// Since it is a lock and as such marshalls concurrent connections,
|
||||
|
|
|
@ -36,14 +36,12 @@ require_once(__DIR__.'/../../pgsql_native_moodle_database.php');
|
|||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
trait test_moodle_read_slave_trait {
|
||||
// @codingStandardsIgnoreStart
|
||||
/**
|
||||
* Constructs a mock db driver
|
||||
*
|
||||
* @param bool $external
|
||||
*/
|
||||
public function __construct($external = false) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
parent::__construct($external);
|
||||
|
||||
$rw = fopen("php://memory", 'r+');
|
||||
|
|
17
lib/dml/tests/fixtures/test_sql_generator.php
vendored
17
lib/dml/tests/fixtures/test_sql_generator.php
vendored
|
@ -34,9 +34,11 @@ require_once(__DIR__.'/../../../ddl/sql_generator.php');
|
|||
* @category ddl
|
||||
* @copyright 2018 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*
|
||||
*/
|
||||
class test_sql_generator extends sql_generator {
|
||||
// @codingStandardsIgnoreStart
|
||||
// phpcs:disable moodle.NamingConventions.ValidFunctionName.LowercaseMethod
|
||||
|
||||
/**
|
||||
* Reset a sequence to the id field of a table.
|
||||
*
|
||||
|
@ -44,11 +46,9 @@ class test_sql_generator extends sql_generator {
|
|||
* @return array of sql statements
|
||||
*/
|
||||
public function getResetSequenceSQL($table) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
return [];
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
/**
|
||||
* Given one correct xmldb_table, returns the SQL statements
|
||||
* to create temporary table (inside one array).
|
||||
|
@ -57,11 +57,9 @@ class test_sql_generator extends sql_generator {
|
|||
* @return array of sql statements
|
||||
*/
|
||||
public function getCreateTempTableSQL($xmldbtable) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
return [];
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
/**
|
||||
* Given one XMLDB Type, length and decimals, returns the DB proper SQL type.
|
||||
*
|
||||
|
@ -71,11 +69,9 @@ class test_sql_generator extends sql_generator {
|
|||
* @return string The DB defined data type.
|
||||
*/
|
||||
public function getTypeSQL($xmldbtype, $xmldblength = null, $xmldbdecimals = null) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
return '';
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
/**
|
||||
* Returns the code (array of statements) needed to add one comment to the table.
|
||||
*
|
||||
|
@ -83,11 +79,9 @@ class test_sql_generator extends sql_generator {
|
|||
* @return array Array of SQL statements to add one comment to the table.
|
||||
*/
|
||||
function getCommentSQL ($xmldbtable) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
return [];
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
/**
|
||||
* Given one xmldb_table and one xmldb_field, return the SQL statements needed to add its default
|
||||
* (usually invoked from getModifyDefaultSQL()
|
||||
|
@ -97,11 +91,9 @@ class test_sql_generator extends sql_generator {
|
|||
* @return array Array of SQL statements to create a field's default.
|
||||
*/
|
||||
public function getCreateDefaultSQL($xmldbtable, $xmldbfield) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
return [];
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
/**
|
||||
* Given one xmldb_table and one xmldb_field, return the SQL statements needed to drop its default
|
||||
* (usually invoked from getModifyDefaultSQL()
|
||||
|
@ -111,17 +103,14 @@ class test_sql_generator extends sql_generator {
|
|||
* @return array Array of SQL statements to create a field's default.
|
||||
*/
|
||||
public function getDropDefaultSQL($xmldbtable, $xmldbfield) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
return [];
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
/**
|
||||
* Returns an array of reserved words (lowercase) for this DB
|
||||
* @return array An array of database specific reserved words
|
||||
*/
|
||||
public static function getReservedWords() {
|
||||
// @codingStandardsIgnoreEnd
|
||||
return [];
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
abstract class base_testcase extends PHPUnit\Framework\TestCase {
|
||||
// @codingStandardsIgnoreStart
|
||||
// phpcs:disable
|
||||
// Following code is legacy code from phpunit to support assertTag
|
||||
// and assertNotTag.
|
||||
|
||||
|
@ -569,6 +569,5 @@ abstract class base_testcase extends PHPUnit\Framework\TestCase {
|
|||
|
||||
return str_replace(' ', ' ', $result);
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreEnd
|
||||
// phpcs:enable
|
||||
}
|
||||
|
|
|
@ -146,7 +146,7 @@ function assignsubmission_comments_comment_display($comments, $options) {
|
|||
$a->participantnumber = $anonid;
|
||||
$a->participantfullname = $comment->fullname;
|
||||
$comment->fullname = get_string('blindmarkingviewfullname', 'assignsubmission_comments', $a);
|
||||
} else if ($USER->id == $comment->userid || $submission->userid == $USER->id || $userinteam) { //@codingStandardsIgnoreLine
|
||||
} else if ($USER->id == $comment->userid || $submission->userid == $USER->id || $userinteam) { // phpcs:ignore
|
||||
// Do not anonymize the user details for this comment.
|
||||
} else {
|
||||
// Anonymize the comments.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue