MDL-78165 lib: Added class properties that are not declared in classes

In PHP 8.2 and later, setting a value to an undeclared class property is
deprecated and emits a deprecation notice.
So we need to add missing class properties that still need to be declared.
This commit is contained in:
Meirza 2023-05-09 11:12:19 +07:00
parent 71c36d2de1
commit 8b63d21a50
10 changed files with 33 additions and 15 deletions

View File

@ -35,6 +35,9 @@ defined('MOODLE_INTERNAL') || die();
*/
class any_course_access extends \core_analytics\local\indicator\binary {
/** @var array user last access. */
protected $lastaccesses = [];
/**
* Returns the name.
*

View File

@ -78,7 +78,7 @@ class chart_series implements JsonSerializable {
* @return string|null
*/
public function get_color() {
return isset($this->color[0]) ? $this->color[0] : null;
return isset($this->colors[0]) ? $this->colors[0] : null;
}
/**

View File

@ -45,6 +45,12 @@ use core\check\result;
*/
class riskxss_result extends \core\check\result {
/** @var array SQL parameters. */
protected $params = [];
/** @var string SQL statement. */
protected $sqlfrom;
/**
* Constructor
*/

View File

@ -92,9 +92,9 @@ class result implements \renderable {
const CRITICAL = 'critical';
/**
* @var string $state - state
* @var string $status - status
*/
protected $state = self::UNKNOWN;
protected $status = self::UNKNOWN;
/**
* @var string summary - should be roughly 1 line of plain text and may change depending on the state.
@ -126,7 +126,7 @@ class result implements \renderable {
/**
* Constructor
*
* @param int $status code
* @param string $status code
* @param string $summary a 1 liner summary
* @param string $details as a html chunk
*/

View File

@ -44,6 +44,12 @@ class cache_handler {
*/
private array $deferreditems;
/** @var string module name. */
private string $module;
/** @var string the directory for cache. */
private string $dir;
/**
* Constructor for class cache_handler.
* This class will accept the module which will determine the location of cached files.

View File

@ -64,15 +64,15 @@ class cache_item {
global $CFG, $USER;
$this->key = $key;
// Set the directory for cache.
$this->dir = $CFG->cachedir . '/' . $module . '/';
if (file_exists($this->dir)) {
$dir = $CFG->cachedir . '/' . $module . '/';
if (file_exists($dir)) {
$filename = 'u' . $USER->id . '_' . md5(serialize($key));
// If the cache fine exists, set the value from the cache file.
if (file_exists($this->dir . $filename)) {
if (file_exists($dir . $filename)) {
$this->ishit = true;
$this->expires_after($ttl);
$fp = fopen($this->dir . $filename, 'rb');
$size = filesize($this->dir . $filename);
$fp = fopen($dir . $filename, 'rb');
$size = filesize($dir . $filename);
$content = fread($fp, $size);
$this->value = unserialize($content);
}

View File

@ -435,9 +435,7 @@ class address_manager {
$this->process($recipient);
// Validate the retrieved data against the e-mail address of the originator.
$this->status = $this->validate($sender);
return $this->status;
return $this->validate($sender);
}
/**

View File

@ -77,6 +77,9 @@ abstract class base {
/** @var int Move a plugin down in the plugin order */
public const MOVE_DOWN = 1;
/** @var string Name of the plugin */
public $component;
/**
* Whether this plugintype supports its plugins being disabled.
*
@ -153,6 +156,7 @@ abstract class base {
$plugin->type = $type;
$plugin->typerootdir = $typerootdir;
$plugin->name = $name;
$plugin->component = $plugin->type.'_'.$plugin->name;
$plugin->rootdir = null;
$plugin->displayname = $name;
$plugin->versiondb = $version;
@ -183,6 +187,7 @@ abstract class base {
$plugin->name = $name;
$plugin->rootdir = $namerootdir;
$plugin->pluginman = $pluginman;
$plugin->component = $plugin->type.'_'.$plugin->name;
$plugin->init_display_name();
$plugin->load_disk_version();

View File

@ -64,7 +64,7 @@ class antivirus_test extends advanced_testcase {
*/
protected function get_check_api_antivirus_status_result() {
$av = new \core\check\environment\antivirus();
return $av->get_result()->status;
return $av->get_result()->get_status();
}
protected function tearDown(): void {

View File

@ -44,11 +44,11 @@ class check_test extends \advanced_testcase {
$CFG->passwordpolicy = false;
$result = $check->get_result();
$this->assertEquals($result->status, result::WARNING);
$this->assertEquals($result->get_status(), result::WARNING);
$CFG->passwordpolicy = true;
$result = $check->get_result();
$this->assertEquals($result->status, result::OK);
$this->assertEquals($result->get_status(), result::OK);
$CFG->passwordpolicy = $prior;
}