rspec/rules/S6349/php/rule.adoc

35 lines
1.0 KiB
Plaintext

== Why is this an issue?
WordPress relies a lot on the configuration located in a file named `wp-config.php`.
This file contains mostly `define` statements and each of them creates a constant for a given WordPress option.
However, no warning appears if an option is misspelled: the statement simply defines a constant which is never used.
This rule raises an issue when a file named `wp-config.php` defines a constant whose name is slightly different from a known WordPress option.
== How to fix it in WordPress
Fix the typing mistake or rename your custom defined constant to be more unique.
=== Code examples
==== Noncompliant code example
[source,php,diff-id=1,diff-type=noncompliant]
----
define( 'DISALLOW_FILE_MOD', true ); // Noncompliant
define( 'Disallow_File_Mods', true ); // Noncompliant
----
==== Compliant solution
[source,php,diff-id=1,diff-type=compliant]
----
define( 'DISALLOW_FILE_MODS', true );
----
== Resources
=== Documentation
* https://developer.wordpress.org/apis/wp-config-php/[WordPress Developer Resources: wp-config.php]