Skip to content

Commit

Permalink
MDL-51784 various: use __construct() for PHP7 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy authored and David Monllao committed Dec 11, 2015
1 parent 05178f0 commit c4d0b75
Show file tree
Hide file tree
Showing 35 changed files with 235 additions and 60 deletions.
4 changes: 2 additions & 2 deletions backup/cc/cc_lib/gral_lib/cssparser.php
Expand Up @@ -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);
Expand Down Expand Up @@ -258,4 +258,4 @@ function GetCSS() {
}
return $result;
}
}
}
2 changes: 1 addition & 1 deletion filter/tex/latex.php
Expand Up @@ -15,7 +15,7 @@ class latex {
* external 'helper' binaries.
* Other platforms could/should be added
*/
function latex() {
public function __construct() {
global $CFG;

// construct directory structure
Expand Down
2 changes: 1 addition & 1 deletion grade/export/lib.php
Expand Up @@ -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();
}
Expand Down
6 changes: 3 additions & 3 deletions grade/lib.php
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion lib/adminlib.php
Expand Up @@ -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');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/componentlib.class.php
Expand Up @@ -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;
Expand Down
Expand Up @@ -13,7 +13,7 @@ class SpellChecker {
*
* @param $config Configuration name/value array.
*/
function SpellChecker(&$config) {
public function __construct(&$config) {
$this->_config = $config;
}

Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -360,7 +360,7 @@ function peek() {
* @package MCManager.utils
*/
class Moxiecode_JSON {
function Moxiecode_JSON() {
public function __construct() {
}

function decode($input) {
Expand Down
Expand Up @@ -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");
Expand Down Expand Up @@ -265,4 +265,4 @@ function toOSPath($path) {
}
}

?>
?>
1 change: 1 addition & 0 deletions lib/editor/tinymce/plugins/spellchecker/readme_moodle.txt
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion lib/environmentlib.php
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/evalmath/evalmath.class.php
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions lib/evalmath/readme_moodle.txt
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/graphlib.php
Expand Up @@ -1173,7 +1173,7 @@ function find_range($data, $min, $max, $resolution) {
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);
Expand Down
16 changes: 13 additions & 3 deletions lib/lexer.php
Expand Up @@ -44,7 +44,7 @@ class ParallelRegex {
* for insensitive.
* @access public
*/
function ParallelRegex($case) {
public function __construct($case) {
$this->_case = $case;
$this->_patterns = array();
$this->_labels = array();
Expand Down Expand Up @@ -137,7 +137,7 @@ class StateStack {
* @param string $start Starting state name.
* @access public
*/
function StateStack($start) {
public function __construct($start) {
$this->_stack = array($start);
}

Expand Down Expand Up @@ -203,13 +203,23 @@ class Lexer {
* @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
Expand Down
2 changes: 1 addition & 1 deletion lib/mathslib.php
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions lib/searchlib.php
Expand Up @@ -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);

Expand Down Expand Up @@ -82,10 +82,10 @@ function getType(){
*/
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.

Expand Down
18 changes: 17 additions & 1 deletion lib/tablelib.php
Expand Up @@ -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;
}
Expand Down
7 changes: 7 additions & 0 deletions lib/upgrade.txt
Expand Up @@ -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 ===

Expand Down
32 changes: 21 additions & 11 deletions mod/wiki/diff/diff_nwiki.php
Expand Up @@ -32,7 +32,7 @@ function nclosing() {
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;
Expand All @@ -47,7 +47,7 @@ function reverse() {
class _WikiDiffOp_Delete extends _WikiDiffOp {
var $type = 'delete';

function _WikiDiffOp_Delete ($lines) {
public function __construct ($lines) {
$this->orig = $lines;
$this->closing = false;
}
Expand All @@ -60,7 +60,7 @@ function reverse() {
class _WikiDiffOp_Add extends _WikiDiffOp {
var $type = 'add';

function _WikiDiffOp_Add ($lines) {
public function __construct ($lines) {
$this->closing = $lines;
$this->orig = false;
}
Expand All @@ -73,7 +73,7 @@ function reverse() {
class _WikiDiffOp_Change extends _WikiDiffOp {
var $type = 'change';

function _WikiDiffOp_Change ($orig, $closing) {
public function __construct ($orig, $closing) {
$this->orig = $orig;
$this->closing = $closing;
}
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -650,13 +660,13 @@ class MappedWikiDiff
* @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++) {
Expand Down Expand Up @@ -837,7 +847,7 @@ function _changed($orig, $closing) {
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 = '';
Expand Down Expand Up @@ -888,12 +898,12 @@ function getLines() {

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);
}

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit c4d0b75

Please sign in to comment.