This repository was archived by the owner on Jul 12, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
main/QafooLabs/Refactoring/Domain/Model
test/QafooLabs/Refactoring/Domain/Model Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -109,7 +109,10 @@ public function change(PhpName $from, PhpName $to)
109109 if ($ this ->fullyQualifiedName === $ this ->relativeName ) {
110110 $ relativeNewParts = $ newParts ;
111111 } else {
112- $ diff = count ($ newParts ) - $ this ->numParts ();
112+ $ diff = ($ this ->type === self ::TYPE_CLASS )
113+ ? 0
114+ : count ($ newParts ) - $ this ->numParts ();
115+
113116 $ relativeNewParts = array_slice ($ newParts , -1 * (count (explode ('\\' , $ this ->relativeName ))+$ diff ));
114117 }
115118
Original file line number Diff line number Diff line change @@ -171,4 +171,17 @@ public function testAddRelativeNameWhenNamespaceExpands()
171171 $ this ->assertEquals ('Foo\Bar\Foo ' , $ changed ->fullyQualifiedName ());
172172 $ this ->assertEquals ('Bar\Foo ' , $ changed ->relativeName ());
173173 }
174+
175+ public function testNotExpandWhenRelativeNameIsTypeClass ()
176+ {
177+ $ from = new PhpName ('Foo ' , 'Foo ' );
178+ $ to = new PhpName ('Foo\Bar ' , 'Foo\Bar ' );
179+
180+ $ name = new PhpName ('Foo\Foo ' , 'Foo ' , PhpName::TYPE_CLASS );
181+ $ changed = $ name ->change ($ from , $ to );
182+
183+ $ this ->assertFalse ($ name ->isAffectedByChangesTo ($ from ));
184+ $ this ->assertEquals ('Foo\Bar\Foo ' , $ changed ->fullyQualifiedName ());
185+ $ this ->assertEquals ('Foo ' , $ changed ->relativeName ());
186+ }
174187}
You can’t perform that action at this time.
0 commit comments