diff --git a/moodle/Util/MoodleUtil.php b/moodle/Util/MoodleUtil.php index 61a0daa..641415e 100644 --- a/moodle/Util/MoodleUtil.php +++ b/moodle/Util/MoodleUtil.php @@ -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; @@ -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 { @@ -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) { @@ -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; } @@ -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; } } @@ -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;