diff --git a/backup/controller/backup_controller.class.php b/backup/controller/backup_controller.class.php index cd124e588b6..e270f9e1f86 100644 --- a/backup/controller/backup_controller.class.php +++ b/backup/controller/backup_controller.class.php @@ -110,7 +110,7 @@ class backup_controller extends base_controller { // By default there is no progress reporter. Interfaces that wish to // display progress must set it. - $this->progress = new \core\progress\null(); + $this->progress = new \core\progress\none(); // Instantiate the output_controller singleton and active it if interactive and inmediate $oc = output_controller::get_instance(); diff --git a/backup/controller/restore_controller.class.php b/backup/controller/restore_controller.class.php index 39926492b45..8c72c588359 100644 --- a/backup/controller/restore_controller.class.php +++ b/backup/controller/restore_controller.class.php @@ -114,7 +114,7 @@ class restore_controller extends base_controller { if ($progress) { $this->progress = $progress; } else { - $this->progress = new \core\progress\null(); + $this->progress = new \core\progress\none(); } $this->progress->start_progress('Constructing restore_controller'); diff --git a/backup/util/dbops/restore_dbops.class.php b/backup/util/dbops/restore_dbops.class.php index bd00c3221bf..880e75dfbfc 100644 --- a/backup/util/dbops/restore_dbops.class.php +++ b/backup/util/dbops/restore_dbops.class.php @@ -123,7 +123,7 @@ abstract class restore_dbops { // Set up progress tracking (indeterminate). if (!$progress) { - $progress = new \core\progress\null(); + $progress = new \core\progress\none(); } $progress->start_progress('Loading inforef.xml file'); @@ -430,7 +430,7 @@ abstract class restore_dbops { // Set up progress tracking (indeterminate). if (!$progress) { - $progress = new \core\progress\null(); + $progress = new \core\progress\none(); } $progress->start_progress('Loading users into temporary table'); diff --git a/backup/util/ui/restore_ui.class.php b/backup/util/ui/restore_ui.class.php index 0bb83236d98..d0e2237dfee 100644 --- a/backup/util/ui/restore_ui.class.php +++ b/backup/util/ui/restore_ui.class.php @@ -185,11 +185,11 @@ class restore_ui extends base_ui { * there are long-running tasks even though there is no restore controller * in use. * - * @return \core\progress\null + * @return \core\progress\none */ public function get_progress_reporter() { if (!$this->progressreporter) { - $this->progressreporter = new \core\progress\null(); + $this->progressreporter = new \core\progress\none(); } return $this->progressreporter; } diff --git a/backup/util/ui/restore_ui_stage.class.php b/backup/util/ui/restore_ui_stage.class.php index 5bb40a13780..2917c727f7d 100644 --- a/backup/util/ui/restore_ui_stage.class.php +++ b/backup/util/ui/restore_ui_stage.class.php @@ -144,11 +144,11 @@ abstract class restore_ui_independent_stage { * in use. There is a similar function in restore_ui. but that class is not * used on some stages. * - * @return \core\progress\null + * @return \core\progress\none */ public function get_progress_reporter() { if (!$this->progressreporter) { - $this->progressreporter = new \core\progress\null(); + $this->progressreporter = new \core\progress\none(); } return $this->progressreporter; } diff --git a/lib/classes/component.php b/lib/classes/component.php index 519bbab2198..95f90449171 100644 --- a/lib/classes/component.php +++ b/lib/classes/component.php @@ -100,6 +100,9 @@ class core_component { $newclassname = self::$classmaprenames[$classname]; $debugging = "Class '%s' has been renamed for the autoloader and is now deprecated. Please use '%s' instead."; debugging(sprintf($debugging, $classname, $newclassname), DEBUG_DEVELOPER); + if (PHP_VERSION_ID >= 70000 && preg_match('#\\\null(\\\|$)#', $classname)) { + throw new \coding_exception("Cannot alias $classname to $newclassname"); + } class_alias($newclassname, $classname); return; } diff --git a/lib/classes/progress/null.php b/lib/classes/progress/none.php similarity index 73% rename from lib/classes/progress/null.php rename to lib/classes/progress/none.php index f332a30b0f0..4273f34d8a5 100644 --- a/lib/classes/progress/null.php +++ b/lib/classes/progress/none.php @@ -14,6 +14,14 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +/** + * Progress handler that ignores progress entirely. + * + * @package core + * @copyright 2013 The Open University + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + namespace core\progress; defined('MOODLE_INTERNAL') || die(); @@ -21,11 +29,16 @@ defined('MOODLE_INTERNAL') || die(); /** * Progress handler that ignores progress entirely. * - * @package core_progress + * @package core * @copyright 2013 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class null extends base { +class none extends base { + /** + * When progress is updated, do nothing. + * + * @see \core\progress\base::update_progress() + */ public function update_progress() { // Do nothing. } diff --git a/lib/db/renamedclasses.php b/lib/db/renamedclasses.php index 9ccba774025..537bcf8e84c 100644 --- a/lib/db/renamedclasses.php +++ b/lib/db/renamedclasses.php @@ -36,4 +36,5 @@ defined('MOODLE_INTERNAL') || die(); // The old class name is the key, the new class name is the value. // The array must be called $renamedclasses. $renamedclasses = array( + 'core\progress\null' => 'core\progress\none', ); diff --git a/lib/upgrade.txt b/lib/upgrade.txt index 89204013b30..b52ab4ad1ed 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -1,6 +1,10 @@ This files describes API changes in core libraries and APIs, information provided here is intended especially for developers. +=== 3.0 === + +* \core\progress\null is renamed to \core\progress\none for improved PHP7 compatibility as null is a reserved word (see MDL-50453). + === 2.9.1 === * New methods grade_grade::get_grade_max() and get_grade_min() must be used rather than directly the public properties rawgrademax and rawgrademin. diff --git a/mod/quiz/report/statistics/classes/calculator.php b/mod/quiz/report/statistics/classes/calculator.php index 0e7d127032d..ada45a7d9ee 100644 --- a/mod/quiz/report/statistics/classes/calculator.php +++ b/mod/quiz/report/statistics/classes/calculator.php @@ -38,7 +38,7 @@ class calculator { public function __construct(\core\progress\base $progress = null) { if ($progress === null) { - $progress = new \core\progress\null(); + $progress = new \core\progress\none(); } $this->progress = $progress; } diff --git a/mod/quiz/report/statistics/report.php b/mod/quiz/report/statistics/report.php index fadb7c49615..bc194c41945 100644 --- a/mod/quiz/report/statistics/report.php +++ b/mod/quiz/report/statistics/report.php @@ -544,7 +544,7 @@ class quiz_statistics_report extends quiz_default_report { public function get_all_stats_and_analysis($quiz, $whichattempts, $whichtries, $groupstudents, $questions, $progress = null) { if ($progress === null) { - $progress = new \core\progress\null(); + $progress = new \core\progress\none(); } $qubaids = quiz_statistics_qubaids_condition($quiz->id, $groupstudents, $whichattempts); @@ -595,7 +595,7 @@ class quiz_statistics_report extends quiz_default_report { $this->progress = new \core\progress\display_if_slow(get_string('calculatingallstats', 'quiz_statistics')); $this->progress->set_display_names(); } else { - $this->progress = new \core\progress\null(); + $this->progress = new \core\progress\none(); } } return $this->progress; @@ -613,7 +613,7 @@ class quiz_statistics_report extends quiz_default_report { protected function analyse_responses_for_all_questions_and_subquestions($questions, $subquestions, $qubaids, $whichtries, $progress = null) { if ($progress === null) { - $progress = new \core\progress\null(); + $progress = new \core\progress\none(); } // Starting response analysis tasks. @@ -643,7 +643,7 @@ class quiz_statistics_report extends quiz_default_report { return array(); } if ($progress === null) { - $progress = new \core\progress\null(); + $progress = new \core\progress\none(); } $progress->start_progress('', $countquestions, $countquestions); foreach ($questions as $question) { diff --git a/question/classes/statistics/questions/calculator.php b/question/classes/statistics/questions/calculator.php index 85c471d946c..567e6e9683f 100644 --- a/question/classes/statistics/questions/calculator.php +++ b/question/classes/statistics/questions/calculator.php @@ -68,12 +68,12 @@ class calculator { * * @param object[] questions to analyze, keyed by slot, also analyses sub questions for random questions. * we expect some extra fields - slot, maxmark and number on the full question data objects. - * @param \core\progress\base|null $progress the element to send progress messages to, default is {@link \core\progress\null}. + * @param \core\progress\base|null $progress the element to send progress messages to, default is {@link \core\progress\none}. */ public function __construct($questions, $progress = null) { if ($progress === null) { - $progress = new \core\progress\null(); + $progress = new \core\progress\none(); } $this->progress = $progress; $this->stats = new $this->statscollectionclassname();