Skip to content

ConstantString doesn't allow for namespaces before the string #422

@GaryJones

Description

@GaryJones

Bug Description

ConstantStringSniff doesn't allow for namespaces before the string.

Minimal Code Snippet

namespace Foo\Bar;

const REST_ALLOWED_META_PREFIXES = [ 'foo-', 'bar-', 'baz-' ];

if ( defined( __NAMESPACE__ . '\REST_ALLOWED_META_PREFIXES' ) && in_array( 'foo-', REST_ALLOWED_META_PREFIXES, true ) ) {
}

Error Code

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

Environment

Question Answer
PHP version 7.3.2
PHP_CodeSniffer version 3.4.2
VIPCS version 1.0.0

Tested Against master branch?

  • I have verified the issue still exists in the master branch of VIPCS.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions