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

WordPressVIPMinimum.Constants.ConstantString.NotCheckingConstantName wrong #480

Closed
kkmuffme opened this issue Jun 26, 2020 · 3 comments
Closed
Milestone

Comments

@kkmuffme
Copy link

$key = 'hello';
if ( defined( $key ) && constant( $key ) === false ) {

gives error WordPressVIPMinimum.Constants.ConstantString.NotCheckingConstantName:
Constant name, as a string, should be used along with defined().

which is wrong, as it is checked with defined.

@GaryJones
Copy link
Contributor

Hi @kkmuffme

While there may indeed be an area of improvement here, your example is flawed, in that defined() only works with constants, yet in your example you've got $key as a variable.

@kkmuffme
Copy link
Author

No, defined() works with strings and NOT constants. If you pass a constant to defined, you check if the value of the constant is defined as a separate constant.

See:

$key = 'HELLO';
define( $key, 'world' );
if ( defined( $key ) ) {
    echo 'checked as string';
}

if ( defined( HELLO ) ) {
    echo 'checked as constant';
}

@jrfnl
Copy link
Collaborator

jrfnl commented Oct 2, 2020

Closing as this was fixed by #444.

@jrfnl jrfnl closed this as completed Oct 2, 2020
@jrfnl jrfnl added this to the 2.3.0 milestone Oct 2, 2020
@jrfnl jrfnl added the Type: Bug label Oct 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants