akeeba / fof

Rapid Application Development framework for Joomla!™ 3 and 4
0 stars 0 forks source link

Warning: "continue" targeting switch is equivalent to "break". #679

Closed neoacevedo closed 5 years ago

neoacevedo commented 5 years ago

In PHP 7.3, continue inside a switch generates a warning:

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?

This is present in https://github.com/akeeba/fof/blob/development/fof/TransparentAuthentication/TransparentAuthentication.php#L324 into the switch($method) code for each empty conditional.

I think you could create a validator for PHP version like:

switch ($method) {
    case 'HTTPBasicAuth_TOTP':
        if (empty($this->fofAuth_Key)) {
            if (version_compare(phpversion(), '7.3.0', '>=')) {
                continue 2;
            } else {
                continue;
            }
        }
...
}
nikosdion commented 5 years ago

Um, I already fixed that last week?

nikosdion commented 5 years ago

So, I had fixed it... but only in the FOF 4 work-in-progress branch. Oops. I backported the fix to FOF 3.

FYI, the continue 2 construct is valid for all versions of PHP supported by FOF 3 (PHP 5.4 to 7.3 inclusive). There is no need to have a conditional.