1.2.238. Constants Created Outside Its Namespace¶
Constants Created Outside Its Namespace.
Using the define() function, it is possible to create constant outside their namespace, but using the fully qualified namespace.
However, this makes the code confusing and difficult to debug. It is recommended to move the constant definition to its namespace.
<?php
namespace A\B {
// define A\B\C as 1
define('C', 1);
}
namespace D\E {
// define A\B\C as 1, while outside the A\B namespace
define('A\B\C', 1);
}
?>
1.2.238.1. Connex PHP features¶
1.2.238.1.1. Suggestions¶
Declare the constant in its namespace
1.2.238.1.2. Specs¶
Short name |
Constants/CreatedOutsideItsNamespace |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Slow (1 hour) |
Precision |
High |
Available in |