Skip to content

Commit

Permalink
Merge pull request #108 from stronk7/revert_old_7_0_support_commit
Browse files Browse the repository at this point in the history
Revert "Downgrade code to be PHP 7.0 compliant."
  • Loading branch information
stronk7 authored Feb 18, 2024
2 parents 73f0a60 + 68ca06c commit 8fff499
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions moodle/Util/MoodleUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protected static function loadCoreComponent(string $moodleRoot): bool {
* @param string $moodleRoot Full path to a valid moodle.root
* @return array Associative array of components as keys and paths as values or null if not found.
*/
protected static function calculateAllComponents(string $moodleRoot) {
protected static function calculateAllComponents(string $moodleRoot): ?array {
// If we have calculated the components already, straight return them.
if (!empty(self::$moodleComponents)) {
return self::$moodleComponents;
Expand Down Expand Up @@ -205,7 +205,7 @@ protected static function calculateAllComponents(string $moodleRoot) {
*
* @return string|null a valid moodle component for the file or null if not found.
*/
public static function getMoodleComponent(File $file, $selfPath = true) {
public static function getMoodleComponent(File $file, $selfPath = true): ?string {
if (defined('PHPUNIT_TEST') && PHPUNIT_TEST && !empty(self::$mockedComponentMappings)) {
$components = self::$mockedComponentMappings; // @codeCoverageIgnore
} else {
Expand Down Expand Up @@ -252,7 +252,7 @@ public static function getMoodleComponent(File $file, $selfPath = true) {
*
* @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) {
public static function getMoodleBranch(?File $file = null, bool $selfPath = true): ?int {

// Return already calculated value if available.
if (self::$moodleBranch !== false) {
Expand All @@ -270,7 +270,7 @@ public static function getMoodleBranch(File $file = null, bool $selfPath = true)
throw new DeepExitException(
"ERROR: Incorrect 'moodleBranch' config/runtime option. Value must be 4 digit max.: '$branch'", 3);
}
self::$moodleBranch = (int)$branch;
self::$moodleBranch = $branch;
return self::$moodleBranch;
}

Expand All @@ -288,7 +288,7 @@ public static function getMoodleBranch(File $file = null, bool $selfPath = true)
// Find the $branch value.
if ($valueToken = $versionFile->findNext(T_CONSTANT_ENCAPSED_STRING, $varToken)) {
$branch = trim($versionFile->getTokens()[$valueToken]['content'], "\"'");
self::$moodleBranch = (int)$branch;
self::$moodleBranch = $branch;
return self::$moodleBranch;
}
}
Expand All @@ -313,7 +313,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) {
public static function getMoodleRoot(?File $file = null, bool $selfPath = true): ?string {
// Return already calculated value if available.
if (self::$moodleRoot !== false) {
return self::$moodleRoot;
Expand Down

0 comments on commit 8fff499

Please sign in to comment.