Skip to content

Commit

Permalink
Downgrade code to be PHP 7.0 compliant.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
stronk7 committed Dec 3, 2021
1 parent 6e382e1 commit f67fc1a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions moodle/Util/MoodleUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions moodle/tests/moodleutil_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit f67fc1a

Please sign in to comment.