Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boolean submitted as string to get_bool_from_string() #1959

Closed
robsonsobral opened this issue Mar 31, 2022 · 0 comments · Fixed by #3215
Closed

Boolean submitted as string to get_bool_from_string() #1959

robsonsobral opened this issue Mar 31, 2022 · 0 comments · Fixed by #3215

Comments

@robsonsobral
Copy link
Contributor

robsonsobral commented Mar 31, 2022

I'm no PHP expert!

Shouldn't "true" and "false" be added to get_bool_from_string()?

function get_bool_from_string($value)
{
    if (is_bool($value) || is_null($value)) {
        return $value;
    }

    switch (strtolower($value)) {
        case 'true': // here
        case 'yes':
        case 'y':
        case 'on':
        case '1':
            return true;

        break;

        case 'false': // and here
        case 'no':
        case 'n':
        case 'off':
        case '0':
            return false;

        break;

        default:
            return null;

        break;
    }
}

I'm thinking on the case of a boolean being submitted as string.

intoeetive added a commit that referenced this issue Apr 4, 2023
Support 'true' and 'false' in get_bool_from_string() function

PSR-12 boot.common.php
intoeetive added a commit that referenced this issue May 2, 2023
Support 'true' and 'false' in get_bool_from_string() function

PSR-12 boot.common.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant