You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// OK.useVendor\Package\ClassNameasOtherClassName;
usefunctionVendor\Package\functionName as otherFunctionName;
useconstVendor\Package\CONSTANT_NAMEasOTHER_CONSTANT_NAME;
// Not OK.useVendor\Package\ClassNameasClassName;
usefunctionVendor\Package\functionName as functionName;
useconstVendor\Package\CONSTANT_NAMEasCONSTANT_NAME;
// Should also be checked for trait `use` statementsclassAliased_Talker {
useA {
A::bigTalk as talk; // OKA::smallTalk as smallTalk; // Not OK.
}
}
Additional context (optional)
Aliasing to the same name, but in a different case should also be flagged, though maybe with a separate error code.
Namespace, OO and function names in PHP are case-insensitive, so aliasing to the same name in a different case is just as useless.
Note: constants are generally case-sensitive, except when explicitly declared as case-insensitive using define(). Probably still a good idea to flag that even so.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem?
It would be nice to have a sniff which would detect and flag when an alias is the same as the original name.
PHP will allow this just fine - https://3v4l.org/DIT7X#veol / https://3v4l.org/Gd4M7#veol - , but it is useless to do so.
Describe the solution you'd like
A new sniff to detect useless aliases.
Additional context (optional)
Aliasing to the same name, but in a different case should also be flagged, though maybe with a separate error code.
Namespace, OO and function names in PHP are case-insensitive, so aliasing to the same name in a different case is just as useless.
Note: constants are generally case-sensitive, except when explicitly declared as case-insensitive using
define()
. Probably still a good idea to flag that even so.The text was updated successfully, but these errors were encountered: