1.2.790. 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.790.1. Suggestions¶
Use a specific namespace for your classes
1.2.790.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 |
Features |
class, global-scope |
Examples |
|
Available in |