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

Remove unnecessary filter_var with FILTER_VALIDATE_BOOLEAN option #8879

Open
Harfusha opened this issue Oct 30, 2024 · 1 comment
Open

Remove unnecessary filter_var with FILTER_VALIDATE_BOOLEAN option #8879

Harfusha opened this issue Oct 30, 2024 · 1 comment
Labels

Comments

@Harfusha
Copy link

Feature Request

When variable is always boolean it is unnecessary to run it trough filter_var with FILTER_VALIDATE_BOOLEAN option.

Diff

function test(bool $isTest): bool {
-    if (filter_var($isTest, FILTER_VALIDATE_BOOLEAN)) {
+    if ($isTest) {
        return true;
    }

    return false;
}
@Harfusha
Copy link
Author

filter_var is 7x slower than simple boolean check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant