Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RemoveUnusedAliasRector should take into account namespace conflicts #1537

Closed
Aerendir opened this issue Jun 3, 2019 · 1 comment · Fixed by #1561
Closed

RemoveUnusedAliasRector should take into account namespace conflicts #1537

Aerendir opened this issue Jun 3, 2019 · 1 comment · Fixed by #1561

Comments

@Aerendir
Copy link
Contributor

Aerendir commented Jun 3, 2019

    ---------- begin diff ----------
--- Original
+++ New
@@ -31,7 +31,7 @@
-use Aerendir\Component\DigitalCertificateVerifier\Client as DcClient;
+use Aerendir\Component\DigitalCertificateVerifier\Client;
@@ -45,7 +45,7 @@
-use SHQ\Component\Whois\Client as WhoisClient;
+use SHQ\Component\Whois\Client;
@@ -77,8 +77,8 @@
      */
     public function __construct(
-        DcClient $certificateClient,
-        WhoisClient $whoisClient,
+        Client $certificateClient,
+        Client $whoisClient
     ) {
         ...
    ----------- end diff -----------

Here WhoisClient and DcClient are two completely different classes but Rector changes them to be both Client and this will cause errors.

SUGGESTED APPROACHES

  1. Maintain the namespace part that are required to differentiate the two classes;
  2. Correctly consider the aliases as in use and so don't remove them.

I prefer the second option as in the code I can better understand when I call one client over the other.

@TomasVotruba
Copy link
Member

TomasVotruba commented Jun 4, 2019

  1. Correctly consider the aliases as in use and so don't remove them.

I like this, because it preffers the programmers intention over semantics/language syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants