Skip to content

Sniff idea: Detect when constant is being used in constant() #717

@rebeccahum

Description

@rebeccahum

Describe the solution you'd like

Not sure if VIPCS is the best way forward, but I think this would be a worthy sniff.

When using constant(), we should throw a warning if a string is not being inputted. Of course it is valid PHP to do something like:

constant( FOO_BAR );

But I think most likely, what the user wants to do is:

constant( 'FOO_BAR' );

What code should be reported as a violation?

constant( FOO_BAR );

What code should not be reported as a violation?

constant( 'FOO_BAR' );
constant( "FOO_BAR" );
constant( $foo_bar );

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions