diff --git a/backup/cc/cc_lib/gral_lib/cssparser.php b/backup/cc/cc_lib/gral_lib/cssparser.php index 3d5653f33e5..209226879d0 100644 --- a/backup/cc/cc_lib/gral_lib/cssparser.php +++ b/backup/cc/cc_lib/gral_lib/cssparser.php @@ -18,7 +18,7 @@ class cssparser { private $css; private $html; - function cssparser($html = true) { + public function __construct($html = true) { // Register "destructor" core_shutdown_manager::register_function(array(&$this, "finalize")); $this->html = ($html != false); @@ -258,4 +258,4 @@ class cssparser { } return $result; } -} \ No newline at end of file +} diff --git a/filter/tex/latex.php b/filter/tex/latex.php index a1966da6212..c2dc1e2b867 100644 --- a/filter/tex/latex.php +++ b/filter/tex/latex.php @@ -15,7 +15,7 @@ * external 'helper' binaries. * Other platforms could/should be added */ - function latex() { + public function __construct() { global $CFG; // construct directory structure diff --git a/grade/export/lib.php b/grade/export/lib.php index e8179438434..b00866601c5 100644 --- a/grade/export/lib.php +++ b/grade/export/lib.php @@ -625,7 +625,7 @@ class grade_export_update_buffer { /** * Constructor - creates the buffer and initialises the time stamp */ - public function grade_export_update_buffer() { + public function __construct() { $this->update_list = array(); $this->export_time = time(); } diff --git a/grade/lib.php b/grade/lib.php index 3a048295bd4..095d7512b36 100644 --- a/grade/lib.php +++ b/grade/lib.php @@ -1085,7 +1085,7 @@ class grade_plugin_return { * * @param array $params - associative array with return parameters, if null parameter are taken from _GET or _POST */ - public function grade_plugin_return($params = null) { + public function __construct($params = null) { if (empty($params)) { $this->type = optional_param('gpr_type', null, PARAM_SAFEDIR); $this->plugin = optional_param('gpr_plugin', null, PARAM_PLUGIN); @@ -2033,7 +2033,7 @@ class grade_seq extends grade_structure { * @param bool $category_grade_last category grade item is the last child * @param bool $nooutcomes Whether or not outcomes should be included */ - public function grade_seq($courseid, $category_grade_last=false, $nooutcomes=false) { + public function __construct($courseid, $category_grade_last=false, $nooutcomes=false) { global $USER, $CFG; $this->courseid = $courseid; @@ -2185,7 +2185,7 @@ class grade_tree extends grade_structure { * @param array $collapsed array of collapsed categories * @param bool $nooutcomes Whether or not outcomes should be included */ - public function grade_tree($courseid, $fillers=true, $category_grade_last=false, + public function __construct($courseid, $fillers=true, $category_grade_last=false, $collapsed=null, $nooutcomes=false) { global $USER, $CFG, $COURSE, $DB; diff --git a/lib/adminlib.php b/lib/adminlib.php index fc177f46b44..5e98cdd5a66 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -4936,7 +4936,7 @@ class admin_setting_special_gradelimiting extends admin_setting_configcheckbox { /** * Calls parent::__construct with specific arguments */ - function admin_setting_special_gradelimiting() { + public function __construct() { parent::__construct('unlimitedgrades', get_string('unlimitedgrades', 'grades'), get_string('unlimitedgrades_help', 'grades'), '0', '1', '0'); } diff --git a/lib/componentlib.class.php b/lib/componentlib.class.php index cac0f6e722f..d01e7c82d88 100644 --- a/lib/componentlib.class.php +++ b/lib/componentlib.class.php @@ -190,7 +190,7 @@ class component_installer { * be expanded (default='' = moodledataitself) * @return object */ - function component_installer ($sourcebase, $zippath, $zipfilename, $md5filename='', $destpath='') { + public function __construct($sourcebase, $zippath, $zipfilename, $md5filename='', $destpath='') { $this->sourcebase = $sourcebase; $this->zippath = $zippath; diff --git a/lib/editor/tinymce/plugins/spellchecker/classes/SpellChecker.php b/lib/editor/tinymce/plugins/spellchecker/classes/SpellChecker.php index b31da4b41c0..0c2d84ba0d8 100644 --- a/lib/editor/tinymce/plugins/spellchecker/classes/SpellChecker.php +++ b/lib/editor/tinymce/plugins/spellchecker/classes/SpellChecker.php @@ -13,7 +13,7 @@ class SpellChecker { * * @param $config Configuration name/value array. */ - function SpellChecker(&$config) { + public function __construct(&$config) { $this->_config = $config; } diff --git a/lib/editor/tinymce/plugins/spellchecker/classes/utils/JSON.php b/lib/editor/tinymce/plugins/spellchecker/classes/utils/JSON.php index 1f2b92caa2d..28f0d2306b9 100644 --- a/lib/editor/tinymce/plugins/spellchecker/classes/utils/JSON.php +++ b/lib/editor/tinymce/plugins/spellchecker/classes/utils/JSON.php @@ -29,7 +29,7 @@ class Moxiecode_JSONReader { var $_location, $_lastLocations; var $_needProp; - function Moxiecode_JSONReader($data) { + public function __construct($data) { $this->_data = $data; $this->_len = strlen($data); $this->_pos = -1; @@ -360,7 +360,7 @@ class Moxiecode_JSONReader { * @package MCManager.utils */ class Moxiecode_JSON { - function Moxiecode_JSON() { + public function __construct() { } function decode($input) { diff --git a/lib/editor/tinymce/plugins/spellchecker/classes/utils/Logger.php b/lib/editor/tinymce/plugins/spellchecker/classes/utils/Logger.php index bc501ea75e0..c8bde2465d6 100644 --- a/lib/editor/tinymce/plugins/spellchecker/classes/utils/Logger.php +++ b/lib/editor/tinymce/plugins/spellchecker/classes/utils/Logger.php @@ -31,7 +31,7 @@ class Moxiecode_Logger { /** * Constructs a new logger instance. */ - function Moxiecode_Logger() { + public function __construct() { $this->_path = ""; $this->_filename = "{level}.log"; $this->setMaxSize("100k"); @@ -265,4 +265,4 @@ class Moxiecode_Logger { } } -?> \ No newline at end of file +?> diff --git a/lib/editor/tinymce/plugins/spellchecker/readme_moodle.txt b/lib/editor/tinymce/plugins/spellchecker/readme_moodle.txt index deb2af9fc99..d72f19f89c5 100644 --- a/lib/editor/tinymce/plugins/spellchecker/readme_moodle.txt +++ b/lib/editor/tinymce/plugins/spellchecker/readme_moodle.txt @@ -8,3 +8,4 @@ List of changes: * Moved static files to /tinymce/ subfolder. * MDL-25736 - French spellchecker fixes. * Fix htmlentities conversion in GoogleSpell.php +* Constructors in Moxiecode_JSONReader, Moxiecode_JSON, Moxiecode_Logger, SpellChecker are renamed to __construct() diff --git a/lib/environmentlib.php b/lib/environmentlib.php index cd251675d1b..efbcd1f6b11 100644 --- a/lib/environmentlib.php +++ b/lib/environmentlib.php @@ -1260,7 +1260,7 @@ class environment_results { * * @param string $part */ - function environment_results($part) { + public function __construct($part) { $this->part=$part; $this->status=false; $this->error_code=NO_ERROR; diff --git a/lib/evalmath/evalmath.class.php b/lib/evalmath/evalmath.class.php index 8f68d2a9de4..bf27d615d85 100644 --- a/lib/evalmath/evalmath.class.php +++ b/lib/evalmath/evalmath.class.php @@ -117,7 +117,7 @@ class EvalMath { var $allowimplicitmultiplication; - function EvalMath($allowconstants = false, $allowimplicitmultiplication = false) { + public function __construct($allowconstants = false, $allowimplicitmultiplication = false) { if ($allowconstants){ $this->v['pi'] = pi(); $this->v['e'] = exp(1); diff --git a/lib/evalmath/readme_moodle.txt b/lib/evalmath/readme_moodle.txt index 0105d564b3e..bb01ba72cdb 100644 --- a/lib/evalmath/readme_moodle.txt +++ b/lib/evalmath/readme_moodle.txt @@ -11,6 +11,7 @@ Our changes: * made a function to test a string to see if it is a valid func or var name. * localized strings * added round, ceil and floor functions. +* EvalMath::EvalMath() changed to EvalMath::__construct() To see all changes diff against version 1.1, available from: http://www.phpclasses.org/browse/package/2695.html diff --git a/lib/graphlib.php b/lib/graphlib.php index 5b11a82fa66..555f1a67ce7 100644 --- a/lib/graphlib.php +++ b/lib/graphlib.php @@ -1173,7 +1173,7 @@ class graph { return array('min' => $min, 'max' => $max); } - function graph() { + public function __construct() { if (func_num_args() == 2) { $this->parameter['width'] = func_get_arg(0); $this->parameter['height'] = func_get_arg(1); diff --git a/lib/lexer.php b/lib/lexer.php index ca53509fcef..341f54dbf5b 100644 --- a/lib/lexer.php +++ b/lib/lexer.php @@ -44,7 +44,7 @@ * for insensitive. * @access public */ - function ParallelRegex($case) { + public function __construct($case) { $this->_case = $case; $this->_patterns = array(); $this->_labels = array(); @@ -137,7 +137,7 @@ * @param string $start Starting state name. * @access public */ - function StateStack($start) { + public function __construct($start) { $this->_stack = array($start); } @@ -203,13 +203,23 @@ * @param bool $case True for case sensitive. * @access public */ - function Lexer(&$parser, $start = "accept", $case = false) { + public function __construct(&$parser, $start = "accept", $case = false) { $this->_case = $case; $this->_regexes = array(); $this->_parser = &$parser; $this->_mode = new StateStack($start); $this->_mode_handlers = array(); } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function Lexer(&$parser, $start = "accept", $case = false) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($parser, $start, $case); + } /** * Adds a token search pattern for a particular diff --git a/lib/mathslib.php b/lib/mathslib.php index 1640f14385b..067f660cca7 100644 --- a/lib/mathslib.php +++ b/lib/mathslib.php @@ -48,7 +48,7 @@ class calc_formula { * @param string $formula with leading = * @param array $params associative array of parameters used in formula. All parameter names must be lowercase! */ - function calc_formula($formula, $params=false) { + public function __construct($formula, $params=false) { $this->_em = new EvalMath(); $this->_em->suppress_errors = true; // no PHP errors! if (strpos($formula, '=') !== 0) { diff --git a/lib/searchlib.php b/lib/searchlib.php index 8fc15d68fca..bb17c45a3e8 100644 --- a/lib/searchlib.php +++ b/lib/searchlib.php @@ -50,7 +50,7 @@ class search_token { private $value; private $type; - function search_token($type,$value){ + public function __construct($type,$value){ $this->type = $type; $this->value = $this->sanitize($value); @@ -82,10 +82,10 @@ class search_token { */ class search_lexer extends Lexer{ - function search_lexer(&$parser){ + public function __construct(&$parser){ // Call parent constructor. - $this->Lexer($parser); + parent::__construct($parser); //Set up the state machine and pattern matches for transitions. diff --git a/lib/tablelib.php b/lib/tablelib.php index 53b64a6ef54..e921805f064 100644 --- a/lib/tablelib.php +++ b/lib/tablelib.php @@ -1657,10 +1657,26 @@ class table_default_export_format_parent { * started yet. */ var $documentstarted = false; - function table_default_export_format_parent(&$table) { + + /** + * Constructor + * + * @param flexible_table $table + */ + public function __construct(&$table) { $this->table =& $table; } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function table_default_export_format_parent(&$table) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($table); + } + function set_table(&$table) { $this->table =& $table; } diff --git a/lib/upgrade.txt b/lib/upgrade.txt index 0a33a153cf0..b7caa452dd4 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -23,6 +23,13 @@ information provided here is intended especially for developers. 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(). + * profile_field_base::profile_field_base() is deprecated, use parent::__construct() + in custom profile fields constructors. Similar deprecations in exsiting + profile_field_* classes. + * user_filter_type::user_filter_type() is deprecated, use parent::__construct() in + custom user filters. Similar deprecations in existing user_filter_* classes. + * table_default_export_format_parent::table_default_export_format_parent() is + deprecated, use parent::__construct() in extending classes. === 3.0 === diff --git a/mod/wiki/diff/diff_nwiki.php b/mod/wiki/diff/diff_nwiki.php index 3afb0c88736..208a71205c1 100644 --- a/mod/wiki/diff/diff_nwiki.php +++ b/mod/wiki/diff/diff_nwiki.php @@ -32,7 +32,7 @@ class _WikiDiffOp { class _WikiDiffOp_Copy extends _WikiDiffOp { var $type = 'copy'; - function _WikiDiffOp_Copy ($orig, $closing = false) { + public function __construct ($orig, $closing = false) { if (!is_array($closing)) $closing = $orig; $this->orig = $orig; @@ -47,7 +47,7 @@ class _WikiDiffOp_Copy extends _WikiDiffOp { class _WikiDiffOp_Delete extends _WikiDiffOp { var $type = 'delete'; - function _WikiDiffOp_Delete ($lines) { + public function __construct ($lines) { $this->orig = $lines; $this->closing = false; } @@ -60,7 +60,7 @@ class _WikiDiffOp_Delete extends _WikiDiffOp { class _WikiDiffOp_Add extends _WikiDiffOp { var $type = 'add'; - function _WikiDiffOp_Add ($lines) { + public function __construct ($lines) { $this->closing = $lines; $this->orig = false; } @@ -73,7 +73,7 @@ class _WikiDiffOp_Add extends _WikiDiffOp { class _WikiDiffOp_Change extends _WikiDiffOp { var $type = 'change'; - function _WikiDiffOp_Change ($orig, $closing) { + public function __construct ($orig, $closing) { $this->orig = $orig; $this->closing = $closing; } @@ -500,12 +500,22 @@ class WikiDiff * (Typically these are lines from a file.) * @param $to_lines array An array of strings. */ - function WikiDiff($from_lines, $to_lines) { + public function __construct($from_lines, $to_lines) { $eng = new _WikiDiffEngine; $this->edits = $eng->diff($from_lines, $to_lines); //$this->_check($from_lines, $to_lines); } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function WikiDiff($from_lines, $to_lines) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($from_lines, $to_lines); + } + /** * Compute reversed WikiDiff. * @@ -650,13 +660,13 @@ extends WikiDiff * @param $mapped_to_lines array This array should * have the same number of elements as $to_lines. */ - function MappedWikiDiff($from_lines, $to_lines, + public function __construct($from_lines, $to_lines, $mapped_from_lines, $mapped_to_lines) { assert(sizeof($from_lines) == sizeof($mapped_from_lines)); assert(sizeof($to_lines) == sizeof($mapped_to_lines)); - $this->WikiDiff($mapped_from_lines, $mapped_to_lines); + parent::__construct($mapped_from_lines, $mapped_to_lines); $xi = $yi = 0; for ($i = 0; $i < sizeof($this->edits); $i++) { @@ -837,7 +847,7 @@ class WikiDiffFormatter define('NBSP', ' '); // iso-8859-x non-breaking space. class _WikiHWLDF_WordAccumulator { - function _WikiHWLDF_WordAccumulator () { + public function __construct () { $this->_lines = array(); $this->_line = ''; $this->_group = ''; @@ -888,12 +898,12 @@ class _WikiHWLDF_WordAccumulator { class WordLevelWikiDiff extends MappedWikiDiff { - function WordLevelWikiDiff ($orig_lines, $closing_lines) { + function __construct ($orig_lines, $closing_lines) { list ($orig_words, $orig_stripped) = $this->_split($orig_lines); list ($closing_words, $closing_stripped) = $this->_split($closing_lines); - $this->MappedWikiDiff($orig_words, $closing_words, + parent::__construct($orig_words, $closing_words, $orig_stripped, $closing_stripped); } @@ -940,7 +950,7 @@ class TableWikiDiffFormatter extends WikiDiffFormatter { var $htmltable = array(); - function TableWikiDiffFormatter() { + public function __construct() { $this->leading_context_lines = 2; $this->trailing_context_lines = 2; } diff --git a/mod/wiki/diff/difflib.php b/mod/wiki/diff/difflib.php index da5c1540f6a..bc6a59861fe 100644 --- a/mod/wiki/diff/difflib.php +++ b/mod/wiki/diff/difflib.php @@ -279,7 +279,7 @@ class ouwiki_line { * @param string $data Text data that makes up this 'line'. (May include line breaks etc.) * @param int $linepos Position number for first character in text */ - function ouwiki_line($data,$linepos) { + public function __construct($data,$linepos) { // 1. Turn things we don't want into spaces (so that positioning stays same) // Whitespace replaced with space @@ -368,7 +368,7 @@ class ouwiki_word { /** Start position in original xhtml */ var $start; - function ouwiki_word($word,$start) { + public function __construct($word,$start) { $this->word=$word; $this->start=$start; } @@ -455,7 +455,7 @@ class ouwiki_changes { * to indices in file2. All indices 1-based. * @param int $count2 Number of lines in file2 */ - function ouwiki_changes($diff,$count2) { + public function __construct($diff,$count2) { // Find deleted lines $this->deletes=self::internal_find_deletes($diff,$count2); diff --git a/question/category_class.php b/question/category_class.php index b5d63322a04..c822a3fddb6 100644 --- a/question/category_class.php +++ b/question/category_class.php @@ -162,7 +162,7 @@ class question_category_object { * * Gets necessary strings and sets relevant path information */ - public function question_category_object($page, $pageurl, $contexts, $currentcat, $defaultcategory, $todelete, $addcontexts) { + public function __construct($page, $pageurl, $contexts, $currentcat, $defaultcategory, $todelete, $addcontexts) { global $CFG, $COURSE, $OUTPUT; $this->tab = str_repeat(' ', $this->tabsize); diff --git a/user/filters/cohort.php b/user/filters/cohort.php index a118f1643d3..be64fe5964a 100644 --- a/user/filters/cohort.php +++ b/user/filters/cohort.php @@ -37,8 +37,18 @@ class user_filter_cohort extends user_filter_type { * Constructor * @param boolean $advanced advanced form element flag */ + public function __construct($advanced) { + parent::__construct('cohort', get_string('idnumber', 'core_cohort'), $advanced); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ public function user_filter_cohort($advanced) { - parent::user_filter_type('cohort', get_string('idnumber', 'core_cohort'), $advanced); + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($advanced); } /** diff --git a/user/filters/courserole.php b/user/filters/courserole.php index 0297094f7e1..b4c5ec984f8 100644 --- a/user/filters/courserole.php +++ b/user/filters/courserole.php @@ -37,8 +37,18 @@ class user_filter_courserole extends user_filter_type { * @param string $label the label of the filter instance * @param boolean $advanced advanced form element flag */ + public function __construct($name, $label, $advanced) { + parent::__construct($name, $label, $advanced); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ public function user_filter_courserole($name, $label, $advanced) { - parent::user_filter_type($name, $label, $advanced); + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($name, $label, $advanced); } /** diff --git a/user/filters/date.php b/user/filters/date.php index ab50f98d8f8..8587ab902b9 100644 --- a/user/filters/date.php +++ b/user/filters/date.php @@ -44,11 +44,21 @@ class user_filter_date extends user_filter_type { * @param boolean $advanced advanced form element flag * @param string $field user table filed name */ - public function user_filter_date($name, $label, $advanced, $field) { - parent::user_filter_type($name, $label, $advanced); + public function __construct($name, $label, $advanced, $field) { + parent::__construct($name, $label, $advanced); $this->_field = $field; } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function user_filter_date($name, $label, $advanced, $field) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($name, $label, $advanced, $field); + } + /** * Adds controls specific to this filter in the form. * @param object $mform a MoodleForm object to setup diff --git a/user/filters/globalrole.php b/user/filters/globalrole.php index 76a49a3f0d3..e205bbaa9fe 100644 --- a/user/filters/globalrole.php +++ b/user/filters/globalrole.php @@ -38,8 +38,18 @@ class user_filter_globalrole extends user_filter_type { * @param string $label the label of the filter instance * @param boolean $advanced advanced form element flag */ + public function __construct($name, $label, $advanced) { + parent::__construct($name, $label, $advanced); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ public function user_filter_globalrole($name, $label, $advanced) { - parent::user_filter_type($name, $label, $advanced); + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($name, $label, $advanced); } /** diff --git a/user/filters/lib.php b/user/filters/lib.php index 2d6c04a0cff..83852a28af8 100644 --- a/user/filters/lib.php +++ b/user/filters/lib.php @@ -55,7 +55,7 @@ class user_filtering { * @param string $baseurl base url used for submission/return, null if the same of current page * @param array $extraparams extra page parameters */ - public function user_filtering($fieldnames = null, $baseurl = null, $extraparams = null) { + public function __construct($fieldnames = null, $baseurl = null, $extraparams = null) { global $SESSION; if (!isset($SESSION->user_filtering)) { @@ -275,12 +275,22 @@ class user_filter_type { * @param string $label the label of the filter instance * @param boolean $advanced advanced form element flag */ - public function user_filter_type($name, $label, $advanced) { + public function __construct($name, $label, $advanced) { $this->_name = $name; $this->_label = $label; $this->_advanced = $advanced; } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function user_filter_type($name, $label, $advanced) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($name, $label, $advanced); + } + /** * Returns the condition to be used with SQL where * @param array $data filter settings diff --git a/user/filters/profilefield.php b/user/filters/profilefield.php index 10278b9575f..85ef374a172 100644 --- a/user/filters/profilefield.php +++ b/user/filters/profilefield.php @@ -39,8 +39,18 @@ class user_filter_profilefield extends user_filter_type { * @param string $label the label of the filter instance * @param boolean $advanced advanced form element flag */ + public function __construct($name, $label, $advanced) { + parent::__construct($name, $label, $advanced); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ public function user_filter_profilefield($name, $label, $advanced) { - parent::user_filter_type($name, $label, $advanced); + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($name, $label, $advanced); } /** diff --git a/user/filters/select.php b/user/filters/select.php index cca46a928fd..75fdfda94b3 100644 --- a/user/filters/select.php +++ b/user/filters/select.php @@ -52,13 +52,23 @@ class user_filter_select extends user_filter_type { * @param array $options select options * @param mixed $default option */ - public function user_filter_select($name, $label, $advanced, $field, $options, $default=null) { - parent::user_filter_type($name, $label, $advanced); + public function __construct($name, $label, $advanced, $field, $options, $default=null) { + parent::__construct($name, $label, $advanced); $this->_field = $field; $this->_options = $options; $this->_default = $default; } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function user_filter_select($name, $label, $advanced, $field, $options, $default=null) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($name, $label, $advanced, $field, $options, $default=null); + } + /** * Returns an array of comparison operators * @return array of comparison operators diff --git a/user/filters/simpleselect.php b/user/filters/simpleselect.php index 19573d4069e..639588b1526 100644 --- a/user/filters/simpleselect.php +++ b/user/filters/simpleselect.php @@ -50,12 +50,22 @@ class user_filter_simpleselect extends user_filter_type { * @param string $field user table filed name * @param array $options select options */ - public function user_filter_simpleselect($name, $label, $advanced, $field, $options) { - parent::user_filter_type($name, $label, $advanced); + public function __construct($name, $label, $advanced, $field, $options) { + parent::__construct($name, $label, $advanced); $this->_field = $field; $this->_options = $options; } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function user_filter_simpleselect($name, $label, $advanced, $field, $options) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($name, $label, $advanced, $field, $options); + } + /** * Adds controls specific to this filter in the form. * @param moodleform $mform a MoodleForm object to setup diff --git a/user/filters/text.php b/user/filters/text.php index c2da3114370..fabea89c5a1 100644 --- a/user/filters/text.php +++ b/user/filters/text.php @@ -41,11 +41,21 @@ class user_filter_text extends user_filter_type { * @param boolean $advanced advanced form element flag * @param string $field user table filed name */ - public function user_filter_text($name, $label, $advanced, $field) { - parent::user_filter_type($name, $label, $advanced); + public function __construct($name, $label, $advanced, $field) { + parent::__construct($name, $label, $advanced); $this->_field = $field; } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function user_filter_text($name, $label, $advanced, $field) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($name, $label, $advanced, $field); + } + /** * Returns an array of comparison operators * @return array of comparison operators diff --git a/user/filters/yesno.php b/user/filters/yesno.php index e81c0ea21f4..5dadd805008 100644 --- a/user/filters/yesno.php +++ b/user/filters/yesno.php @@ -37,8 +37,18 @@ class user_filter_yesno extends user_filter_simpleselect { * @param boolean $advanced advanced form element flag * @param string $field user table filed name */ + public function __construct($name, $label, $advanced, $field) { + parent::__construct($name, $label, $advanced, $field, array(0 => get_string('no'), 1 => get_string('yes'))); + } + + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ public function user_filter_yesno($name, $label, $advanced, $field) { - parent::user_filter_simpleselect($name, $label, $advanced, $field, array(0 => get_string('no'), 1 => get_string('yes'))); + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($name, $label, $advanced, $field); } /** diff --git a/user/profile/field/checkbox/field.class.php b/user/profile/field/checkbox/field.class.php index 68b75a94a58..530485783bf 100644 --- a/user/profile/field/checkbox/field.class.php +++ b/user/profile/field/checkbox/field.class.php @@ -38,10 +38,10 @@ class profile_field_checkbox extends profile_field_base { * @param int $fieldid * @param int $userid */ - public function profile_field_checkbox($fieldid=0, $userid=0) { + public function __construct($fieldid=0, $userid=0) { global $DB; // First call parent constructor. - $this->profile_field_base($fieldid, $userid); + parent::__construct($fieldid, $userid); if (!empty($this->field)) { $datafield = $DB->get_field('user_info_data', 'data', array('userid' => $this->userid, 'fieldid' => $this->fieldid)); @@ -53,6 +53,16 @@ class profile_field_checkbox extends profile_field_base { } } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function profile_field_checkbox($fieldid=0, $userid=0) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($fieldid, $userid); + } + /** * Add elements for editing the profile field value. * @param moodleform $mform diff --git a/user/profile/field/menu/field.class.php b/user/profile/field/menu/field.class.php index 7b6d416ebac..bfb41f8279c 100644 --- a/user/profile/field/menu/field.class.php +++ b/user/profile/field/menu/field.class.php @@ -44,9 +44,9 @@ class profile_field_menu extends profile_field_base { * @param int $fieldid * @param int $userid */ - public function profile_field_menu($fieldid = 0, $userid = 0) { + public function __construct($fieldid = 0, $userid = 0) { // First call parent constructor. - $this->profile_field_base($fieldid, $userid); + parent::__construct($fieldid, $userid); // Param 1 for menu type is the options. if (isset($this->field->param1)) { @@ -72,6 +72,16 @@ class profile_field_menu extends profile_field_base { } } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function profile_field_menu($fieldid=0, $userid=0) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($fieldid, $userid); + } + /** * Create the code snippet for this field instance * Overwrites the base class method diff --git a/user/profile/lib.php b/user/profile/lib.php index 161834d6230..41470bbbd4e 100644 --- a/user/profile/lib.php +++ b/user/profile/lib.php @@ -61,7 +61,7 @@ class profile_field_base { * @param int $fieldid id of the profile from the user_info_field table * @param int $userid id of the user for whom we are displaying data */ - public function profile_field_base($fieldid=0, $userid=0) { + public function __construct($fieldid=0, $userid=0) { global $USER; $this->set_fieldid($fieldid); @@ -69,6 +69,16 @@ class profile_field_base { $this->load_data(); } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function profile_field_base($fieldid=0, $userid=0) { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct($fieldid, $userid); + } + /** * Abstract method: Adds the profile field to the moodle form class * @abstract The following methods must be overwritten by child classes