From f67fc1ae89a9a509a7a9f041b7541f4aa9fe15c5 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Fri, 3 Dec 2021 23:23:50 +0100 Subject: [PATCH] Downgrade code to be PHP 7.0 compliant. We need codechecker to continue working with PHP 7.0, because it's used by moodle-plugin-ci that supports that version. Hence, we have to downgrade code till it's decided to raise requirements in both products. Not much problem, only a few code recently introduced (using some optional return type hinting that was added with PHP 7.1) needs to be downgraded. --- moodle/Util/MoodleUtil.php | 8 ++++---- moodle/tests/moodleutil_test.php | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/moodle/Util/MoodleUtil.php b/moodle/Util/MoodleUtil.php index b15aeb44..a8e9ecb8 100644 --- a/moodle/Util/MoodleUtil.php +++ b/moodle/Util/MoodleUtil.php @@ -84,7 +84,7 @@ protected static function loadCoreComponent(string $moodleRoot): bool { * * @return array Associative array of components as keys and paths as values or null if not found. */ - protected static function calculateAllComponents(string $moodleRoot): ?array { + protected static function calculateAllComponents(string $moodleRoot) { // If we have calculated the components already, straight return them. if (!empty(self::$moodleComponents)) { @@ -188,7 +188,7 @@ protected static function calculateAllComponents(string $moodleRoot): ?array { * * @return string|null a valid moodle component for the file or null if not found. */ - public static function getMoodleComponent(File $file, $selfPath = true): ?string { + public static function getMoodleComponent(File $file, $selfPath = true) { // Verify that we are able to find a valid moodle root. if (! $moodleRoot = self::getMoodleRoot($file, $selfPath)) { @@ -232,7 +232,7 @@ public static function getMoodleComponent(File $file, $selfPath = true): ?string * * @return int|null the numeric branch in moodle root version.php or null if not found */ - public static function getMoodleBranch(?File $file = null, bool $selfPath = true): ?int { + public static function getMoodleBranch(File $file = null, bool $selfPath = true) { // Return already calculated value if available. if (self::$moodleBranch !== false) { @@ -293,7 +293,7 @@ public static function getMoodleBranch(?File $file = null, bool $selfPath = true * * @return string|null the full path to moodle root or null if not found. */ - public static function getMoodleRoot(?File $file = null, bool $selfPath = true): ?string { + public static function getMoodleRoot(File $file = null, bool $selfPath = true) { // Return already calculated value if available. if (self::$moodleRoot !== false) { diff --git a/moodle/tests/moodleutil_test.php b/moodle/tests/moodleutil_test.php index 59505616..82c1725a 100644 --- a/moodle/tests/moodleutil_test.php +++ b/moodle/tests/moodleutil_test.php @@ -142,7 +142,7 @@ public function getMoodleComponentProvider() { * * @dataProvider getMoodleComponentProvider */ - public function test_getMoodleComponent(array $config, array $return, ?bool $reset = true, ?bool $selfPath = true) { + public function test_getMoodleComponent(array $config, array $return, bool $reset = true, bool $selfPath = true) { $file = null; // Set config options when passed. if ($config) { @@ -240,7 +240,7 @@ public function getMoodleBranchProvider() { * * @dataProvider getMoodleBranchProvider */ - public function test_getMoodleBranch(array $config, array $return, ?bool $reset = true, ?bool $selfPath = true) { + public function test_getMoodleBranch(array $config, array $return, bool $reset = true, bool $selfPath = true) { $file = null; // Set config options when passed. if ($config) { @@ -342,7 +342,7 @@ public function getMoodleRootProvider() { * * @dataProvider getMoodleRootProvider */ - public function test_getMoodleRoot(array $config, array $return, ?bool $reset = true, ?bool $selfPath = true) { + public function test_getMoodleRoot(array $config, array $return, bool $reset = true, bool $selfPath = true) { $file = null; // Set config options when passed. if ($config) {