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

Allowing ! empty() construct in place of isset() #793

Open
joho1968 opened this issue Nov 18, 2024 · 1 comment
Open

Allowing ! empty() construct in place of isset() #793

joho1968 opened this issue Nov 18, 2024 · 1 comment

Comments

@joho1968
Copy link

Quite a few warnings are generated which I feel are excessive, specifically in regards to checking variables before using them.

I often use a construct like this:

if ( ! empty( $_SERVER['this_and_that'] ) ) {
  $my_variable = wp_unslash( $_SERVER['this_and_that'] );
} else {
  $my_variable = 'Is something else';
}

But here, it seems like the plugin checker wants me to use something like this:

if ( isset( $_SERVER['this_and_that'] ) && ! empty( $_SERVER['this_and_that'] ) ) {
  $my_variable = wp_unslash( $_SERVER['this_and_that'] );
} else {
  $my_variable = 'Is something else';
}

Why?

The empty() construct allows me to check for existence and content ...

@swissspidy
Copy link
Member

This is a question for the WPCS repo, but I am pretty sure that‘s already explained there somewhere.

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

No branches or pull requests

2 participants