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

[Core] Apply Scope refresh for Namespace_ and FileWithoutNamespace #2569

Merged
merged 6 commits into from
Jun 27, 2022

Conversation

samsonasik
Copy link
Member

No description provided.

@samsonasik samsonasik force-pushed the scope-refresh-namespace-file-without-namespace branch from 754a5fe to 0e10130 Compare June 26, 2022 04:03
@samsonasik
Copy link
Member Author

implemented 🎉 with check:

  • has no Scope
  • Node is Namespace_ or FileWithoutNamespace

then fallback to use Scope from ScopeFactory:

$mutatingScope = $this->scopeFactory->createFromFile($smartFileInfo);

@samsonasik
Copy link
Member Author

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

@TomasVotruba
Copy link
Member

I wonder, there should be also some test to cover this fix. To make sure it will not be regressed in the future.

@samsonasik
Copy link
Member Author

The test already exists, when only unregister Namespace_ and FileWithoutNamespace, it will got error:

There were 4 errors:
1) Rector\Tests\PSR4\Rector\FileWithoutNamespace\NormalizeNamespaceByPSR4ComposerAutoloadRector\NormalizeNamespaceByPSR4ComposerAutoloadRectorTest::test with data set #3 (Symplify\SmartFileSystem\SmartFileInfo Object (...))
Rector\Core\Exception\ShouldNotHappenException: Node "PhpParser\Node\Stmt\Namespace_" with parent of "" is missing scope required for scope refresh.

https://github.com/rectorphp/rector-src/runs/7058239145?check_suite_focus=true#step:5:87

On first commit e5941ba

@TomasVotruba
Copy link
Member

I see it now, thank you 👍

@TomasVotruba TomasVotruba merged commit 89a684f into main Jun 27, 2022
@TomasVotruba TomasVotruba deleted the scope-refresh-namespace-file-without-namespace branch June 27, 2022 08:26
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