1.2.805. No Class In Global¶
Avoid defining structures in Global namespace. Always prefer using a namespace. This will come handy later, either when publishing the code, or when importing a library, or even if PHP reclaims that name.
<?php
// Code prepared for later
namespace Foo {
class Bar {}
}
// Code that may conflict with other names.
namespace {
class Bar {}
}
?>
1.2.805.1. Connex PHP features¶
1.2.805.1.1. Suggestions¶
Use a specific namespace for your classes
1.2.805.1.2. Specs¶
Short name |
Php/NoClassInGlobal |
Rulesets |
|
Exakat since |
0.10.9 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Slow (1 hour) |
Precision |
Very high |
Examples |
|
Available in |