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

Fix name context on no namespace #1067

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

samsonasik
Copy link
Contributor

Ref https://getrector.com/ast/d50f4d493f7061f3c419397a744a49e92409c3ce?nodeId=1

which \true should be true on no namespace.

@samsonasik
Copy link
Contributor Author

Ready to merge 👍

Copy link
Owner

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this change is correct. Outside a namespace we should still fully resolve to full qualified names. Unqualified names should only be left if resolution is impossible (due to global fallback) or because of special class names.

@samsonasik
Copy link
Contributor Author

samsonasik commented Jan 29, 2025

the verification of fully qualified already checked before check on line 114, so I think that's safe

@@ -117,8 +117,8 @@ public function testResolveNames(): void {
new \Hallo\Bar();
new \Bar();
new \Bar();
\bar();
\hi();
bar();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what I mean. This should resolve to a fully qualified name. The fact that it is equivalent to the unqualified name doesn't matter, we should always resolve fully if it is possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if i understand correctly, the test is removing namespace, which no longer has namespace, means it doesn't have \\ prefix, next line to it, it have \bar which not changed as already fully qualified on the first place, which expexted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see line 124 which kept to have \\ prefix as it previously already fully qualified.

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.

2 participants