1.2.1109. Should Make Alias¶
Long names should be aliased.
Aliased names are easy to read at the beginning of the script; they may be changed at one point, and update the whole code at the same time. Finally, short names makes the rest of the code readable.
<?php
namespace x\y\z;
use a\b\c\d\e\f\g as Object;
// long name, difficult to read, prone to change.
new a\b\c\d\e\f\g();
// long name, difficult to read, prone to silent dead code if namespace change.
if ($o instanceof a\b\c\d\e\f\g) {
}
// short names Easy to update all at once.
new Object();
if ($o instanceof Object) {
}
?>
1.2.1109.1. Specs¶
Short name |
Namespaces/ShouldMakeAlias |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Available in |