Skip to content

Commit 53f6402

Browse files
authored
Merge pull request #162 from stronk7/php70fix
Downgrade code to be PHP 7.0 compliant.
2 parents 6e382e1 + 85d9c1f commit 53f6402

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

moodle/Util/MoodleUtil.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ protected static function loadCoreComponent(string $moodleRoot): bool {
8484
*
8585
* @return array Associative array of components as keys and paths as values or null if not found.
8686
*/
87-
protected static function calculateAllComponents(string $moodleRoot): ?array {
87+
protected static function calculateAllComponents(string $moodleRoot) {
8888

8989
// If we have calculated the components already, straight return them.
9090
if (!empty(self::$moodleComponents)) {
@@ -188,7 +188,7 @@ protected static function calculateAllComponents(string $moodleRoot): ?array {
188188
*
189189
* @return string|null a valid moodle component for the file or null if not found.
190190
*/
191-
public static function getMoodleComponent(File $file, $selfPath = true): ?string {
191+
public static function getMoodleComponent(File $file, $selfPath = true) {
192192

193193
// Verify that we are able to find a valid moodle root.
194194
if (! $moodleRoot = self::getMoodleRoot($file, $selfPath)) {
@@ -232,7 +232,7 @@ public static function getMoodleComponent(File $file, $selfPath = true): ?string
232232
*
233233
* @return int|null the numeric branch in moodle root version.php or null if not found
234234
*/
235-
public static function getMoodleBranch(?File $file = null, bool $selfPath = true): ?int {
235+
public static function getMoodleBranch(File $file = null, bool $selfPath = true) {
236236

237237
// Return already calculated value if available.
238238
if (self::$moodleBranch !== false) {
@@ -250,7 +250,7 @@ public static function getMoodleBranch(?File $file = null, bool $selfPath = true
250250
throw new DeepExitException(
251251
"ERROR: Incorrect 'moodleBranch' config/runtime option. Value must be 4 digit max.: '$branch'", 3);
252252
}
253-
self::$moodleBranch = $branch;
253+
self::$moodleBranch = (int)$branch;
254254
return self::$moodleBranch;
255255
}
256256

@@ -268,7 +268,7 @@ public static function getMoodleBranch(?File $file = null, bool $selfPath = true
268268
// Find the $branch value.
269269
if ($valueToken = $versionFile->findNext(T_CONSTANT_ENCAPSED_STRING, $varToken)) {
270270
$branch = trim($versionFile->getTokens()[$valueToken]['content'], "\"'");
271-
self::$moodleBranch = $branch;
271+
self::$moodleBranch = (int)$branch;
272272
return self::$moodleBranch;
273273
}
274274
}
@@ -293,7 +293,7 @@ public static function getMoodleBranch(?File $file = null, bool $selfPath = true
293293
*
294294
* @return string|null the full path to moodle root or null if not found.
295295
*/
296-
public static function getMoodleRoot(?File $file = null, bool $selfPath = true): ?string {
296+
public static function getMoodleRoot(File $file = null, bool $selfPath = true) {
297297

298298
// Return already calculated value if available.
299299
if (self::$moodleRoot !== false) {

moodle/tests/moodleutil_test.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function getMoodleComponentProvider() {
142142
*
143143
* @dataProvider getMoodleComponentProvider
144144
*/
145-
public function test_getMoodleComponent(array $config, array $return, ?bool $reset = true, ?bool $selfPath = true) {
145+
public function test_getMoodleComponent(array $config, array $return, bool $reset = true, bool $selfPath = true) {
146146
$file = null;
147147
// Set config options when passed.
148148
if ($config) {
@@ -240,7 +240,7 @@ public function getMoodleBranchProvider() {
240240
*
241241
* @dataProvider getMoodleBranchProvider
242242
*/
243-
public function test_getMoodleBranch(array $config, array $return, ?bool $reset = true, ?bool $selfPath = true) {
243+
public function test_getMoodleBranch(array $config, array $return, bool $reset = true, bool $selfPath = true) {
244244
$file = null;
245245
// Set config options when passed.
246246
if ($config) {
@@ -342,7 +342,7 @@ public function getMoodleRootProvider() {
342342
*
343343
* @dataProvider getMoodleRootProvider
344344
*/
345-
public function test_getMoodleRoot(array $config, array $return, ?bool $reset = true, ?bool $selfPath = true) {
345+
public function test_getMoodleRoot(array $config, array $return, bool $reset = true, bool $selfPath = true) {
346346
$file = null;
347347
// Set config options when passed.
348348
if ($config) {

0 commit comments

Comments
 (0)