From 1a0df5535edcd2fdd39bf6fa1b0f34a744597062 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Thu, 5 Nov 2015 17:01:34 +0800 Subject: [PATCH] MDL-52081 forms: Use __construct() for constructors --- blocks/edit_form.php | 2 +- blocks/rss_client/editfeed.php | 2 +- course/moodleform_mod.php | 14 ++++++- filter/local_settings_form.php | 2 +- grade/grading/form/guide/guideeditor.php | 12 +++++- grade/grading/form/rubric/rubriceditor.php | 14 ++++++- lib/form/advcheckbox.php | 14 ++++++- lib/form/autocomplete.php | 14 ++++++- lib/form/button.php | 14 ++++++- lib/form/cancel.php | 17 ++++++-- lib/form/checkbox.php | 14 ++++++- lib/form/dateselector.php | 14 ++++++- lib/form/datetimeselector.php | 14 ++++++- lib/form/duration.php | 14 ++++++- lib/form/editor.php | 14 ++++++- lib/form/filemanager.php | 14 ++++++- lib/form/filepicker.php | 14 ++++++- lib/form/grading.php | 14 ++++++- lib/form/group.php | 14 ++++++- lib/form/header.php | 14 ++++++- lib/form/hidden.php | 14 ++++++- lib/form/htmleditor.php | 14 ++++++- lib/form/listing.php | 14 ++++++- lib/form/modgrade.php | 14 ++++++- lib/form/modvisible.php | 15 +++++-- lib/form/password.php | 14 ++++++- lib/form/passwordunmask.php | 14 ++++++- lib/form/questioncategory.php | 13 +++++- lib/form/radio.php | 14 ++++++- lib/form/recaptcha.php | 14 ++++++- lib/form/searchableselector.php | 14 ++++++- lib/form/select.php | 14 ++++++- lib/form/selectgroups.php | 14 ++++++- lib/form/selectwithlink.php | 15 +++++-- lib/form/selectyesno.php | 15 +++++-- lib/form/static.php | 14 ++++++- lib/form/submit.php | 14 ++++++- lib/form/submitlink.php | 14 ++++++- lib/form/tags.php | 14 ++++++- lib/form/text.php | 14 ++++++- lib/form/textarea.php | 14 ++++++- lib/form/url.php | 14 ++++++- lib/form/warning.php | 14 ++++++- lib/formslib.php | 40 ++++++++++++++++--- lib/pear/HTML/Common.php | 12 +++++- lib/pear/HTML/QuickForm.php | 31 +++++++++++--- lib/pear/HTML/QuickForm/Renderer.php | 13 +++++- lib/pear/HTML/QuickForm/Renderer/Array.php | 14 +++++-- lib/pear/HTML/QuickForm/Renderer/Default.php | 15 +++++-- lib/pear/HTML/QuickForm/Renderer/Object.php | 15 +++++-- .../HTML/QuickForm/Renderer/Tableless.php | 15 +++++-- lib/pear/HTML/QuickForm/advcheckbox.php | 15 +++++-- lib/pear/HTML/QuickForm/autocomplete.php | 15 +++++-- lib/pear/HTML/QuickForm/button.php | 15 +++++-- lib/pear/HTML/QuickForm/checkbox.php | 17 ++++++-- lib/pear/HTML/QuickForm/date.php | 15 +++++-- lib/pear/HTML/QuickForm/element.php | 18 ++++++--- lib/pear/HTML/QuickForm/file.php | 20 +++++++--- lib/pear/HTML/QuickForm/group.php | 15 +++++-- lib/pear/HTML/QuickForm/header.php | 15 +++++-- lib/pear/HTML/QuickForm/hidden.php | 15 +++++-- lib/pear/HTML/QuickForm/hiddenselect.php | 15 +++++-- lib/pear/HTML/QuickForm/hierselect.php | 15 +++++-- lib/pear/HTML/QuickForm/html.php | 15 +++++-- lib/pear/HTML/QuickForm/image.php | 15 +++++-- lib/pear/HTML/QuickForm/input.php | 15 +++++-- lib/pear/HTML/QuickForm/link.php | 17 ++++++-- lib/pear/HTML/QuickForm/password.php | 15 +++++-- lib/pear/HTML/QuickForm/radio.php | 15 +++++-- lib/pear/HTML/QuickForm/reset.php | 15 +++++-- lib/pear/HTML/QuickForm/select.php | 15 +++++-- lib/pear/HTML/QuickForm/static.php | 17 ++++++-- lib/pear/HTML/QuickForm/submit.php | 17 ++++++-- lib/pear/HTML/QuickForm/text.php | 15 +++++-- lib/pear/HTML/QuickForm/textarea.php | 17 ++++++-- lib/pear/HTML/QuickForm/xbutton.php | 14 +++++-- lib/pear/PEAR.php | 24 ++++++++++- lib/pear/README_MOODLE.txt | 7 ++++ lib/upgrade.txt | 12 ++++++ mod/data/export_form.php | 14 ++++++- mod/lesson/mod_form.php | 14 ++++++- mod/wiki/editors/wikieditor.php | 21 +++++++++- mod/wiki/editors/wikifiletable.php | 14 ++++++- 83 files changed, 1014 insertions(+), 208 deletions(-) diff --git a/blocks/edit_form.php b/blocks/edit_form.php index ad32113fe0f1c..57c9de8d5b996 100644 --- a/blocks/edit_form.php +++ b/blocks/edit_form.php @@ -54,7 +54,7 @@ function __construct($actionurl, $block, $page) { global $CFG; $this->block = $block; $this->page = $page; - parent::moodleform($actionurl); + parent::__construct($actionurl); } function definition() { diff --git a/blocks/rss_client/editfeed.php b/blocks/rss_client/editfeed.php index 77e3097c30ecf..2b6d92a8a1277 100644 --- a/blocks/rss_client/editfeed.php +++ b/blocks/rss_client/editfeed.php @@ -36,7 +36,7 @@ class feed_edit_form extends moodleform { function __construct($actionurl, $isadding, $caneditshared) { $this->isadding = $isadding; $this->caneditshared = $caneditshared; - parent::moodleform($actionurl); + parent::__construct($actionurl); } function definition() { diff --git a/course/moodleform_mod.php b/course/moodleform_mod.php index 4c8c25feab79b..690dda8a8340d 100644 --- a/course/moodleform_mod.php +++ b/course/moodleform_mod.php @@ -58,7 +58,7 @@ abstract class moodleform_mod extends moodleform { /** @var object The course format of the current course. */ protected $courseformat; - function moodleform_mod($current, $section, $cm, $course) { + public function __construct($current, $section, $cm, $course) { global $CFG; $this->current = $current; @@ -83,7 +83,17 @@ function moodleform_mod($current, $section, $cm, $course) { } $this->_modname = $matches[1]; $this->init_features(); - parent::moodleform('modedit.php'); + parent::__construct('modedit.php'); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function moodleform_mod($current, $section, $cm, $course) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($current, $section, $cm, $course); } protected function init_features() { diff --git a/filter/local_settings_form.php b/filter/local_settings_form.php index 1721ffa74bcfc..fce01a19bb258 100644 --- a/filter/local_settings_form.php +++ b/filter/local_settings_form.php @@ -33,7 +33,7 @@ abstract class filter_local_settings_form extends moodleform { public function __construct($submiturl, $filter, $context) { $this->filter = $filter; $this->context = $context; - parent::moodleform($submiturl); + parent::__construct($submiturl); } /** diff --git a/grade/grading/form/guide/guideeditor.php b/grade/grading/form/guide/guideeditor.php index 902834c5166f7..a6e43a1973caa 100644 --- a/grade/grading/form/guide/guideeditor.php +++ b/grade/grading/form/guide/guideeditor.php @@ -53,8 +53,18 @@ class moodlequickform_guideeditor extends HTML_QuickForm_input { * @param string $elementlabel * @param array $attributes */ + public function __construct($elementname=null, $elementlabel=null, $attributes=null) { + parent::__construct($elementname, $elementlabel, $attributes); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ public function moodlequickform_guideeditor($elementname=null, $elementlabel=null, $attributes=null) { - parent::HTML_QuickForm_input($elementname, $elementlabel, $attributes); + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementname, $elementlabel, $attributes); } /** diff --git a/grade/grading/form/rubric/rubriceditor.php b/grade/grading/form/rubric/rubriceditor.php index b3cc5bfb40eaa..d9901267257e2 100644 --- a/grade/grading/form/rubric/rubriceditor.php +++ b/grade/grading/form/rubric/rubriceditor.php @@ -60,8 +60,18 @@ class MoodleQuickForm_rubriceditor extends HTML_QuickForm_input { * @param string $elementLabel * @param array $attributes */ - function MoodleQuickForm_rubriceditor($elementName=null, $elementLabel=null, $attributes=null) { - parent::HTML_QuickForm_input($elementName, $elementLabel, $attributes); + public function __construct($elementName=null, $elementLabel=null, $attributes=null) { + parent::__construct($elementName, $elementLabel, $attributes); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_rubriceditor($elementName=null, $elementLabel=null, $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $attributes); } /** diff --git a/lib/form/advcheckbox.php b/lib/form/advcheckbox.php index 26ae788005f51..ff679d44d270d 100644 --- a/lib/form/advcheckbox.php +++ b/lib/form/advcheckbox.php @@ -55,7 +55,7 @@ class MoodleQuickForm_advcheckbox extends HTML_QuickForm_advcheckbox{ * or an associative array * @param mixed $values (optional) Values to pass if checked or not checked */ - function MoodleQuickForm_advcheckbox($elementName=null, $elementLabel=null, $text=null, $attributes=null, $values=null) + public function __construct($elementName=null, $elementLabel=null, $text=null, $attributes=null, $values=null) { if ($values === null){ $values = array(0, 1); @@ -81,7 +81,17 @@ function MoodleQuickForm_advcheckbox($elementName=null, $elementLabel=null, $tex } } - parent::HTML_QuickForm_advcheckbox($elementName, $elementLabel, $text, $attributes, $values); + parent::__construct($elementName, $elementLabel, $text, $attributes, $values); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_advcheckbox($elementName=null, $elementLabel=null, $text=null, $attributes=null, $values=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $text, $attributes, $values); } /** diff --git a/lib/form/autocomplete.php b/lib/form/autocomplete.php index 206bc67b6891e..5cf63c2553582 100644 --- a/lib/form/autocomplete.php +++ b/lib/form/autocomplete.php @@ -60,7 +60,7 @@ class MoodleQuickForm_autocomplete extends MoodleQuickForm_select { * @param mixed $attributes Either a typical HTML attribute string or an associative array. Special options * "tags", "placeholder", "ajax", "multiple", "casesensitive" are supported. */ - function MoodleQuickForm_autocomplete($elementName=null, $elementLabel=null, $options=null, $attributes=null) { + public function __construct($elementName=null, $elementLabel=null, $options=null, $attributes=null) { // Even if the constructor gets called twice we do not really want 2x options (crazy forms!). $this->_options = array(); if ($attributes === null) { @@ -87,11 +87,21 @@ function MoodleQuickForm_autocomplete($elementName=null, $elementLabel=null, $op $this->casesensitive = $attributes['casesensitive'] ? true : false; unset($attributes['casesensitive']); } - parent::HTML_QuickForm_select($elementName, $elementLabel, $options, $attributes); + parent::__construct($elementName, $elementLabel, $options, $attributes); $this->_type = 'autocomplete'; } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_autocomplete($elementName=null, $elementLabel=null, $options=null, $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $options, $attributes); + } + /** * Returns HTML for select form element. * diff --git a/lib/form/button.php b/lib/form/button.php index bfa9615c142f9..a69e217105381 100644 --- a/lib/form/button.php +++ b/lib/form/button.php @@ -50,8 +50,18 @@ class MoodleQuickForm_button extends HTML_QuickForm_button * @param mixed $attributes (optional) Either a typical HTML attribute string * or an associative array */ - function MoodleQuickForm_button($elementName=null, $value=null, $attributes=null) { - parent::HTML_QuickForm_button($elementName, $value, $attributes); + public function __construct($elementName=null, $value=null, $attributes=null) { + parent::__construct($elementName, $value, $attributes); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_button($elementName=null, $value=null, $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $value, $attributes); } /** diff --git a/lib/form/cancel.php b/lib/form/cancel.php index 6674377e911f6..2a5764f009b1f 100644 --- a/lib/form/cancel.php +++ b/lib/form/cancel.php @@ -52,7 +52,7 @@ class MoodleQuickForm_cancel extends MoodleQuickForm_submit * @param mixed $attributes (optional) Either a typical HTML attribute string * or an associative array */ - function MoodleQuickForm_cancel($elementName=null, $value=null, $attributes=null) + public function __construct($elementName=null, $value=null, $attributes=null) { if ($elementName==null){ $elementName='cancel'; @@ -60,7 +60,7 @@ function MoodleQuickForm_cancel($elementName=null, $value=null, $attributes=null if ($value==null){ $value=get_string('cancel'); } - MoodleQuickForm_submit::MoodleQuickForm_submit($elementName, $value, $attributes); + parent::__construct($elementName, $value, $attributes); $this->updateAttributes(array('onclick'=>'skipClientValidation = true; return true;')); // Add the class btn-cancel. @@ -71,6 +71,16 @@ function MoodleQuickForm_cancel($elementName=null, $value=null, $attributes=null $this->updateAttributes(array('class' => $class . ' btn-cancel')); } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_cancel($elementName=null, $value=null, $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $value, $attributes); + } + /** * Called by HTML_QuickForm whenever form event is made on this element * @@ -83,8 +93,7 @@ function onQuickFormEvent($event, $arg, &$caller) { switch ($event) { case 'createElement': - $className = get_class($this); - $this->$className($arg[0], $arg[1], $arg[2]); + static::__construct($arg[0], $arg[1], $arg[2]); $caller->_registerCancelButton($this->getName()); return true; break; diff --git a/lib/form/checkbox.php b/lib/form/checkbox.php index 37397da51899c..8aaecdde1abe0 100644 --- a/lib/form/checkbox.php +++ b/lib/form/checkbox.php @@ -52,8 +52,18 @@ class MoodleQuickForm_checkbox extends HTML_QuickForm_checkbox{ * @param mixed $attributes (optional) Either a typical HTML attribute string * or an associative array */ - function MoodleQuickForm_checkbox($elementName=null, $elementLabel=null, $text='', $attributes=null) { - parent::HTML_QuickForm_checkbox($elementName, $elementLabel, $text, $attributes); + public function __construct($elementName=null, $elementLabel=null, $text='', $attributes=null) { + parent::__construct($elementName, $elementLabel, $text, $attributes); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_checkbox($elementName=null, $elementLabel=null, $text='', $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $text, $attributes); } /** diff --git a/lib/form/dateselector.php b/lib/form/dateselector.php index 2332e990e415f..76f3a2e1558ef 100644 --- a/lib/form/dateselector.php +++ b/lib/form/dateselector.php @@ -75,12 +75,12 @@ class MoodleQuickForm_date_selector extends MoodleQuickForm_group { * @param array $options Options to control the element's display * @param mixed $attributes Either a typical HTML attribute string or an associative array */ - function MoodleQuickForm_date_selector($elementName = null, $elementLabel = null, $options = array(), $attributes = null) { + public function __construct($elementName = null, $elementLabel = null, $options = array(), $attributes = null) { // Get the calendar type used - see MDL-18375. $calendartype = \core_calendar\type_factory::get_calendar_instance(); $this->_options = array('startyear' => $calendartype->get_min_year(), 'stopyear' => $calendartype->get_max_year(), 'defaulttime' => 0, 'timezone' => 99, 'step' => 5, 'optional' => false); - $this->HTML_QuickForm_element($elementName, $elementLabel, $attributes); + HTML_QuickForm_element::__construct($elementName, $elementLabel, $attributes); $this->_persistantFreeze = true; $this->_appendName = true; $this->_type = 'date_selector'; @@ -103,6 +103,16 @@ function MoodleQuickForm_date_selector($elementName = null, $elementLabel = null } } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_date_selector($elementName = null, $elementLabel = null, $options = array(), $attributes = null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $options, $attributes); + } + /** * This will create date group element constisting of day, month and year. * diff --git a/lib/form/datetimeselector.php b/lib/form/datetimeselector.php index 3153f34c100d7..9f27cbd7bd5a6 100644 --- a/lib/form/datetimeselector.php +++ b/lib/form/datetimeselector.php @@ -77,13 +77,13 @@ class MoodleQuickForm_date_time_selector extends MoodleQuickForm_group { * @param array $options Options to control the element's display * @param mixed $attributes Either a typical HTML attribute string or an associative array */ - function MoodleQuickForm_date_time_selector($elementName = null, $elementLabel = null, $options = array(), $attributes = null) { + public function __construct($elementName = null, $elementLabel = null, $options = array(), $attributes = null) { // Get the calendar type used - see MDL-18375. $calendartype = \core_calendar\type_factory::get_calendar_instance(); $this->_options = array('startyear' => $calendartype->get_min_year(), 'stopyear' => $calendartype->get_max_year(), 'defaulttime' => 0, 'timezone' => 99, 'step' => 5, 'optional' => false); - $this->HTML_QuickForm_element($elementName, $elementLabel, $attributes); + HTML_QuickForm_element::__construct($elementName, $elementLabel, $attributes); $this->_persistantFreeze = true; $this->_appendName = true; $this->_type = 'date_time_selector'; @@ -106,6 +106,16 @@ function MoodleQuickForm_date_time_selector($elementName = null, $elementLabel = } } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_date_time_selector($elementName = null, $elementLabel = null, $options = array(), $attributes = null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $options, $attributes); + } + /** * This will create date group element constisting of day, month and year. * diff --git a/lib/form/duration.php b/lib/form/duration.php index 4298f00215048..7c29757b67bc0 100644 --- a/lib/form/duration.php +++ b/lib/form/duration.php @@ -63,8 +63,8 @@ class MoodleQuickForm_duration extends MoodleQuickForm_group { * If not specified, minutes is used. * @param mixed $attributes Either a typical HTML attribute string or an associative array */ - function MoodleQuickForm_duration($elementName = null, $elementLabel = null, $options = array(), $attributes = null) { - $this->HTML_QuickForm_element($elementName, $elementLabel, $attributes); + public function __construct($elementName = null, $elementLabel = null, $options = array(), $attributes = null) { + HTML_QuickForm_element::__construct($elementName, $elementLabel, $attributes); $this->_persistantFreeze = true; $this->_appendName = true; $this->_type = 'duration'; @@ -83,6 +83,16 @@ function MoodleQuickForm_duration($elementName = null, $elementLabel = null, $op } } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_duration($elementName = null, $elementLabel = null, $options = array(), $attributes = null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $options, $attributes); + } + /** * Returns time associative array of unit length. * diff --git a/lib/form/editor.php b/lib/form/editor.php index 0c18b2122d0b9..4e06505dfb2a9 100644 --- a/lib/form/editor.php +++ b/lib/form/editor.php @@ -68,7 +68,7 @@ class MoodleQuickForm_editor extends HTML_QuickForm_element { * or an associative array * @param array $options set of options to initalize filepicker */ - function MoodleQuickForm_editor($elementName=null, $elementLabel=null, $attributes=null, $options=null) { + public function __construct($elementName=null, $elementLabel=null, $attributes=null, $options=null) { global $CFG, $PAGE; $options = (array)$options; @@ -89,7 +89,7 @@ function MoodleQuickForm_editor($elementName=null, $elementLabel=null, $attribut } } $this->_options['trusted'] = trusttext_trusted($this->_options['context']); - parent::HTML_QuickForm_element($elementName, $elementLabel, $attributes); + parent::__construct($elementName, $elementLabel, $attributes); // Note: for some reason the code using this setting does not like bools. $this->_options['subdirs'] = (int)($this->_options['subdirs'] == 1); @@ -97,6 +97,16 @@ function MoodleQuickForm_editor($elementName=null, $elementLabel=null, $attribut editors_head_setup(); } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_editor($elementName=null, $elementLabel=null, $attributes=null, $options=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $attributes, $options); + } + /** * Called by HTML_QuickForm whenever form event is made on this element * diff --git a/lib/form/filemanager.php b/lib/form/filemanager.php index 8140fec153d50..d52525312973a 100644 --- a/lib/form/filemanager.php +++ b/lib/form/filemanager.php @@ -60,7 +60,7 @@ class MoodleQuickForm_filemanager extends HTML_QuickForm_element { * or an associative array * @param array $options set of options to initalize filemanager */ - function MoodleQuickForm_filemanager($elementName=null, $elementLabel=null, $attributes=null, $options=null) { + public function __construct($elementName=null, $elementLabel=null, $attributes=null, $options=null) { global $CFG, $PAGE; $options = (array)$options; @@ -76,7 +76,17 @@ function MoodleQuickForm_filemanager($elementName=null, $elementLabel=null, $att $this->_options['return_types'] = (FILE_INTERNAL | FILE_REFERENCE); } $this->_type = 'filemanager'; - parent::HTML_QuickForm_element($elementName, $elementLabel, $attributes); + parent::__construct($elementName, $elementLabel, $attributes); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_filemanager($elementName=null, $elementLabel=null, $attributes=null, $options=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $attributes, $options); } /** diff --git a/lib/form/filepicker.php b/lib/form/filepicker.php index da5aff8a3e1f4..16340963f2048 100644 --- a/lib/form/filepicker.php +++ b/lib/form/filepicker.php @@ -59,7 +59,7 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_input { * or an associative array * @param array $options set of options to initalize filepicker */ - function MoodleQuickForm_filepicker($elementName=null, $elementLabel=null, $attributes=null, $options=null) { + public function __construct($elementName=null, $elementLabel=null, $attributes=null, $options=null) { global $CFG, $PAGE; $options = (array)$options; @@ -81,7 +81,17 @@ function MoodleQuickForm_filepicker($elementName=null, $elementLabel=null, $attr } $this->_options['maxbytes'] = get_user_max_upload_file_size($PAGE->context, $CFG->maxbytes, $coursemaxbytes, $fpmaxbytes); $this->_type = 'filepicker'; - parent::HTML_QuickForm_input($elementName, $elementLabel, $attributes); + parent::__construct($elementName, $elementLabel, $attributes); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_filepicker($elementName=null, $elementLabel=null, $attributes=null, $options=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $attributes, $options); } /** diff --git a/lib/form/grading.php b/lib/form/grading.php index 18191dd6d40aa..c47de8a0ed3ee 100644 --- a/lib/form/grading.php +++ b/lib/form/grading.php @@ -61,11 +61,21 @@ class MoodleQuickForm_grading extends HTML_QuickForm_input{ * @param mixed $elementLabel Label(s) for the input field * @param mixed $attributes Either a typical HTML attribute string or an associative array */ - public function MoodleQuickForm_grading($elementName=null, $elementLabel=null, $attributes=null) { - parent::HTML_QuickForm_input($elementName, $elementLabel, $attributes); + public function __construct($elementName=null, $elementLabel=null, $attributes=null) { + parent::__construct($elementName, $elementLabel, $attributes); $this->gradingattributes = $attributes; } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_grading($elementName=null, $elementLabel=null, $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $attributes); + } + /** * Helper function to retrieve gradingform_instance passed in element attributes * diff --git a/lib/form/group.php b/lib/form/group.php index 3d95d9f53db02..753977f108733 100644 --- a/lib/form/group.php +++ b/lib/form/group.php @@ -50,8 +50,18 @@ class MoodleQuickForm_group extends HTML_QuickForm_group{ * @param string $separator (optional) string to seperate elements. * @param string $appendName (optional) string to appened to grouped elements. */ - function MoodleQuickForm_group($elementName=null, $elementLabel=null, $elements=null, $separator=null, $appendName = true) { - parent::HTML_QuickForm_group($elementName, $elementLabel, $elements, $separator, $appendName); + public function __construct($elementName=null, $elementLabel=null, $elements=null, $separator=null, $appendName = true) { + parent::__construct($elementName, $elementLabel, $elements, $separator, $appendName); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_group($elementName=null, $elementLabel=null, $elements=null, $separator=null, $appendName = true) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $elements, $separator, $appendName); } /** @var string template type, would cause problems with client side validation so will leave for now */ diff --git a/lib/form/header.php b/lib/form/header.php index 36c5a08e6f3cc..f5f1ed57722ea 100644 --- a/lib/form/header.php +++ b/lib/form/header.php @@ -48,8 +48,18 @@ class MoodleQuickForm_header extends HTML_QuickForm_header * @param string $elementName name of the header element * @param string $text text displayed in header element */ - function MoodleQuickForm_header($elementName = null, $text = null) { - parent::HTML_QuickForm_header($elementName, $text); + public function __construct($elementName = null, $text = null) { + parent::__construct($elementName, $text); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_header($elementName = null, $text = null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $text); } /** diff --git a/lib/form/hidden.php b/lib/form/hidden.php index 6c2f239264b43..d21c029a51063 100644 --- a/lib/form/hidden.php +++ b/lib/form/hidden.php @@ -49,8 +49,18 @@ class MoodleQuickForm_hidden extends HTML_QuickForm_hidden{ * @param mixed $attributes (optional) Either a typical HTML attribute string * or an associative array */ - function MoodleQuickForm_hidden($elementName=null, $value='', $attributes=null) { - parent::HTML_QuickForm_hidden($elementName, $value, $attributes); + public function __construct($elementName=null, $value='', $attributes=null) { + parent::__construct($elementName, $value, $attributes); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_hidden($elementName=null, $value='', $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + return self::__construct($elementName, $value, $attributes); } /** diff --git a/lib/form/htmleditor.php b/lib/form/htmleditor.php index adddc3fcf3e48..32353d673768c 100644 --- a/lib/form/htmleditor.php +++ b/lib/form/htmleditor.php @@ -54,8 +54,8 @@ class MoodleQuickForm_htmleditor extends MoodleQuickForm_textarea{ * @param array $attributes (optional) Either a typical HTML attribute string * or an associative array */ - function MoodleQuickForm_htmleditor($elementName=null, $elementLabel=null, $options=array(), $attributes=null){ - parent::MoodleQuickForm_textarea($elementName, $elementLabel, $attributes); + public function __construct($elementName=null, $elementLabel=null, $options=array(), $attributes=null){ + parent::__construct($elementName, $elementLabel, $attributes); // set the options, do not bother setting bogus ones if (is_array($options)) { foreach ($options as $name => $value) { @@ -73,6 +73,16 @@ function MoodleQuickForm_htmleditor($elementName=null, $elementLabel=null, $opti editors_head_setup(); } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_htmleditor($elementName=null, $elementLabel=null, $options=array(), $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $options, $attributes); + } + /** * Returns the input field in HTML * diff --git a/lib/form/listing.php b/lib/form/listing.php index 102b492571506..cd9477cb33ade 100644 --- a/lib/form/listing.php +++ b/lib/form/listing.php @@ -73,7 +73,7 @@ class MoodleQuickForm_listing extends HTML_QuickForm_input { * @param array $attributes (optional) Either a typical HTML attribute string or an associative array. * @param array $options set of options to initalize listing. */ - function MoodleQuickForm_listing($elementName=null, $elementLabel=null, $attributes=null, $options=array()) { + public function __construct($elementName=null, $elementLabel=null, $attributes=null, $options=array()) { $this->_type = 'listing'; if (!empty($options['items'])) { @@ -89,7 +89,17 @@ function MoodleQuickForm_listing($elementName=null, $elementLabel=null, $attribu } else { $this->hideall = get_string('hide'); } - parent::HTML_QuickForm_input($elementName, $elementLabel, $attributes); + parent::__construct($elementName, $elementLabel, $attributes); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_listing($elementName=null, $elementLabel=null, $attributes=null, $options=array()) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $attributes, $options); } /** diff --git a/lib/form/modgrade.php b/lib/form/modgrade.php index d76122b7039d5..19c3ee08167a2 100644 --- a/lib/form/modgrade.php +++ b/lib/form/modgrade.php @@ -53,13 +53,23 @@ class MoodleQuickForm_modgrade extends MoodleQuickForm_group{ * @param array $options Options to control the element's display. Not used. * @param mixed $attributes Either a typical HTML attribute string or an associative array */ - public function MoodleQuickForm_modgrade($elementname = null, $elementlabel = null, $options = array(), $attributes = null) { - $this->HTML_QuickForm_element($elementname, $elementlabel, $attributes); + public function __construct($elementname = null, $elementlabel = null, $options = array(), $attributes = null) { + HTML_QuickForm_element::__construct($elementname, $elementlabel, $attributes); $this->_persistantFreeze = true; $this->_appendName = true; $this->_type = 'modgrade'; } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_modgrade($elementname = null, $elementlabel = null, $options = array(), $attributes = null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementname, $elementlabel, $options, $attributes); + } + /** * Create elements for this group. */ diff --git a/lib/form/modvisible.php b/lib/form/modvisible.php index 2a6acd9437f3d..99fca08a561f3 100644 --- a/lib/form/modvisible.php +++ b/lib/form/modvisible.php @@ -48,12 +48,19 @@ class MoodleQuickForm_modvisible extends MoodleQuickForm_select{ * @param mixed $attributes Either a typical HTML attribute string or an associative array * @param array $options ignored */ - function MoodleQuickForm_modvisible($elementName=null, $elementLabel=null, $attributes=null, $options=null) - { - HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes, null); + public function __construct($elementName=null, $elementLabel=null, $attributes=null, $options=null) { + HTML_QuickForm_element::__construct($elementName, $elementLabel, $attributes, null); $this->_type = 'modvisible'; + } - + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_modvisible($elementName=null, $elementLabel=null, $attributes=null, $options=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $attributes, $options); } /** diff --git a/lib/form/password.php b/lib/form/password.php index 4265ec6fa1b95..82153bca9191f 100644 --- a/lib/form/password.php +++ b/lib/form/password.php @@ -49,7 +49,7 @@ class MoodleQuickForm_password extends HTML_QuickForm_password{ * @param mixed $attributes (optional) Either a typical HTML attribute string * or an associative array */ - function MoodleQuickForm_password($elementName=null, $elementLabel=null, $attributes=null) { + public function __construct($elementName=null, $elementLabel=null, $attributes=null) { global $CFG; // no standard mform in moodle should allow autocomplete of passwords if (empty($attributes)) { @@ -62,7 +62,17 @@ function MoodleQuickForm_password($elementName=null, $elementLabel=null, $attrib } } - parent::HTML_QuickForm_password($elementName, $elementLabel, $attributes); + parent::__construct($elementName, $elementLabel, $attributes); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_password($elementName=null, $elementLabel=null, $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $attributes); } /** diff --git a/lib/form/passwordunmask.php b/lib/form/passwordunmask.php index 15bd4bc35d27a..b8d4102ea817c 100644 --- a/lib/form/passwordunmask.php +++ b/lib/form/passwordunmask.php @@ -51,7 +51,7 @@ class MoodleQuickForm_passwordunmask extends MoodleQuickForm_password { * @param mixed $attributes (optional) Either a typical HTML attribute string * or an associative array */ - function MoodleQuickForm_passwordunmask($elementName=null, $elementLabel=null, $attributes=null) { + public function __construct($elementName=null, $elementLabel=null, $attributes=null) { global $CFG; // no standard mform in moodle should allow autocomplete of passwords if (empty($attributes)) { @@ -64,7 +64,17 @@ function MoodleQuickForm_passwordunmask($elementName=null, $elementLabel=null, $ } } - parent::MoodleQuickForm_password($elementName, $elementLabel, $attributes); + parent::__construct($elementName, $elementLabel, $attributes); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_passwordunmask($elementName=null, $elementLabel=null, $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $attributes); } /** diff --git a/lib/form/questioncategory.php b/lib/form/questioncategory.php index 4f7d9998ffd21..8ebe1d0fd7ff8 100644 --- a/lib/form/questioncategory.php +++ b/lib/form/questioncategory.php @@ -53,8 +53,8 @@ class MoodleQuickForm_questioncategory extends MoodleQuickForm_selectgroups { * from moodlelib.php. * @param mixed $attributes Either a typical HTML attribute string or an associative array */ - function MoodleQuickForm_questioncategory($elementName = null, $elementLabel = null, $options = null, $attributes = null) { - MoodleQuickForm_selectgroups::MoodleQuickForm_selectgroups($elementName, $elementLabel, array(), $attributes); + public function __construct($elementName = null, $elementLabel = null, $options = null, $attributes = null) { + parent::__construct($elementName, $elementLabel, array(), $attributes); $this->_type = 'questioncategory'; if (is_array($options)) { $this->_options = $options + $this->_options; @@ -64,4 +64,13 @@ function MoodleQuickForm_questioncategory($elementName = null, $elementLabel = n } } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_questioncategory($elementName = null, $elementLabel = null, $options = null, $attributes = null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $options, $attributes); + } } diff --git a/lib/form/radio.php b/lib/form/radio.php index 6aaa7809a0b4c..3f6a731872d67 100644 --- a/lib/form/radio.php +++ b/lib/form/radio.php @@ -51,8 +51,18 @@ class MoodleQuickForm_radio extends HTML_QuickForm_radio{ * @param mixed $attributes (optional) Either a typical HTML attribute string * or an associative array */ - function MoodleQuickForm_radio($elementName=null, $elementLabel=null, $text=null, $value=null, $attributes=null) { - parent::HTML_QuickForm_radio($elementName, $elementLabel, $text, $value, $attributes); + public function __construct($elementName=null, $elementLabel=null, $text=null, $value=null, $attributes=null) { + parent::__construct($elementName, $elementLabel, $text, $value, $attributes); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_radio($elementName=null, $elementLabel=null, $text=null, $value=null, $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $text, $value, $attributes); } /** diff --git a/lib/form/recaptcha.php b/lib/form/recaptcha.php index 2080088562779..f043353c3b263 100644 --- a/lib/form/recaptcha.php +++ b/lib/form/recaptcha.php @@ -53,9 +53,9 @@ class MoodleQuickForm_recaptcha extends HTML_QuickForm_input { * @param mixed $attributes (optional) Either a typical HTML attribute string * or an associative array */ - function MoodleQuickForm_recaptcha($elementName = null, $elementLabel = null, $attributes = null) { + public function __construct($elementName = null, $elementLabel = null, $attributes = null) { global $CFG; - parent::HTML_QuickForm_input($elementName, $elementLabel, $attributes); + parent::__construct($elementName, $elementLabel, $attributes); $this->_type = 'recaptcha'; if (is_https()) { $this->_https = true; @@ -64,6 +64,16 @@ function MoodleQuickForm_recaptcha($elementName = null, $elementLabel = null, $a } } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_recaptcha($elementName = null, $elementLabel = null, $attributes = null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $attributes); + } + /** * Returns the recaptcha element in HTML * diff --git a/lib/form/searchableselector.php b/lib/form/searchableselector.php index 681549bd72fe0..458a23c2d83fe 100644 --- a/lib/form/searchableselector.php +++ b/lib/form/searchableselector.php @@ -49,12 +49,22 @@ class MoodleQuickForm_searchableselector extends MoodleQuickForm_select{ * @param array $options additional options. * @param mixed $attributes Either a typical HTML attribute string or an associative array */ - function MoodleQuickForm_searchableselector($elementName=null, $elementLabel=null, $options=null, $attributes=null) { + public function __construct($elementName=null, $elementLabel=null, $options=null, $attributes=null) { //set size default to 12 if (empty($attributes) || empty($attributes['size'])) { $attributes['size'] = 12; } - parent::MoodleQuickForm_select($elementName, $elementLabel, $options, $attributes); + parent::__construct($elementName, $elementLabel, $options, $attributes); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_searchableselector($elementName=null, $elementLabel=null, $options=null, $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $options, $attributes); } /** diff --git a/lib/form/select.php b/lib/form/select.php index 8b0beba392064..aa888cb562769 100644 --- a/lib/form/select.php +++ b/lib/form/select.php @@ -52,8 +52,18 @@ class MoodleQuickForm_select extends HTML_QuickForm_select{ * @param mixed $options Data to be used to populate options * @param mixed $attributes Either a typical HTML attribute string or an associative array */ - function MoodleQuickForm_select($elementName=null, $elementLabel=null, $options=null, $attributes=null) { - parent::HTML_QuickForm_select($elementName, $elementLabel, $options, $attributes); + public function __construct($elementName=null, $elementLabel=null, $options=null, $attributes=null) { + parent::__construct($elementName, $elementLabel, $options, $attributes); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_select($elementName=null, $elementLabel=null, $options=null, $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $options, $attributes); } /** diff --git a/lib/form/selectgroups.php b/lib/form/selectgroups.php index 2d5dd635d3142..c942acbdf5eb7 100644 --- a/lib/form/selectgroups.php +++ b/lib/form/selectgroups.php @@ -63,10 +63,10 @@ class MoodleQuickForm_selectgroups extends HTML_QuickForm_element { * @param mixed $attributes Either a typical HTML attribute string or an associative array * @param bool $showchoose add standard moodle "Choose..." option as first item */ - function MoodleQuickForm_selectgroups($elementName=null, $elementLabel=null, $optgrps=null, $attributes=null, $showchoose=false) + public function __construct($elementName=null, $elementLabel=null, $optgrps=null, $attributes=null, $showchoose=false) { $this->showchoose = $showchoose; - HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes); + parent::__construct($elementName, $elementLabel, $attributes); $this->_persistantFreeze = true; $this->_type = 'selectgroups'; if (isset($optgrps)) { @@ -74,6 +74,16 @@ function MoodleQuickForm_selectgroups($elementName=null, $elementLabel=null, $op } } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_selectgroups($elementName=null, $elementLabel=null, $optgrps=null, $attributes=null, $showchoose=false) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $optgrps, $attributes, $showchoose); + } + /** * Sets the default values of the select box * diff --git a/lib/form/selectwithlink.php b/lib/form/selectwithlink.php index 4377b316464ca..78832d9376bfc 100644 --- a/lib/form/selectwithlink.php +++ b/lib/form/selectwithlink.php @@ -62,8 +62,7 @@ class MoodleQuickForm_selectwithlink extends HTML_QuickForm_select{ * @param mixed $attributes Either a typical HTML attribute string or an associative array * @param bool $linkdata data to be posted */ - function MoodleQuickForm_selectwithlink($elementName=null, $elementLabel=null, $options=null, $attributes=null, $linkdata=null) - { + public function __construct($elementName=null, $elementLabel=null, $options=null, $attributes=null, $linkdata=null) { if (!empty($linkdata['link']) && !empty($linkdata['label'])) { $this->_link = $linkdata['link']; $this->_linklabel = $linkdata['label']; @@ -73,7 +72,17 @@ function MoodleQuickForm_selectwithlink($elementName=null, $elementLabel=null, $ $this->_linkreturn = $linkdata['return']; } - parent::HTML_QuickForm_select($elementName, $elementLabel, $options, $attributes); + parent::__construct($elementName, $elementLabel, $options, $attributes); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_selectwithlink($elementName=null, $elementLabel=null, $options=null, $attributes=null, $linkdata=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $options, $attributes, $linkdata); } /** diff --git a/lib/form/selectyesno.php b/lib/form/selectyesno.php index d88a276c08cd5..8ccf82b87c4fc 100644 --- a/lib/form/selectyesno.php +++ b/lib/form/selectyesno.php @@ -47,13 +47,22 @@ class MoodleQuickForm_selectyesno extends MoodleQuickForm_select{ * @param mixed $attributes Either a typical HTML attribute string or an associative array * @param mixed $options ignored, not used. */ - function MoodleQuickForm_selectyesno($elementName=null, $elementLabel=null, $attributes=null, $options=null) - { - HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes, null); + public function __construct($elementName=null, $elementLabel=null, $attributes=null, $options=null) { + HTML_QuickForm_element::__construct($elementName, $elementLabel, $attributes, null); $this->_type = 'selectyesno'; $this->_persistantFreeze = true; } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_selectyesno($elementName=null, $elementLabel=null, $attributes=null, $options=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $attributes, $options); + } + /** * Called by HTML_QuickForm whenever form event is made on this element * diff --git a/lib/form/static.php b/lib/form/static.php index 716b026884943..391be8e0cc7c0 100644 --- a/lib/form/static.php +++ b/lib/form/static.php @@ -51,8 +51,18 @@ class MoodleQuickForm_static extends HTML_QuickForm_static{ * @param string $elementLabel (optional) text field label * @param string $text (optional) Text to put in text field */ - function MoodleQuickForm_static($elementName=null, $elementLabel=null, $text=null) { - parent::HTML_QuickForm_static($elementName, $elementLabel, $text); + public function __construct($elementName=null, $elementLabel=null, $text=null) { + parent::__construct($elementName, $elementLabel, $text); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_static($elementName=null, $elementLabel=null, $text=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $text); } /** diff --git a/lib/form/submit.php b/lib/form/submit.php index af94e4f6872fb..c0e2d9638039f 100644 --- a/lib/form/submit.php +++ b/lib/form/submit.php @@ -45,8 +45,18 @@ class MoodleQuickForm_submit extends HTML_QuickForm_submit { * @param string $value (optional) field label * @param string $attributes (optional) Either a typical HTML attribute string or an associative array */ - function MoodleQuickForm_submit($elementName=null, $value=null, $attributes=null) { - parent::HTML_QuickForm_submit($elementName, $value, $attributes); + public function __construct($elementName=null, $value=null, $attributes=null) { + parent::__construct($elementName, $value, $attributes); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_submit($elementName=null, $value=null, $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $value, $attributes); } /** diff --git a/lib/form/submitlink.php b/lib/form/submitlink.php index 9b7b5e0aa5e73..bf238a51e3114 100644 --- a/lib/form/submitlink.php +++ b/lib/form/submitlink.php @@ -51,8 +51,18 @@ class MoodleQuickForm_submitlink extends MoodleQuickForm_submit { * @param string $value (optional) field label * @param string $attributes (optional) Either a typical HTML attribute string or an associative array */ - function MoodleQuickForm_submitlink($elementName=null, $value=null, $attributes=null) { - parent::MoodleQuickForm_submit($elementName, $value, $attributes); + public function __construct($elementName=null, $value=null, $attributes=null) { + parent::__construct($elementName, $value, $attributes); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_submitlink($elementName=null, $value=null, $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $value, $attributes); } /** diff --git a/lib/form/tags.php b/lib/form/tags.php index 961a26299218e..a4727672634d9 100644 --- a/lib/form/tags.php +++ b/lib/form/tags.php @@ -71,7 +71,7 @@ class MoodleQuickForm_tags extends MoodleQuickForm_autocomplete { * @param array $options Options to control the element's display * @param mixed $attributes Either a typical HTML attribute string or an associative array. */ - function MoodleQuickForm_tags($elementName = null, $elementLabel = null, $options = array(), $attributes = null) { + public function __construct($elementName = null, $elementLabel = null, $options = array(), $attributes = null) { if (!isset($options['display'])) { $options['display'] = self::DEFAULTUI; } @@ -92,7 +92,17 @@ function MoodleQuickForm_tags($elementName = null, $elementLabel = null, $option $attributes['placeholder'] = get_string('entertags', 'tag'); $attributes['showsuggestions'] = $this->showingofficial; - parent::MoodleQuickForm_autocomplete($elementName, $elementLabel, $validoptions, $attributes); + parent::__construct($elementName, $elementLabel, $validoptions, $attributes); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_tags($elementName = null, $elementLabel = null, $options = array(), $attributes = null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $options, $attributes); } /** diff --git a/lib/form/text.php b/lib/form/text.php index 97a0219eb7192..a1af03b747e4d 100644 --- a/lib/form/text.php +++ b/lib/form/text.php @@ -51,8 +51,18 @@ class MoodleQuickForm_text extends HTML_QuickForm_text{ * @param string $elementLabel (optional) text field label * @param string $attributes (optional) Either a typical HTML attribute string or an associative array */ - function MoodleQuickForm_text($elementName=null, $elementLabel=null, $attributes=null) { - parent::HTML_QuickForm_text($elementName, $elementLabel, $attributes); + public function __construct($elementName=null, $elementLabel=null, $attributes=null) { + parent::__construct($elementName, $elementLabel, $attributes); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_text($elementName=null, $elementLabel=null, $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $attributes); } /** diff --git a/lib/form/textarea.php b/lib/form/textarea.php index f03b610726e02..273fff5cb011a 100644 --- a/lib/form/textarea.php +++ b/lib/form/textarea.php @@ -54,8 +54,18 @@ class MoodleQuickForm_textarea extends HTML_QuickForm_textarea{ * @param string $elementLabel (optional) text field label * @param string $attributes (optional) Either a typical HTML attribute string or an associative array */ - function MoodleQuickForm_textarea($elementName=null, $elementLabel=null, $attributes=null) { - parent::HTML_QuickForm_textarea($elementName, $elementLabel, $attributes); + public function __construct($elementName=null, $elementLabel=null, $attributes=null) { + parent::__construct($elementName, $elementLabel, $attributes); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_textarea($elementName=null, $elementLabel=null, $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $attributes); } /** diff --git a/lib/form/url.php b/lib/form/url.php index 2e62463328135..4a22571136cab 100644 --- a/lib/form/url.php +++ b/lib/form/url.php @@ -51,7 +51,7 @@ class MoodleQuickForm_url extends HTML_QuickForm_text{ * @param mixed $attributes Either a typical HTML attribute string or an associative array. * @param array $options data which need to be posted. */ - function MoodleQuickForm_url($elementName=null, $elementLabel=null, $attributes=null, $options=null) { + public function __construct($elementName=null, $elementLabel=null, $attributes=null, $options=null) { global $CFG; require_once("$CFG->dirroot/repository/lib.php"); $options = (array)$options; @@ -61,7 +61,17 @@ function MoodleQuickForm_url($elementName=null, $elementLabel=null, $attributes= if (!isset($this->_options['usefilepicker'])) { $this->_options['usefilepicker'] = true; } - parent::HTML_QuickForm_text($elementName, $elementLabel, $attributes); + parent::__construct($elementName, $elementLabel, $attributes); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_url($elementName=null, $elementLabel=null, $attributes=null, $options=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $attributes, $options); } /** diff --git a/lib/form/warning.php b/lib/form/warning.php index 90865ea1cc26a..38c21a3d18e53 100644 --- a/lib/form/warning.php +++ b/lib/form/warning.php @@ -53,8 +53,8 @@ class MoodleQuickForm_warning extends HTML_QuickForm_static{ * @param string $elementClass (optional) show as warning or notification => 'notifyproblem' * @param string $text (optional) Text to put in warning field */ - function MoodleQuickForm_warning($elementName=null, $elementClass='notifyproblem', $text=null) { - parent::HTML_QuickForm_static($elementName, null, $text); + public function __construct($elementName=null, $elementClass='notifyproblem', $text=null) { + parent::__construct($elementName, null, $text); $this->_type = 'warning'; if (is_null($elementClass)) { $elementClass = 'notifyproblem'; @@ -62,6 +62,16 @@ function MoodleQuickForm_warning($elementName=null, $elementClass='notifyproblem $this->_class = $elementClass; } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_warning($elementName=null, $elementClass='notifyproblem', $text=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementClass, $text); + } + /** * Returns HTML for this form element. * diff --git a/lib/formslib.php b/lib/formslib.php index e65979c76963b..ef8646bce34fe 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -157,7 +157,7 @@ abstract class moodleform { * @param mixed $attributes you can pass a string of html attributes here or an array. * @param bool $editable */ - function moodleform($action=null, $customdata=null, $method='post', $target='', $attributes=null, $editable=true) { + public function __construct($action=null, $customdata=null, $method='post', $target='', $attributes=null, $editable=true) { global $CFG, $FULLME; // no standard mform in moodle should allow autocomplete with the exception of user signup if (empty($attributes)) { @@ -207,6 +207,16 @@ function moodleform($action=null, $customdata=null, $method='post', $target='', $this->_process_submission($method); } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function moodleform($action=null, $customdata=null, $method='post', $target='', $attributes=null, $editable=true) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($action, $customdata, $method, $target, $attributes, $editable); + } + /** * It should returns unique identifier for the form. * Currently it will return class name, but in case two same forms have to be @@ -1426,12 +1436,12 @@ class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless { * @param string $target (optional)Form's target defaults to none * @param mixed $attributes (optional)Extra attributes for
tag */ - function MoodleQuickForm($formName, $method, $action, $target='', $attributes=null){ + public function __construct($formName, $method, $action, $target='', $attributes=null) { global $CFG, $OUTPUT; static $formcounter = 1; - HTML_Common::HTML_Common($attributes); + HTML_Common::__construct($attributes); $target = empty($target) ? array() : array('target' => $target); $this->_formName = $formName; if (is_a($action, 'moodle_url')){ @@ -1460,6 +1470,16 @@ function MoodleQuickForm($formName, $method, $action, $target='', $attributes=nu $this->setRequiredNote(get_string('somefieldsrequired', 'form', ''.get_string('requiredelement', 'form').'')); } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm($formName, $method, $action, $target='', $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($formName, $method, $action, $target, $attributes); + } + /** * Use this method to indicate an element in a form is an advanced field. If items in a form * are marked as advanced then 'Hide/Show Advanced' buttons will automatically be displayed in the @@ -2594,7 +2614,7 @@ class MoodleQuickForm_Renderer extends HTML_QuickForm_Renderer_Tableless{ /** * Constructor */ - function MoodleQuickForm_Renderer(){ + public function __construct() { // switch next two lines for ol li containers for form items. // $this->_elementTemplates=array('default'=>"\n\t\t".'
  • {error}
    {element}
  • '); $this->_elementTemplates = array( @@ -2610,7 +2630,17 @@ function MoodleQuickForm_Renderer(){ 'nodisplay'=>''); - parent::HTML_QuickForm_Renderer_Tableless(); + parent::__construct(); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_Renderer() { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct(); } /** diff --git a/lib/pear/HTML/Common.php b/lib/pear/HTML/Common.php index 2c510109d0ccb..b86217910a530 100644 --- a/lib/pear/HTML/Common.php +++ b/lib/pear/HTML/Common.php @@ -83,12 +83,22 @@ class HTML_Common { * @param int $tabOffset Indent offset in tabs * @access public */ - function HTML_Common($attributes = null, $tabOffset = 0) + public function __construct($attributes = null, $tabOffset = 0) { $this->setAttributes($attributes); $this->setTabOffset($tabOffset); } // end constructor + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_Common($attributes = null, $tabOffset = 0) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($attributes, $tabOffset); + } + public static function raiseError($message = null, $code = null, $mode = null, diff --git a/lib/pear/HTML/QuickForm.php b/lib/pear/HTML/QuickForm.php index 6da6ff4b1adb4..bf8062ef4c794 100644 --- a/lib/pear/HTML/QuickForm.php +++ b/lib/pear/HTML/QuickForm.php @@ -253,9 +253,9 @@ class HTML_QuickForm extends HTML_Common { * @param bool $trackSubmit (optional)Whether to track if the form was submitted by adding a special hidden field * @access public */ - function HTML_QuickForm($formName='', $method='post', $action='', $target='', $attributes=null, $trackSubmit = false) + public function __construct($formName='', $method='post', $action='', $target='', $attributes=null, $trackSubmit = false) { - HTML_Common::HTML_Common($attributes); + parent::__construct($attributes); $method = (strtoupper($method) == 'GET') ? 'get' : 'post'; $action = ($action == '') ? $_SERVER['PHP_SELF'] : $action; $target = empty($target) ? array() : array('target' => $target); @@ -301,6 +301,16 @@ function HTML_QuickForm($formName='', $method='post', $action='', $target='', $a } } // end constructor + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm($formName='', $method='post', $action='', $target='', $attributes=null, $trackSubmit = false) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($formName, $method, $action, $target, $attributes, $trackSubmit); + } + // }}} // {{{ apiVersion() @@ -1983,16 +1993,27 @@ class HTML_QuickForm_Error extends PEAR_Error { * @param int $level intensity of the error (PHP error code) * @param mixed $debuginfo any information that can inform user as to nature of the error */ - function HTML_QuickForm_Error($code = QUICKFORM_ERROR, $mode = PEAR_ERROR_RETURN, + public function __construct($code = QUICKFORM_ERROR, $mode = PEAR_ERROR_RETURN, $level = E_USER_NOTICE, $debuginfo = null) { if (is_int($code)) { - $this->PEAR_Error(HTML_QuickForm::errorMessage($code), $code, $mode, $level, $debuginfo); + parent::__construct(HTML_QuickForm::errorMessage($code), $code, $mode, $level, $debuginfo); } else { - $this->PEAR_Error("Invalid error code: $code", QUICKFORM_ERROR, $mode, $level, $debuginfo); + parent::__construct("Invalid error code: $code", QUICKFORM_ERROR, $mode, $level, $debuginfo); } } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_Error($code = QUICKFORM_ERROR, $mode = PEAR_ERROR_RETURN, + $level = E_USER_NOTICE, $debuginfo = null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($code, $mode, $level, $debuginfo); + } + // }}} } // end class HTML_QuickForm_Error ?> diff --git a/lib/pear/HTML/QuickForm/Renderer.php b/lib/pear/HTML/QuickForm/Renderer.php index 7162c641bb9f3..324fbf78c1ec8 100644 --- a/lib/pear/HTML/QuickForm/Renderer.php +++ b/lib/pear/HTML/QuickForm/Renderer.php @@ -33,10 +33,19 @@ class HTML_QuickForm_Renderer * * @access public */ - function HTML_QuickForm_Renderer() - { + public function __construct() { } // end constructor + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_Renderer() { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct(); + } + /** * Called when visiting a form, before processing any form elements * diff --git a/lib/pear/HTML/QuickForm/Renderer/Array.php b/lib/pear/HTML/QuickForm/Renderer/Array.php index ee0c4ced7cfeb..a91d90b7eedf1 100644 --- a/lib/pear/HTML/QuickForm/Renderer/Array.php +++ b/lib/pear/HTML/QuickForm/Renderer/Array.php @@ -147,13 +147,21 @@ class HTML_QuickForm_Renderer_Array extends HTML_QuickForm_Renderer * @param bool true: render an array of labels to many labels, $key 0 to 'label' and the oterh to "label_$key" * @access public */ - function HTML_QuickForm_Renderer_Array($collectHidden = false, $staticLabels = false) - { - $this->HTML_QuickForm_Renderer(); + public function __construct($collectHidden = false, $staticLabels = false) { + parent::__construct(); $this->_collectHidden = $collectHidden; $this->_staticLabels = $staticLabels; } // end constructor + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_Renderer_Array($collectHidden = false, $staticLabels = false) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($collectHidden, $staticLabels); + } /** * Returns the resultant array diff --git a/lib/pear/HTML/QuickForm/Renderer/Default.php b/lib/pear/HTML/QuickForm/Renderer/Default.php index 5eeee14a141c1..7c54c130bf3d6 100644 --- a/lib/pear/HTML/QuickForm/Renderer/Default.php +++ b/lib/pear/HTML/QuickForm/Renderer/Default.php @@ -141,9 +141,18 @@ class HTML_QuickForm_Renderer_Default extends HTML_QuickForm_Renderer * * @access public */ - function HTML_QuickForm_Renderer_Default() - { - $this->HTML_QuickForm_Renderer(); + public function __construct() { + parent::__construct(); + } // end constructor + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_Renderer_Default() { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct(); } // end constructor /** diff --git a/lib/pear/HTML/QuickForm/Renderer/Object.php b/lib/pear/HTML/QuickForm/Renderer/Object.php index 9ed495c7c643d..9928a0b3d586f 100644 --- a/lib/pear/HTML/QuickForm/Renderer/Object.php +++ b/lib/pear/HTML/QuickForm/Renderer/Object.php @@ -78,13 +78,22 @@ class HTML_QuickForm_Renderer_Object extends HTML_QuickForm_Renderer * @param collecthidden bool true: collect all hidden elements * @access public */ - function HTML_QuickForm_Renderer_Object($collecthidden = false) - { - $this->HTML_QuickForm_Renderer(); + public function __construct($collecthidden = false) { + parent::__construct(); $this->_collectHidden = $collecthidden; $this->_obj = new QuickformForm; } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_Renderer_Object($collecthidden = false) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($collecthidden); + } + /** * Return the rendered Object * @access public diff --git a/lib/pear/HTML/QuickForm/Renderer/Tableless.php b/lib/pear/HTML/QuickForm/Renderer/Tableless.php index 7326ede66af23..4ef5a337e7ee2 100644 --- a/lib/pear/HTML/QuickForm/Renderer/Tableless.php +++ b/lib/pear/HTML/QuickForm/Renderer/Tableless.php @@ -118,11 +118,20 @@ class HTML_QuickForm_Renderer_Tableless extends HTML_QuickForm_Renderer_Default * * @access public */ - function HTML_QuickForm_Renderer_Tableless() - { - $this->HTML_QuickForm_Renderer_Default(); + public function __construct() { + parent::__construct(); } // end constructor + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_Renderer_Tableless() { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct(); + } + /** * Called when visiting a header element * diff --git a/lib/pear/HTML/QuickForm/advcheckbox.php b/lib/pear/HTML/QuickForm/advcheckbox.php index cc14b715dbf86..896fa271f712d 100644 --- a/lib/pear/HTML/QuickForm/advcheckbox.php +++ b/lib/pear/HTML/QuickForm/advcheckbox.php @@ -77,12 +77,21 @@ class HTML_QuickForm_advcheckbox extends HTML_QuickForm_checkbox * @access public * @return void */ - function HTML_QuickForm_advcheckbox($elementName=null, $elementLabel=null, $text=null, $attributes=null, $values=null) - { - $this->HTML_QuickForm_checkbox($elementName, $elementLabel, $text, $attributes); + public function __construct($elementName=null, $elementLabel=null, $text=null, $attributes=null, $values=null) { + parent::__construct($elementName, $elementLabel, $text, $attributes); $this->setValues($values); } //end constructor + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_advcheckbox($elementName=null, $elementLabel=null, $text=null, $attributes=null, $values=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $text, $attributes, $values); + } + // }}} // {{{ getPrivateName() diff --git a/lib/pear/HTML/QuickForm/autocomplete.php b/lib/pear/HTML/QuickForm/autocomplete.php index c39bd8dec4cf5..acfbd20badd52 100644 --- a/lib/pear/HTML/QuickForm/autocomplete.php +++ b/lib/pear/HTML/QuickForm/autocomplete.php @@ -75,9 +75,8 @@ class HTML_QuickForm_autocomplete extends HTML_QuickForm_text * @access public * @return void */ - function HTML_QuickForm_autocomplete($elementName = null, $elementLabel = null, $options = null, $attributes = null) - { - $this->HTML_QuickForm_text($elementName, $elementLabel, $attributes); + public function __construct($elementName = null, $elementLabel = null, $options = null, $attributes = null) { + parent::__construct($elementName, $elementLabel, $attributes); $this->_persistantFreeze = true; $this->_type = 'autocomplete'; if (isset($options)) { @@ -85,6 +84,16 @@ function HTML_QuickForm_autocomplete($elementName = null, $elementLabel = null, } } //end constructor + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_autocomplete($elementName = null, $elementLabel = null, $options = null, $attributes = null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $options, $attributes); + } + // }}} // {{{ setOptions() diff --git a/lib/pear/HTML/QuickForm/button.php b/lib/pear/HTML/QuickForm/button.php index bf6f10e8738b4..95e975ffc7b76 100644 --- a/lib/pear/HTML/QuickForm/button.php +++ b/lib/pear/HTML/QuickForm/button.php @@ -45,13 +45,22 @@ class HTML_QuickForm_button extends HTML_QuickForm_input * @access public * @return void */ - function HTML_QuickForm_button($elementName=null, $value=null, $attributes=null) - { - HTML_QuickForm_input::HTML_QuickForm_input($elementName, null, $attributes); + public function __construct($elementName=null, $value=null, $attributes=null) { + parent::__construct($elementName, null, $attributes); $this->_persistantFreeze = false; $this->setValue($value); $this->setType('button'); } //end constructor + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_button($elementName=null, $value=null, $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $value, $attributes); + } // }}} // {{{ freeze() diff --git a/lib/pear/HTML/QuickForm/checkbox.php b/lib/pear/HTML/QuickForm/checkbox.php index 100f8e7341773..f305fc5f96891 100644 --- a/lib/pear/HTML/QuickForm/checkbox.php +++ b/lib/pear/HTML/QuickForm/checkbox.php @@ -57,15 +57,24 @@ class HTML_QuickForm_checkbox extends HTML_QuickForm_input * @access public * @return void */ - function HTML_QuickForm_checkbox($elementName=null, $elementLabel=null, $text='', $attributes=null) - { - HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes); + public function __construct($elementName=null, $elementLabel=null, $text='', $attributes=null) { + parent::__construct($elementName, $elementLabel, $attributes); $this->_persistantFreeze = true; $this->_text = $text; $this->setType('checkbox'); $this->updateAttributes(array('value'=>1)); } //end constructor - + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_checkbox($elementName=null, $elementLabel=null, $text='', $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $text, $attributes); + } + // }}} // {{{ setChecked() diff --git a/lib/pear/HTML/QuickForm/date.php b/lib/pear/HTML/QuickForm/date.php index 495e76ebcffad..12478376e3367 100644 --- a/lib/pear/HTML/QuickForm/date.php +++ b/lib/pear/HTML/QuickForm/date.php @@ -266,9 +266,8 @@ class HTML_QuickForm_date extends HTML_QuickForm_group * @param array Options to control the element's display * @param mixed Either a typical HTML attribute string or an associative array */ - function HTML_QuickForm_date($elementName = null, $elementLabel = null, $options = array(), $attributes = null) - { - $this->HTML_QuickForm_element($elementName, $elementLabel, $attributes); + public function __construct($elementName = null, $elementLabel = null, $options = array(), $attributes = null) { + HTML_QuickForm_element::__construct($elementName, $elementLabel, $attributes); $this->_persistantFreeze = true; $this->_appendName = true; $this->_type = 'date'; @@ -288,6 +287,16 @@ function HTML_QuickForm_date($elementName = null, $elementLabel = null, $options } } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_date($elementName = null, $elementLabel = null, $options = array(), $attributes = null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $options, $attributes); + } + // }}} // {{{ _createElements() diff --git a/lib/pear/HTML/QuickForm/element.php b/lib/pear/HTML/QuickForm/element.php index a0a600c45f53d..dc615f52e07d5 100644 --- a/lib/pear/HTML/QuickForm/element.php +++ b/lib/pear/HTML/QuickForm/element.php @@ -80,9 +80,8 @@ class HTML_QuickForm_element extends HTML_Common * @access public * @return void */ - function HTML_QuickForm_element($elementName=null, $elementLabel=null, $attributes=null) - { - HTML_Common::HTML_Common($attributes); + public function __construct($elementName=null, $elementLabel=null, $attributes=null) { + parent::__construct($attributes); if (isset($elementName)) { $this->setName($elementName); } @@ -90,6 +89,16 @@ function HTML_QuickForm_element($elementName=null, $elementLabel=null, $attribut $this->setLabel($elementLabel); } } //end constructor + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_element($elementName=null, $elementLabel=null, $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $attributes); + } // }}} // {{{ apiVersion() @@ -359,8 +368,7 @@ function onQuickFormEvent($event, $arg, &$caller) { switch ($event) { case 'createElement': - $className = get_class($this); - $this->$className($arg[0], $arg[1], $arg[2], $arg[3], $arg[4]); + static::__construct($arg[0], $arg[1], $arg[2], $arg[3], $arg[4]); break; case 'addElement': $this->onQuickFormEvent('createElement', $arg, $caller); diff --git a/lib/pear/HTML/QuickForm/file.php b/lib/pear/HTML/QuickForm/file.php index a8906f55c93ce..b698b670a7d71 100644 --- a/lib/pear/HTML/QuickForm/file.php +++ b/lib/pear/HTML/QuickForm/file.php @@ -61,12 +61,21 @@ class HTML_QuickForm_file extends HTML_QuickForm_input * @since 1.0 * @access public */ - function HTML_QuickForm_file($elementName=null, $elementLabel=null, $attributes=null) - { - HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes); + public function __construct($elementName=null, $elementLabel=null, $attributes=null) { + parent::__construct($elementName, $elementLabel, $attributes); $this->setType('file'); } //end constructor - + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_file($elementName=null, $elementLabel=null, $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $attributes); + } + // }}} // {{{ setSize() @@ -176,8 +185,7 @@ function onQuickFormEvent($event, $arg, &$caller) return $this->onQuickFormEvent('updateValue', null, $caller); break; case 'createElement': - $className = get_class($this); - $this->$className($arg[0], $arg[1], $arg[2]); + static::__construct($arg[0], $arg[1], $arg[2], $arg[3], $arg[4]); break; } return true; diff --git a/lib/pear/HTML/QuickForm/group.php b/lib/pear/HTML/QuickForm/group.php index 229d6979e84ac..b400964082e21 100644 --- a/lib/pear/HTML/QuickForm/group.php +++ b/lib/pear/HTML/QuickForm/group.php @@ -92,9 +92,8 @@ class HTML_QuickForm_group extends HTML_QuickForm_element * @access public * @return void */ - function HTML_QuickForm_group($elementName=null, $elementLabel=null, $elements=null, $separator=null, $appendName = true) - { - $this->HTML_QuickForm_element($elementName, $elementLabel); + public function __construct($elementName=null, $elementLabel=null, $elements=null, $separator=null, $appendName = true) { + parent::__construct($elementName, $elementLabel); $this->_type = 'group'; if (isset($elements) && is_array($elements)) { $this->setElements($elements); @@ -107,6 +106,16 @@ function HTML_QuickForm_group($elementName=null, $elementLabel=null, $elements=n } } //end constructor + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_group($elementName=null, $elementLabel=null, $elements=null, $separator=null, $appendName = true) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $elements, $separator, $appendName); + } + // }}} // {{{ setName() diff --git a/lib/pear/HTML/QuickForm/header.php b/lib/pear/HTML/QuickForm/header.php index b13eb2df4db1b..6ba301c3da8fa 100644 --- a/lib/pear/HTML/QuickForm/header.php +++ b/lib/pear/HTML/QuickForm/header.php @@ -38,12 +38,21 @@ class HTML_QuickForm_header extends HTML_QuickForm_static * @access public * @return void */ - function HTML_QuickForm_header($elementName = null, $text = null) - { - $this->HTML_QuickForm_static($elementName, null, $text); + public function __construct($elementName = null, $text = null) { + parent::__construct($elementName, null, $text); $this->_type = 'header'; } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_header($elementName = null, $text = null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $text); + } + // }}} // {{{ accept() diff --git a/lib/pear/HTML/QuickForm/hidden.php b/lib/pear/HTML/QuickForm/hidden.php index e758aeef81dfb..edbade9b79733 100644 --- a/lib/pear/HTML/QuickForm/hidden.php +++ b/lib/pear/HTML/QuickForm/hidden.php @@ -45,13 +45,22 @@ class HTML_QuickForm_hidden extends HTML_QuickForm_input * @access public * @return void */ - function HTML_QuickForm_hidden($elementName=null, $value='', $attributes=null) - { - HTML_QuickForm_input::HTML_QuickForm_input($elementName, null, $attributes); + public function __construct($elementName=null, $value='', $attributes=null) { + parent::__construct($elementName, null, $attributes); $this->setType('hidden'); $this->setValue($value); } //end constructor + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_hidden($elementName=null, $value='', $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + return self::__construct($elementName, $value, $attributes); + } + // }}} // {{{ freeze() diff --git a/lib/pear/HTML/QuickForm/hiddenselect.php b/lib/pear/HTML/QuickForm/hiddenselect.php index 458aa5c3ddc5b..0dc8721edc4fc 100644 --- a/lib/pear/HTML/QuickForm/hiddenselect.php +++ b/lib/pear/HTML/QuickForm/hiddenselect.php @@ -49,9 +49,8 @@ class HTML_QuickForm_hiddenselect extends HTML_QuickForm_select * @access public * @return void */ - function HTML_QuickForm_hiddenselect($elementName=null, $elementLabel=null, $options=null, $attributes=null) - { - HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes); + public function __construct($elementName=null, $elementLabel=null, $options=null, $attributes=null) { + HTML_QuickForm_element::__construct($elementName, $elementLabel, $attributes); $this->_persistantFreeze = true; $this->_type = 'hiddenselect'; if (isset($options)) { @@ -59,6 +58,16 @@ function HTML_QuickForm_hiddenselect($elementName=null, $elementLabel=null, $opt } } //end constructor + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_hiddenselect($elementName=null, $elementLabel=null, $options=null, $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $options, $attributes); + } + // }}} // {{{ toHtml() diff --git a/lib/pear/HTML/QuickForm/hierselect.php b/lib/pear/HTML/QuickForm/hierselect.php index 25de46686df11..ac34db2609d25 100644 --- a/lib/pear/HTML/QuickForm/hierselect.php +++ b/lib/pear/HTML/QuickForm/hierselect.php @@ -114,9 +114,8 @@ class HTML_QuickForm_hierselect extends HTML_QuickForm_group * @access public * @return void */ - function HTML_QuickForm_hierselect($elementName=null, $elementLabel=null, $attributes=null, $separator=null) - { - $this->HTML_QuickForm_element($elementName, $elementLabel, $attributes); + public function __construct($elementName=null, $elementLabel=null, $attributes=null, $separator=null) { + HTML_QuickForm_element::__construct($elementName, $elementLabel, $attributes); $this->_persistantFreeze = true; if (isset($separator)) { $this->_separator = $separator; @@ -125,6 +124,16 @@ function HTML_QuickForm_hierselect($elementName=null, $elementLabel=null, $attri $this->_appendName = true; } //end constructor + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_hierselect($elementName=null, $elementLabel=null, $attributes=null, $separator=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $attributes, $separator); + } + // }}} // {{{ setOptions() diff --git a/lib/pear/HTML/QuickForm/html.php b/lib/pear/HTML/QuickForm/html.php index 10b773e1372b7..a8c6f012dd0fc 100644 --- a/lib/pear/HTML/QuickForm/html.php +++ b/lib/pear/HTML/QuickForm/html.php @@ -40,12 +40,21 @@ class HTML_QuickForm_html extends HTML_QuickForm_static * @access public * @return void */ - function HTML_QuickForm_html($text = null) - { - $this->HTML_QuickForm_static(null, null, $text); + public function __construct($text = null) { + parent::__construct(null, null, $text); $this->_type = 'html'; } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_html($text = null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($text); + } + // }}} // {{{ accept() diff --git a/lib/pear/HTML/QuickForm/image.php b/lib/pear/HTML/QuickForm/image.php index a3cc2e37c2c10..3cdef2ba7123f 100644 --- a/lib/pear/HTML/QuickForm/image.php +++ b/lib/pear/HTML/QuickForm/image.php @@ -44,13 +44,22 @@ class HTML_QuickForm_image extends HTML_QuickForm_input * @access public * @return void */ - function HTML_QuickForm_image($elementName=null, $src='', $attributes=null) - { - HTML_QuickForm_input::HTML_QuickForm_input($elementName, null, $attributes); + public function __construct($elementName=null, $src='', $attributes=null) { + parent::__construct($elementName, null, $attributes); $this->setType('image'); $this->setSource($src); } // end class constructor + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_image($elementName=null, $src='', $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $src, $attributes); + } + // }}} // {{{ setSource() diff --git a/lib/pear/HTML/QuickForm/input.php b/lib/pear/HTML/QuickForm/input.php index f182e7e4dd150..aa197d172e56c 100644 --- a/lib/pear/HTML/QuickForm/input.php +++ b/lib/pear/HTML/QuickForm/input.php @@ -45,11 +45,20 @@ class HTML_QuickForm_input extends HTML_QuickForm_element * @access public * @return void */ - function HTML_QuickForm_input($elementName=null, $elementLabel=null, $attributes=null) - { - $this->HTML_QuickForm_element($elementName, $elementLabel, $attributes); + public function __construct($elementName=null, $elementLabel=null, $attributes=null) { + parent::__construct($elementName, $elementLabel, $attributes); } //end constructor + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_input($elementName=null, $elementLabel=null, $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $attributes); + } + // }}} // {{{ setType() diff --git a/lib/pear/HTML/QuickForm/link.php b/lib/pear/HTML/QuickForm/link.php index 947f76c32bd10..570aba8a42629 100644 --- a/lib/pear/HTML/QuickForm/link.php +++ b/lib/pear/HTML/QuickForm/link.php @@ -57,15 +57,24 @@ class HTML_QuickForm_link extends HTML_QuickForm_static * @return void * @throws */ - function HTML_QuickForm_link($elementName=null, $elementLabel=null, $href=null, $text=null, $attributes=null) - { - HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes); + public function __construct($elementName=null, $elementLabel=null, $href=null, $text=null, $attributes=null) { + HTML_QuickForm_element::__construct($elementName, $elementLabel, $attributes); $this->_persistantFreeze = false; $this->_type = 'link'; $this->setHref($href); $this->_text = $text; } //end constructor - + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_link($elementName=null, $elementLabel=null, $href=null, $text=null, $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $href, $text, $attributes); + } + // }}} // {{{ setName() diff --git a/lib/pear/HTML/QuickForm/password.php b/lib/pear/HTML/QuickForm/password.php index a83d5053e38dc..6d4c73089e27d 100644 --- a/lib/pear/HTML/QuickForm/password.php +++ b/lib/pear/HTML/QuickForm/password.php @@ -46,11 +46,20 @@ class HTML_QuickForm_password extends HTML_QuickForm_input * @return void * @throws */ - function HTML_QuickForm_password($elementName=null, $elementLabel=null, $attributes=null) - { - HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes); + public function __construct($elementName=null, $elementLabel=null, $attributes=null) { + parent::__construct($elementName, $elementLabel, $attributes); $this->setType('password'); } //end constructor + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_password($elementName=null, $elementLabel=null, $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $attributes); + } // }}} // {{{ setSize() diff --git a/lib/pear/HTML/QuickForm/radio.php b/lib/pear/HTML/QuickForm/radio.php index 26320267668a8..ef00cfe24da8d 100644 --- a/lib/pear/HTML/QuickForm/radio.php +++ b/lib/pear/HTML/QuickForm/radio.php @@ -57,9 +57,8 @@ class HTML_QuickForm_radio extends HTML_QuickForm_input * @access public * @return void */ - function HTML_QuickForm_radio($elementName=null, $elementLabel=null, $text=null, $value=null, $attributes=null) - { - $this->HTML_QuickForm_element($elementName, $elementLabel, $attributes); + public function __construct($elementName=null, $elementLabel=null, $text=null, $value=null, $attributes=null) { + HTML_QuickForm_element::__construct($elementName, $elementLabel, $attributes); if (isset($value)) { $this->setValue($value); } @@ -68,6 +67,16 @@ function HTML_QuickForm_radio($elementName=null, $elementLabel=null, $text=null, $this->_text = $text; } //end constructor + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_radio($elementName=null, $elementLabel=null, $text=null, $value=null, $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $text, $value, $attributes); + } + // }}} function _generateId() { diff --git a/lib/pear/HTML/QuickForm/reset.php b/lib/pear/HTML/QuickForm/reset.php index 3533653086661..62ee12f2d64ab 100644 --- a/lib/pear/HTML/QuickForm/reset.php +++ b/lib/pear/HTML/QuickForm/reset.php @@ -45,13 +45,22 @@ class HTML_QuickForm_reset extends HTML_QuickForm_input * @access public * @return void */ - function HTML_QuickForm_reset($elementName=null, $value=null, $attributes=null) - { - HTML_QuickForm_input::HTML_QuickForm_input($elementName, null, $attributes); + public function __construct($elementName=null, $value=null, $attributes=null) { + parent::__construct($elementName, null, $attributes); $this->setValue($value); $this->setType('reset'); } //end constructor + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_reset($elementName=null, $value=null, $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $value, $attributes); + } + // }}} // {{{ freeze() diff --git a/lib/pear/HTML/QuickForm/select.php b/lib/pear/HTML/QuickForm/select.php index f15ad8bcb2930..eda84388c4c8e 100644 --- a/lib/pear/HTML/QuickForm/select.php +++ b/lib/pear/HTML/QuickForm/select.php @@ -66,15 +66,24 @@ class HTML_QuickForm_select extends HTML_QuickForm_element { * @access public * @return void */ - function HTML_QuickForm_select($elementName=null, $elementLabel=null, $options=null, $attributes=null) - { - HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes); + public function __construct($elementName=null, $elementLabel=null, $options=null, $attributes=null) { + parent::__construct($elementName, $elementLabel, $attributes); $this->_persistantFreeze = true; $this->_type = 'select'; if (isset($options)) { $this->load($options); } } //end constructor + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_select($elementName=null, $elementLabel=null, $options=null, $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $attributes); + } // }}} // {{{ apiVersion() diff --git a/lib/pear/HTML/QuickForm/static.php b/lib/pear/HTML/QuickForm/static.php index 69879312afa39..728eabdaa6fb3 100644 --- a/lib/pear/HTML/QuickForm/static.php +++ b/lib/pear/HTML/QuickForm/static.php @@ -49,14 +49,23 @@ class HTML_QuickForm_static extends HTML_QuickForm_element { * @access public * @return void */ - function HTML_QuickForm_static($elementName=null, $elementLabel=null, $text=null) - { - HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel); + public function __construct($elementName=null, $elementLabel=null, $text=null) { + parent::__construct($elementName, $elementLabel); $this->_persistantFreeze = false; $this->_type = 'static'; $this->_text = $text; } //end constructor - + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_static($elementName=null, $elementLabel=null, $text=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $text); + } + // }}} // {{{ setName() diff --git a/lib/pear/HTML/QuickForm/submit.php b/lib/pear/HTML/QuickForm/submit.php index e1d3e7d26e520..6ca23a47cf675 100644 --- a/lib/pear/HTML/QuickForm/submit.php +++ b/lib/pear/HTML/QuickForm/submit.php @@ -44,13 +44,22 @@ class HTML_QuickForm_submit extends HTML_QuickForm_input * @access public * @return void */ - function HTML_QuickForm_submit($elementName=null, $value=null, $attributes=null) - { - HTML_QuickForm_input::HTML_QuickForm_input($elementName, null, $attributes); + public function __construct($elementName=null, $value=null, $attributes=null) { + parent::__construct($elementName, null, $attributes); $this->setValue($value); $this->setType('submit'); } //end constructor - + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_submit($elementName=null, $value=null, $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $value, $attributes); + } + // }}} // {{{ freeze() diff --git a/lib/pear/HTML/QuickForm/text.php b/lib/pear/HTML/QuickForm/text.php index 9d6d9dea4ff94..042e50875c5e7 100644 --- a/lib/pear/HTML/QuickForm/text.php +++ b/lib/pear/HTML/QuickForm/text.php @@ -46,12 +46,21 @@ class HTML_QuickForm_text extends HTML_QuickForm_input * @access public * @return void */ - function HTML_QuickForm_text($elementName=null, $elementLabel=null, $attributes=null) - { - HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes); + public function __construct($elementName=null, $elementLabel=null, $attributes=null) { + parent::__construct($elementName, $elementLabel, $attributes); $this->_persistantFreeze = true; $this->setType('text'); } //end constructor + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_text($elementName=null, $elementLabel=null, $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $attributes); + } // }}} // {{{ setSize() diff --git a/lib/pear/HTML/QuickForm/textarea.php b/lib/pear/HTML/QuickForm/textarea.php index 7aa0af2ad6c1b..9967f59b52778 100644 --- a/lib/pear/HTML/QuickForm/textarea.php +++ b/lib/pear/HTML/QuickForm/textarea.php @@ -55,13 +55,22 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element * @access public * @return void */ - function HTML_QuickForm_textarea($elementName=null, $elementLabel=null, $attributes=null) - { - HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes); + public function __construct($elementName=null, $elementLabel=null, $attributes=null) { + parent::__construct($elementName, $elementLabel, $attributes); $this->_persistantFreeze = true; $this->_type = 'textarea'; } //end constructor - + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_textarea($elementName=null, $elementLabel=null, $attributes=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $attributes); + } + // }}} // {{{ setName() diff --git a/lib/pear/HTML/QuickForm/xbutton.php b/lib/pear/HTML/QuickForm/xbutton.php index dd01995b21299..b8f972ba1bf9f 100644 --- a/lib/pear/HTML/QuickForm/xbutton.php +++ b/lib/pear/HTML/QuickForm/xbutton.php @@ -44,14 +44,22 @@ class HTML_QuickForm_xbutton extends HTML_QuickForm_element * @param mixed Either a typical HTML attribute string or an associative array * @access public */ - function HTML_QuickForm_xbutton($elementName = null, $elementContent = null, $attributes = null) - { - $this->HTML_QuickForm_element($elementName, null, $attributes); + public function __construct($elementName = null, $elementContent = null, $attributes = null) { + parent::__construct($elementName, null, $attributes); $this->setContent($elementContent); $this->setPersistantFreeze(false); $this->_type = 'xbutton'; } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function HTML_QuickForm_xbutton($elementName = null, $elementContent = null, $attributes = null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementContent, $attributes); + } function toHtml() { diff --git a/lib/pear/PEAR.php b/lib/pear/PEAR.php index 69b2655366f8c..4e7c901db2ed5 100644 --- a/lib/pear/PEAR.php +++ b/lib/pear/PEAR.php @@ -146,7 +146,7 @@ class PEAR * @access public * @return void */ - function PEAR($error_class = null) + function __construct($error_class = null) { $classname = strtolower(get_class($this)); if ($this->_debug) { @@ -173,6 +173,18 @@ function PEAR($error_class = null) } } + /** + * Only here for backwards compatibility. + * E.g. Archive_Tar calls $this->PEAR() in its constructor. + * + * @param string $error_class Which class to use for error objects, + * defaults to PEAR_Error. + */ + public function PEAR($error_class = null) + { + $this->__construct($error_class); + } + /** * Destructor (the emulated type of...). Does nothing right now, * but is included for forward compatibility, so subclass @@ -823,7 +835,7 @@ class PEAR_Error * @access public * */ - function PEAR_Error($message = 'unknown error', $code = null, + function __construct($message = 'unknown error', $code = null, $mode = null, $options = null, $userinfo = null) { if ($mode === null) { @@ -896,6 +908,14 @@ function PEAR_Error($message = 'unknown error', $code = null, } } + /** + * Old syntax of class constructor for backward compatibility. + */ + public function PEAR_Error($message = 'unknown error', $code = null, + $mode = null, $options = null, $userinfo = null) { + self::__construct($message, $code, $mode, $options, $userinfo); + } + /** * Get the error mode from an error object. * diff --git a/lib/pear/README_MOODLE.txt b/lib/pear/README_MOODLE.txt index 5b70ba4562025..4dc1fb4d0c9ec 100644 --- a/lib/pear/README_MOODLE.txt +++ b/lib/pear/README_MOODLE.txt @@ -27,3 +27,10 @@ Most probably we will stop using this library in the future. MDL-20876 - replaced split() with explode() or preg_split() where appropriate MDL-40267 - Moodle core_text strlen functions used for range rule rule to be utf8 safe. MDL-46467 - $mform->hardfreeze causes labels to loose their for HTML attribute +MDL-52081 - made all constructors PHP7 compatible + + +Pear +==== +Changed constructors in classes PEAR and PEAR_ERROR to be __construct(). This has +been already changed upstream in 1.10.0, remove this line after upgrade. \ No newline at end of file diff --git a/lib/upgrade.txt b/lib/upgrade.txt index e93691cbbd1d8..0a33a153cf04e 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -11,6 +11,18 @@ information provided here is intended especially for developers. * Ajax calls going through lib/ajax/* now validate the return values before sending the response. If the validation does not pass an exception is raised. This behaviour is consistent with web services. +* Several changes in Moodle core, standard plugins and third party libraries to + ensure compatibility with PHP7. All plugins are recommended to perform testing + against PHP7 as well. The following changes may affect you: + * Class moodleform, moodleform_mod and some module classes have been changed to use + __construct() for the constructor. Calling parent constructors by the class + name will display debugging message. Incorrect: parent::moodleform(), + correct: parent::__construct() + * All form elements have also changed the constructor syntax. No changes are + needed for using form elements, however if plugin defines new form element it + needs to use correct syntax. For example, incorrect: parent::HTML_QuickForm_input(), + HTML_QuickForm_input::HTML_QuickForm_input(), $this->HTML_QuickForm_input(). + Correct: HTML_QuickForm_input::__construct() or parent::__construct(). === 3.0 === diff --git a/mod/data/export_form.php b/mod/data/export_form.php index 90b4ff77d5902..c0383f29dfa51 100644 --- a/mod/data/export_form.php +++ b/mod/data/export_form.php @@ -13,11 +13,21 @@ class mod_data_export_form extends moodleform { // @param string $url: the url to post to // @param array $datafields: objects in this database - function mod_data_export_form($url, $datafields, $cm, $data) { + public function __construct($url, $datafields, $cm, $data) { $this->_datafields = $datafields; $this->_cm = $cm; $this->_data = $data; - parent::moodleform($url); + parent::__construct($url); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function mod_data_export_form($url, $datafields, $cm, $data) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($url, $datafields, $cm, $data); } function definition() { diff --git a/mod/lesson/mod_form.php b/mod/lesson/mod_form.php index 5d3eb3a67fe89..d701c52214786 100644 --- a/mod/lesson/mod_form.php +++ b/mod/lesson/mod_form.php @@ -33,9 +33,19 @@ class mod_lesson_mod_form extends moodleform_mod { protected $course = null; - public function mod_lesson_mod_form($current, $section, $cm, $course) { + public function __construct($current, $section, $cm, $course) { $this->course = $course; - parent::moodleform_mod($current, $section, $cm, $course); + parent::__construct($current, $section, $cm, $course); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function mod_lesson_mod_form($current, $section, $cm, $course) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($current, $section, $cm, $course); } function definition() { diff --git a/mod/wiki/editors/wikieditor.php b/mod/wiki/editors/wikieditor.php index 11641523fff13..187c34199e7ef 100644 --- a/mod/wiki/editors/wikieditor.php +++ b/mod/wiki/editors/wikieditor.php @@ -33,7 +33,14 @@ class MoodleQuickForm_wikieditor extends MoodleQuickForm_textarea { private $files; - function MoodleQuickForm_wikieditor($elementName = null, $elementLabel = null, $attributes = null) { + /** + * Constructor + * + * @param string $elementName (optional) name of the text field + * @param string $elementLabel (optional) text field label + * @param string $attributes (optional) Either a typical HTML attribute string or an associative array + */ + function __construct($elementName = null, $elementLabel = null, $attributes = null) { if (isset($attributes['wiki_format'])) { $this->wikiformat = $attributes['wiki_format']; unset($attributes['wiki_format']); @@ -43,7 +50,17 @@ function MoodleQuickForm_wikieditor($elementName = null, $elementLabel = null, $ unset($attributes['files']); } - parent::MoodleQuickForm_textarea($elementName, $elementLabel, $attributes); + parent::__construct($elementName, $elementLabel, $attributes); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_wikieditor($elementName = null, $elementLabel = null, $attributes = null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $attributes); } function setWikiFormat($wikiformat) { diff --git a/mod/wiki/editors/wikifiletable.php b/mod/wiki/editors/wikifiletable.php index c1b9ed4fb6ab8..fffaf4b25ee93 100644 --- a/mod/wiki/editors/wikifiletable.php +++ b/mod/wiki/editors/wikifiletable.php @@ -37,13 +37,23 @@ class MoodleQuickForm_wikifiletable extends HTML_QuickForm_element { private $_fileinfo; private $_value = array(); - function MoodleQuickForm_wikifiletable($elementName = null, $elementLabel = null, $attributes = null, $fileinfo = null, $format = null) { + public function __construct($elementName = null, $elementLabel = null, $attributes = null, $fileinfo = null, $format = null) { - parent::HTML_QuickForm_element($elementName, $elementLabel, $attributes); + parent::__construct($elementName, $elementLabel, $attributes); $this->_fileinfo = $fileinfo; $this->_format = $format; } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function MoodleQuickForm_wikifiletable($elementName = null, $elementLabel = null, $attributes = null, $fileinfo = null, $format = null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($elementName, $elementLabel, $attributes, $fileinfo, $format); + } + function onQuickFormEvent($event, $arg, &$caller) { global $OUTPUT;