1.2.722. Multiple Alias Definitions

Some aliases are representing different classes across the repository. This leads to potential confusion.

Across an application, it is recommended to use the same namespace for one alias. Failing to do this lead to the same keyword to represent different values in different files, with different behavior. Those are hard to find bugs.

<?php

namespace A {
    use d\d; // aka D
}

// Those are usually in different files, rather than just different namespaces.

namespace B {
    use b\c as D; // also D. This could be named something else
}

?>

1.2.722.1. Suggestions

  • Give more specific names to classes

  • Use an alias ‘use AB ac BC’ to give locally another name

1.2.722.2. Specs

Short name

Namespaces/MultipleAliasDefinitions

Rulesets

All, Analyze, CE, CI-checks, Changed Behavior

Exakat since

0.8.4

PHP Version

All

Severity

Minor

Time To Fix

Instant (5 mins)

Precision

Very high

Examples

ChurchCRM, Phinx

Available in

Entreprise Edition, Community Edition, Exakat Cloud