Skip to content
This repository was archived by the owner on Jul 12, 2020. It is now read-only.

Commit 279ff66

Browse files
author
Tom Oram
committed
Rename local variables does not corrupt other variables starting with the variable name being changed
1 parent c951cbf commit 279ff66

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

features/rename_local_variable.feature

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,45 @@ Feature: Rename Local Variable
4848
}
4949
}
5050
"""
51+
52+
Scenario: Rename variable in method other other similarly named variables on same line
53+
Given a PHP File named "src/SimilarVariableName.php" with:
54+
"""
55+
<?php
56+
class SimilarVariableName
57+
{
58+
public function operation()
59+
{
60+
$var = 2;
61+
62+
$varsecond = 5;
63+
64+
return $var + $varsecond;
65+
}
66+
}
67+
"""
68+
When I use refactoring "rename-local-variable" with:
69+
| arg | value |
70+
| file | src/SimilarVariableName.php |
71+
| line | 6 |
72+
| name | var |
73+
| new-name | number |
74+
Then the PHP File "src/SimilarVariableName.php" should be refactored:
75+
"""
76+
--- a/vfs://project/src/SimilarVariableName.php
77+
+++ b/vfs://project/src/SimilarVariableName.php
78+
@@ -3,10 +3,10 @@
79+
{
80+
public function operation()
81+
{
82+
- $var = 2;
83+
+ $number = 2;
84+
85+
$varsecond = 5;
86+
87+
- return $var + $varsecond;
88+
+ return $number + $varsecond;
89+
}
90+
}
91+
92+
"""

0 commit comments

Comments
 (0)