From 97ff68fd6b8166478fdf872f10d8b6068bfa374f Mon Sep 17 00:00:00 2001 From: Meirza Date: Tue, 9 May 2023 11:27:30 +0700 Subject: [PATCH] MDL-78159 lib: Added missing properties for core libraries 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. --- ...resets_admin_setting_configmultiselect.php | 3 +++ ...dminpresets_admin_setting_configselect.php | 3 +++ .../adminpresets_admin_setting_configtime.php | 3 +++ ...esets_admin_setting_special_backupdays.php | 3 +++ ...ts_admin_setting_users_with_capability.php | 3 +++ admin/roles/classes/allow_role_page.php | 1 - .../brickfield/classes/output/renderer.php | 1 - lib/adminlib.php | 15 ++++++----- lib/dmllib.php | 2 +- lib/filelib.php | 5 ++++ lib/filterlib.php | 6 +++++ lib/flickrlib.php | 10 +++----- lib/formslib.php | 12 +++++++++ lib/graphlib.php | 14 +++++++++++ lib/listlib.php | 3 +++ lib/modinfolib.php | 6 +++++ lib/navigationlib.php | 7 +++++- lib/oauthlib.php | 13 ++++++++++ lib/outputactions.php | 13 +++++----- lib/outputcomponents.php | 6 +++++ lib/outputlib.php | 25 +++++++++++++++++++ lib/outputrequirementslib.php | 6 +++++ lib/tests/html_writer_test.php | 2 -- lib/webdavlib.php | 15 +++++++++++ lib/wiki_to_markdown.php | 1 - mod/wiki/pagelib.php | 2 +- 26 files changed, 152 insertions(+), 28 deletions(-) diff --git a/admin/presets/classes/local/setting/adminpresets_admin_setting_configmultiselect.php b/admin/presets/classes/local/setting/adminpresets_admin_setting_configmultiselect.php index 7ae72675a32..dd8cacac605 100644 --- a/admin/presets/classes/local/setting/adminpresets_admin_setting_configmultiselect.php +++ b/admin/presets/classes/local/setting/adminpresets_admin_setting_configmultiselect.php @@ -26,6 +26,9 @@ namespace core_adminpresets\local\setting; */ class adminpresets_admin_setting_configmultiselect extends adminpresets_setting { + /** @var \admin_setting_configmultiselect $settingdata */ + protected $settingdata; + /** * Ensure that the $value values are setting choices. * diff --git a/admin/presets/classes/local/setting/adminpresets_admin_setting_configselect.php b/admin/presets/classes/local/setting/adminpresets_admin_setting_configselect.php index d8a9109fa60..1ac97d7070c 100644 --- a/admin/presets/classes/local/setting/adminpresets_admin_setting_configselect.php +++ b/admin/presets/classes/local/setting/adminpresets_admin_setting_configselect.php @@ -26,6 +26,9 @@ namespace core_adminpresets\local\setting; */ class adminpresets_admin_setting_configselect extends adminpresets_setting { + /** @var \admin_setting_configselect $settingdata */ + protected $settingdata; + /** * Sets the setting value cleaning it. * diff --git a/admin/presets/classes/local/setting/adminpresets_admin_setting_configtime.php b/admin/presets/classes/local/setting/adminpresets_admin_setting_configtime.php index 67e56d5f376..fa918099162 100644 --- a/admin/presets/classes/local/setting/adminpresets_admin_setting_configtime.php +++ b/admin/presets/classes/local/setting/adminpresets_admin_setting_configtime.php @@ -26,6 +26,9 @@ namespace core_adminpresets\local\setting; */ class adminpresets_admin_setting_configtime extends adminpresets_setting { + /** @var \admin_setting_configtime $settingdata */ + protected $settingdata; + /** * To check that the value is one of the options * diff --git a/admin/presets/classes/local/setting/adminpresets_admin_setting_special_backupdays.php b/admin/presets/classes/local/setting/adminpresets_admin_setting_special_backupdays.php index 70739a82caf..625c2aa15bd 100644 --- a/admin/presets/classes/local/setting/adminpresets_admin_setting_special_backupdays.php +++ b/admin/presets/classes/local/setting/adminpresets_admin_setting_special_backupdays.php @@ -28,6 +28,9 @@ namespace core_adminpresets\local\setting; */ class adminpresets_admin_setting_special_backupdays extends adminpresets_setting { + /** @var \admin_setting_special_backupdays $settingdata */ + protected $settingdata; + protected function set_value($value) { $this->value = clean_param($value, PARAM_SEQUENCE); $this->set_visiblevalue(); diff --git a/admin/presets/classes/local/setting/adminpresets_admin_setting_users_with_capability.php b/admin/presets/classes/local/setting/adminpresets_admin_setting_users_with_capability.php index e46db3afbad..c30b4c344de 100644 --- a/admin/presets/classes/local/setting/adminpresets_admin_setting_users_with_capability.php +++ b/admin/presets/classes/local/setting/adminpresets_admin_setting_users_with_capability.php @@ -26,6 +26,9 @@ namespace core_adminpresets\local\setting; */ class adminpresets_admin_setting_users_with_capability extends adminpresets_admin_setting_configmultiselect { + /** @var \admin_setting_configmultiselect $settingdata */ + protected $settingdata; + protected function set_behaviors() { $this->behaviors['loadchoices'] = &$this->settingdata; } diff --git a/admin/roles/classes/allow_role_page.php b/admin/roles/classes/allow_role_page.php index 376489fa239..b32946b456a 100644 --- a/admin/roles/classes/allow_role_page.php +++ b/admin/roles/classes/allow_role_page.php @@ -141,7 +141,6 @@ abstract class core_role_allow_role_page { $table->cellspacing = 0; $table->width = '90%'; $table->align = array('left'); - $table->rotateheaders = true; $table->head = array(' '); $table->colclasses = array(''); diff --git a/admin/tool/brickfield/classes/output/renderer.php b/admin/tool/brickfield/classes/output/renderer.php index 09ec97a6d3f..b6b483d2d59 100644 --- a/admin/tool/brickfield/classes/output/renderer.php +++ b/admin/tool/brickfield/classes/output/renderer.php @@ -76,7 +76,6 @@ class renderer extends plugin_renderer_base { $label = $tool->get_toolshortname(); } $tab = new tabobject($idprefix . $toolname, $link, $label); - $tab->extraclass = isset($extraclass[$toolname]) ? $extraclass[$toolname] : null; $tabs[] = $tab; } return $this->render(new tabtree($tabs, $idprefix . $filter->tab)); diff --git a/lib/adminlib.php b/lib/adminlib.php index 63235c2a0d4..36a14511999 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -1738,6 +1738,8 @@ abstract class admin_setting { private $dependenton = []; /** @var bool Whether this setting uses a custom form control */ protected $customcontrol = false; + /** @var mixed int means PARAM_XXX type, string is a allowed format in regex */ + public $paramtype; /** * Constructor @@ -2442,8 +2444,6 @@ class admin_setting_description extends admin_setting { */ class admin_setting_configtext extends admin_setting { - /** @var mixed int means PARAM_XXX type, string is a allowed format in regex */ - public $paramtype; /** @var int default field size */ public $size; @@ -3126,11 +3126,12 @@ class admin_setting_configcheckbox extends admin_setting { * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class admin_setting_configmulticheckbox extends admin_setting { - /** @var array Array of choices value=>label */ - public $choices; /** @var callable|null Loader function for choices */ protected $choiceloader = null; + /** @var array Array of choices value=>label. */ + public $choices; + /** * Constructor: uses parent::__construct * @@ -4664,7 +4665,8 @@ class admin_setting_bloglevel extends admin_setting_configselect { * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class admin_setting_courselist_frontpage extends admin_setting { - /** @var array Array of choices value=>label */ + + /** @var array Array of choices value=>label. */ public $choices; /** @@ -6260,7 +6262,8 @@ class admin_setting_special_gradepointmax extends admin_setting_configtext { * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class admin_setting_gradecat_combo extends admin_setting { - /** @var array Array of choices */ + + /** @var array Array of choices value=>label. */ public $choices; /** diff --git a/lib/dmllib.php b/lib/dmllib.php index 4ec1c561b90..021241742d8 100644 --- a/lib/dmllib.php +++ b/lib/dmllib.php @@ -178,7 +178,7 @@ class dml_multiple_records_exception extends dml_exception { */ class dml_missing_record_exception extends dml_exception { /** @var string A table's name.*/ - public $table; + public $tablename; /** @var string An SQL query.*/ public $sql; /** @var array The SQL's parameters.*/ diff --git a/lib/filelib.php b/lib/filelib.php index 48769d19cce..4a4650387c3 100644 --- a/lib/filelib.php +++ b/lib/filelib.php @@ -3154,6 +3154,8 @@ class curl { private $ignoresecurity; /** @var array $mockresponses For unit testing only - return the head of this list instead of making the next request. */ private static $mockresponses = []; + /** @var array temporary params value if the value is not belongs to class stored_file. */ + public $_tmp_file_post_params = []; /** * Curl constructor. @@ -4261,6 +4263,9 @@ class curl_cache { /** @var string Path to cache directory */ public $dir = ''; + /** @var int the repositorycacheexpire config value. */ + private $ttl; + /** * Constructor * diff --git a/lib/filterlib.php b/lib/filterlib.php index ec80be2d720..d8ddaceeaeb 100644 --- a/lib/filterlib.php +++ b/lib/filterlib.php @@ -496,6 +496,12 @@ class filterobject { /** @var null|string once initialised, holds the mangled HTML to replace the regexp with. */ public $workreplacementphrase = null; + /** @var null|callable hold a replacement function to be called. */ + public $replacementcallback; + + /** @var null|array data to be passed to $replacementcallback. */ + public $replacementcallbackdata; + /** * Constructor. * diff --git a/lib/flickrlib.php b/lib/flickrlib.php index 7d54e28573c..25af647ffb4 100644 --- a/lib/flickrlib.php +++ b/lib/flickrlib.php @@ -57,6 +57,9 @@ class phpFlickr { var $token; var $php_version; + /** @var curl cURL class. */ + private $curl; + /** * When your database cache table hits this many rows, a cleanup * will occur to get rid of all of the old rows and cleanup the @@ -78,7 +81,6 @@ class phpFlickr { $this->api_key = $api_key; $this->secret = $secret; $this->die_on_error = false; - $this->service = "flickr"; $this->token = $token; //Find the PHP version and store it for future reference $this->php_version = explode("-", phpversion()); @@ -1134,12 +1136,6 @@ class phpFlickr { // $args['async'] = 1; $args['api_key'] = $this->api_key; - if (!empty($this->email)) { - $args['email'] = $this->email; - } - if (!empty($this->password)) { - $args['password'] = $this->password; - } if (!empty($this->token)) { $args['auth_token'] = $this->token; } diff --git a/lib/formslib.php b/lib/formslib.php index f54253a807c..5cb1cdc4012 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -1682,6 +1682,12 @@ class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless { */ const DEP_HIDE = 1; + /** @var string request class HTML. */ + protected $_reqHTML; + + /** @var string advanced class HTML. */ + protected $_advancedHTML; + /** * Class constructor - same parameters as HTML_QuickForm_DHTMLRulesTableless * @@ -3104,6 +3110,12 @@ class MoodleQuickForm_Renderer extends HTML_QuickForm_Renderer_Tableless{ */ var $_collapseButtons = ''; + /** @var string request class HTML. */ + protected $_reqHTML; + + /** @var string advanced class HTML. */ + protected $_advancedHTML; + /** * Constructor */ diff --git a/lib/graphlib.php b/lib/graphlib.php index fcb1eda3b1d..c06db479b79 100644 --- a/lib/graphlib.php +++ b/lib/graphlib.php @@ -154,6 +154,20 @@ class graph { var $y_tick_labels = null; // array of text values for y-axis tick labels var $offset_relation = null; // array of offsets for different sets of data + /** @var array y_order data. */ + public $y_order = []; + + /** @var array y_format data. */ + public $y_format = []; + + /** @var array x_data data. */ + public $x_data = []; + + /** @var array colour. */ + public $colour = []; + + /** @var array y_data data. */ + public $y_data = []; // init all text - title, labels, and axis text. function init() { diff --git a/lib/listlib.php b/lib/listlib.php index 894a793cfc8..26ca97a023a 100644 --- a/lib/listlib.php +++ b/lib/listlib.php @@ -79,6 +79,9 @@ abstract class moodle_list { public $pageurl; public $pageparamname; + /** @var int no of top level items. */ + private $itemsperpage; + /** * Constructor. * diff --git a/lib/modinfolib.php b/lib/modinfolib.php index 4ebfbab9a60..834c381668c 100644 --- a/lib/modinfolib.php +++ b/lib/modinfolib.php @@ -3070,6 +3070,12 @@ class section_info implements IteratorAggregate { */ private $modinfo; + /** + * True if has activities, otherwise false. + * @var bool + */ + public $hasactivites; + /** * Constructs object from database information plus extra required data. * @param object $data Array entry from cached sectioncache diff --git a/lib/navigationlib.php b/lib/navigationlib.php index edf2d7bed6d..c95f7ebcbb2 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -158,6 +158,12 @@ class navigation_node implements renderable { public $showinsecondarynavigation = true; /** @var bool If set to true the children of this node will be displayed within a submenu when applicable */ public $showchildreninsubmenu = false; + /** @var string tab element ID. */ + public $tab; + /** @var string unique identifier. */ + public $moremenuid; + /** @var bool node that have children. */ + public $haschildren; /** * Constructs a new navigation_node @@ -2279,7 +2285,6 @@ class global_navigation extends navigation_node { if ($this->includesectionnum !== false && $this->includesectionnum == $section->section) { $this->load_section_activities($sectionnode, $section->section, $activities); } - $section->sectionnode = $sectionnode; $navigationsections[$sectionid] = $section; } } diff --git a/lib/oauthlib.php b/lib/oauthlib.php index 40ef011962b..8fe9edd3a99 100644 --- a/lib/oauthlib.php +++ b/lib/oauthlib.php @@ -61,6 +61,19 @@ class oauth_helper { protected $http; /** @var array options to pass to the next curl request */ protected $http_options; + /** @var moodle_url oauth callback URL. */ + protected $oauth_callback; + /** @var string access token. */ + protected $access_token; + /** @var string access secret token. */ + protected $access_token_secret; + /** @var string sign secret. */ + protected $sign_secret; + /** @var string nonce. */ + protected $nonce; + /** @var int timestamp. */ + protected $timestamp; + /** * Contructor for oauth_helper. diff --git a/lib/outputactions.php b/lib/outputactions.php index cf0d70d0a6b..04bf469af06 100644 --- a/lib/outputactions.php +++ b/lib/outputactions.php @@ -170,18 +170,17 @@ class popup_action extends component_action { */ public function __construct($event, $url, $name='popup', $params=array()) { global $CFG; - $this->name = $name; $url = new moodle_url($url); - if ($this->name) { - $_name = $this->name; - if (($_name = preg_replace("/\s/", '_', $_name)) != $this->name) { - throw new coding_exception('The $name of a popup window shouldn\'t contain spaces - string modified. '. $this->name .' changed to '. $_name); - $this->name = $_name; + if ($name) { + $_name = $name; + if (($_name = preg_replace("/\s/", '_', $_name)) != $name) { + throw new coding_exception('The $name of a popup window shouldn\'t contain spaces - string modified. '. $name .' changed to '. $_name); + $name = $_name; } } else { - $this->name = 'popup'; + $name = 'popup'; } foreach ($this->params as $var => $val) { diff --git a/lib/outputcomponents.php b/lib/outputcomponents.php index adb09b605ae..020e5687830 100644 --- a/lib/outputcomponents.php +++ b/lib/outputcomponents.php @@ -1116,6 +1116,9 @@ class single_select implements renderable, templatable { */ var $helpicon = null; + /** @var component_action[] component action. */ + public $actions = []; + /** * Constructor * @param moodle_url $url form action target, includes hidden fields @@ -2866,6 +2869,9 @@ class html_table { /** @var bool Whether to make the table to be scrolled horizontally with ease. Make table responsive across all viewports. */ public $responsive = true; + /** @var string class name to add to this html table. */ + public $class; + /** * Constructor */ diff --git a/lib/outputlib.php b/lib/outputlib.php index dab6f7c7ed2..a1d73f9cbbb 100644 --- a/lib/outputlib.php +++ b/lib/outputlib.php @@ -689,6 +689,31 @@ class theme_config { */ public $activityheaderconfig = []; + /** + * For backward compatibility with old themes. + * BLOCK_ADDBLOCK_POSITION_DEFAULT, BLOCK_ADDBLOCK_POSITION_FLATNAV. + * @var int + */ + public $addblockposition; + + /** + * editor_scss file(s) provided by this theme. + * @var array + */ + public $editor_scss; + + /** + * Name of the class extending \core\output\icon_system. + * @var string + */ + public $iconsystem; + + /** + * Theme defines its own editing mode switch. + * @var bool + */ + public $haseditswitch = false; + /** * Load the config.php file for a particular theme, and return an instance * of this class. (That is, this is a factory method.) diff --git a/lib/outputrequirementslib.php b/lib/outputrequirementslib.php index 3ce54f98c28..071eed34839 100644 --- a/lib/outputrequirementslib.php +++ b/lib/outputrequirementslib.php @@ -1851,6 +1851,12 @@ class YUI_config { public $insertBefore = 'firstthemesheet'; public $groups = array(); public $modules = array(); + /** @var array The log sources that should be not be logged. */ + public $logInclude = []; + /** @var array Tog sources that should be logged. */ + public $logExclude = []; + /** @var string The minimum log level for YUI logging statements. */ + public $logLevel; /** * @var array List of functions used by the YUI Loader group pattern recognition. diff --git a/lib/tests/html_writer_test.php b/lib/tests/html_writer_test.php index e732269d18d..623078eaa57 100644 --- a/lib/tests/html_writer_test.php +++ b/lib/tests/html_writer_test.php @@ -236,7 +236,6 @@ class html_writer_test extends basic_testcase { // The data-name will be present in the output. $row->attributes['data-name'] = 'Fred'; - $row->class = 'this is a table row'; $cell = new html_table_cell(); @@ -246,7 +245,6 @@ class html_writer_test extends basic_testcase { // The data-name will be present in the output. $cell->attributes['data-name'] = 'John'; - $cell->class = 'this is a table cell'; $row->cells[] = $cell; diff --git a/lib/webdavlib.php b/lib/webdavlib.php index 562b9412b24..72603aa13a8 100644 --- a/lib/webdavlib.php +++ b/lib/webdavlib.php @@ -88,6 +88,21 @@ class webdav_client { */ private $oauthtoken; + /** @var string Username (for basic/digest auth, see $auth). */ + private $user; + + /** @var string Password (for basic/digest auth, see $auth). */ + private $pass; + + /** @var mixed to store xml data that need to be handled. */ + private $_lock_ref_cdata; + + /** @var mixed to store the deleted xml data. */ + private $_delete_cdata; + + /** @var string to store the locked xml data. */ + private $_lock_cdata; + /**#@-*/ /** diff --git a/lib/wiki_to_markdown.php b/lib/wiki_to_markdown.php index ce5c2aa98a8..6a0cecdb613 100644 --- a/lib/wiki_to_markdown.php +++ b/lib/wiki_to_markdown.php @@ -323,7 +323,6 @@ class WikiToMarkdown { $this->list_state = LIST_NONE; $this->list_depth = 0; $this->list_backtrack = array(); - $this->spelling_on = false; $this->courseid = $courseid; // split content into array of single lines diff --git a/mod/wiki/pagelib.php b/mod/wiki/pagelib.php index b35b1cbf1f8..6f61dd06261 100644 --- a/mod/wiki/pagelib.php +++ b/mod/wiki/pagelib.php @@ -660,7 +660,7 @@ class page_wiki_comments extends page_wiki { $cell1 = new html_table_cell($OUTPUT->user_picture($user, array('popup' => true))); $cell2 = new html_table_cell(get_string('bynameondate', 'forum', $by)); $cell3 = new html_table_cell(); - $cell3->atributtes ['width'] = "80%"; + $cell3->attributes['width'] = "80%"; $cell4 = new html_table_cell(); $cell5 = new html_table_cell();