MDL-51784 various: use __construct() for PHP7 compatibility
authorMarina Glancy <marina@moodle.com>
Thu, 26 Nov 2015 02:49:58 +0000 (10:49 +0800)
committerDavid Monllao <davidm@moodle.com>
Fri, 11 Dec 2015 04:48:24 +0000 (12:48 +0800)
35 files changed:
backup/cc/cc_lib/gral_lib/cssparser.php
filter/tex/latex.php
grade/export/lib.php
grade/lib.php
lib/adminlib.php
lib/componentlib.class.php
lib/editor/tinymce/plugins/spellchecker/classes/SpellChecker.php
lib/editor/tinymce/plugins/spellchecker/classes/utils/JSON.php
lib/editor/tinymce/plugins/spellchecker/classes/utils/Logger.php
lib/editor/tinymce/plugins/spellchecker/readme_moodle.txt
lib/environmentlib.php
lib/evalmath/evalmath.class.php
lib/evalmath/readme_moodle.txt
lib/graphlib.php
lib/lexer.php
lib/mathslib.php
lib/searchlib.php
lib/tablelib.php
lib/upgrade.txt
mod/wiki/diff/diff_nwiki.php
mod/wiki/diff/difflib.php
question/category_class.php
user/filters/cohort.php
user/filters/courserole.php
user/filters/date.php
user/filters/globalrole.php
user/filters/lib.php
user/filters/profilefield.php
user/filters/select.php
user/filters/simpleselect.php
user/filters/text.php
user/filters/yesno.php
user/profile/field/checkbox/field.class.php
user/profile/field/menu/field.class.php
user/profile/lib.php

index 3d5653f..2092268 100644 (file)
@@ -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
+}
index a1966da..c2dc1e2 100644 (file)
@@ -15,7 +15,7 @@
          * external 'helper' binaries.
          * Other platforms could/should be added
          */
-        function latex() {
+        public function __construct() {
             global $CFG;
 
             // construct directory structure
index e817943..b008666 100644 (file)
@@ -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();
     }
index 3a04829..095d751 100644 (file)
@@ -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;
 
index fc177f4..5e98cdd 100644 (file)
@@ -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');
     }
index cac0f6e..d01e7c8 100644 (file)
@@ -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;
index b31da4b..0c2d84b 100644 (file)
@@ -13,7 +13,7 @@ class SpellChecker {
         *\r
         * @param $config Configuration name/value array.\r
         */\r
-       function SpellChecker(&$config) {\r
+       public function __construct(&$config) {\r
                $this->_config = $config;\r
        }\r
 \r
index 1f2b92c..28f0d23 100644 (file)
@@ -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) {
index bc501ea..c8bde24 100644 (file)
@@ -31,7 +31,7 @@ class Moxiecode_Logger {
        /**\r
         * Constructs a new logger instance.\r
         */\r
-       function Moxiecode_Logger() {\r
+       public function __construct() {\r
                $this->_path = "";\r
                $this->_filename = "{level}.log";\r
                $this->setMaxSize("100k");\r
@@ -265,4 +265,4 @@ class Moxiecode_Logger {
        }\r
 }\r
 \r
-?>
\ No newline at end of file
+?>\r
index deb2af9..d72f19f 100644 (file)
@@ -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()
index cd25167..efbcd1f 100644 (file)
@@ -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;
index 8f68d2a..bf27d61 100644 (file)
@@ -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);
index 0105d56..bb01ba7 100644 (file)
@@ -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
index 5b11a82..555f1a6 100644 (file)
@@ -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);
index ca53509..341f54d 100644 (file)
@@ -44,7 +44,7 @@
          *                    for insensitive.
          *    @access public
          */
-        function ParallelRegex($case) {
+        public function __construct($case) {
             $this->_case = $case;
             $this->_patterns = array();
             $this->_labels = array();
          *    @param string $start        Starting state name.
          *    @access public
          */
-        function StateStack($start) {
+        public function __construct($start) {
             $this->_stack = array($start);
         }
         
          *    @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
index 1640f14..067f660 100644 (file)
@@ -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) {
index 8fc15d6..bb17c45 100644 (file)
@@ -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.
 
index 53b64a6..e921805 100644 (file)
@@ -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;
     }
index 0a33a15..b7caa45 100644 (file)
@@ -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 ===
 
index 3afb0c8..208a712 100644 (file)
@@ -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', '&#160;');                      // 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;
     }
index da5c154..bc6a598 100644 (file)
@@ -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);
         
index b5d6332..c822a3f 100644 (file)
@@ -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('&nbsp;', $this->tabsize);
index a118f16..be64fe5 100644 (file)
@@ -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);
     }
 
     /**
index 0297094..b4c5ec9 100644 (file)
@@ -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);
     }
 
     /**
index ab50f98..8587ab9 100644 (file)
@@ -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
index 76a49a3..e205bba 100644 (file)
@@ -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);
     }
 
     /**
index 2d6c04a..83852a2 100644 (file)
@@ -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
index 10278b9..85ef374 100644 (file)
@@ -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);
     }
 
     /**
index cca46a9..75fdfda 100644 (file)
@@ -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
index 19573d4..639588b 100644 (file)
@@ -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
index c2da311..fabea89 100644 (file)
@@ -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
index e81c0ea..5dadd80 100644 (file)
@@ -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);
     }
 
     /**
index 68b75a9..5304857 100644 (file)
@@ -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
index 7b6d416..bfb41f8 100644 (file)
@@ -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
index 161834d..41470bb 100644 (file)
@@ -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