-
-
Notifications
You must be signed in to change notification settings - Fork 117
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
Keeping class references fully qualified after moving #2208
Keeping class references fully qualified after moving #2208
Conversation
@@ -34,6 +34,18 @@ public function replaceReferences( | |||
|
|||
foreach ($classRefList as $classRef) { | |||
assert($classRef instanceof ClassReference); | |||
|
|||
// Check if the class name is fully qualified and replace it with a fully qualified version of the new name | |||
$firstClassNameCharacter = $source->__toString()[$classRef->position()->start()]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this is probably not the right way to check if a class name is fully qualified or not. Any suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like you could add a method to QualifiedName
: wasFullyQualified
. ATM it seems it then has the contents ["", "Foo", "Bar"]
otherwise you could check if it was fully qualified in the static constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should work but the ClassMover namespace has it's own version of a FullyQualified name. Should I try to also add it to that? Because this changes a lot of tests if I do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes , class mover has it's own stuff...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added it in both versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK ClassMover doesn't use the Name
package. Can we revert those changes? A name doesn't normally know if it was fully qualfiied ,,,,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing.
{ | ||
return $this->updater->textEditsFor(SourceCodeBuilder::create()->namespace($qualifiedName->__toString())->build(), Code::fromString($source->__toString())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note Code::
need probably be entirely replcaed by TextDocument, so this type of refatoring isnt really necessaary
merci! |
If a class name was fully qualified before moving, then it should be fully qualified after moving as well.
Fixes #2115