Skip to content

Conversation

@samsonasik
Copy link
Member

File with multiple namespaces currently make infinite loop on UseAddingPostRector's PostRector.

This PR skip it to avoid infinite loop due to somehow lookup on the File instead of current namespace.

@samsonasik samsonasik changed the title [AutoImport] Skip multiple namespaces on auto imports [AutoImport] Skip multiple namespaces on single file on auto imports Sep 19, 2022
@samsonasik
Copy link
Member Author

It seems cause error in test: ImportFullyQualifiedNamesRector

 There was 1 failure:

1) Rector\Tests\CodingStyle\Rector\Namespace_\ImportFullyQualifiedNamesRector\ImportFullyQualifiedNamesRectorTest::test with data set #10 ('/home/runner/work/rector-src/...hp.inc')
Failed asserting that string matches format description.
--- Expected
+++ Actual
@@ @@
 <?php
 
 namespace {
-    use function SomeNamespace\gc_disable;
     function run_me_never()
     {
         // silent deprecations, since we test them
@@ @@
         error_reporting(E_ALL ^ E_DEPRECATED);
 
         // performance boost
-        gc_disable();
+        \SomeNamespace\gc_disable();
     }
 }

The issue is when importing is flipped to 2nd namespace instead of 1st namespace. I think it should just be skipped, then it will be safe.

@samsonasik
Copy link
Member Author

I updated the fixture to skip multiple namespaces

@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba it is ready for review.

@TomasVotruba TomasVotruba merged commit 4c69331 into main Sep 19, 2022
@TomasVotruba TomasVotruba deleted the skip-multiple-namespace-autoload branch September 19, 2022 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants