@@ -91,6 +91,46 @@ Feature: Rename Local Variable
91
91
92
92
"""
93
93
94
+ Scenario : Rename a method argument
95
+ Given a PHP File named "src/MethodArgument.php" with:
96
+ """
97
+ <?php
98
+ class MethodArgument
99
+ {
100
+ public function operation($varsecond = 5)
101
+ {
102
+ $var = 2;
103
+
104
+ return $var + $varsecond;
105
+ }
106
+ }
107
+ """
108
+ When I use refactoring "rename-local-variable" with:
109
+ | arg | value |
110
+ | file | src /MethodArgument .php |
111
+ | line | 4 |
112
+ | name | varsecond |
113
+ | new -name | multiplier |
114
+ Then the PHP File "src/MethodArgument.php" should be refactored:
115
+ """
116
+ --- a/vfs://project/src/MethodArgument.php
117
+ +++ b/vfs://project/src/MethodArgument.php
118
+ @@ -1,10 +1,10 @@
119
+ <?php
120
+ class MethodArgument
121
+ {
122
+ - public function operation($varsecond = 5)
123
+ + public function operation($multiplier = 5)
124
+ {
125
+ $var = 2;
126
+
127
+ - return $var + $varsecond;
128
+ + return $var + $multiplier;
129
+ }
130
+ }
131
+
132
+ """
133
+
94
134
Scenario : Rename Variable In functions
95
135
Given a PHP File named "src/Foo.php" with:
96
136
"""
@@ -131,4 +171,44 @@ Feature: Rename Local Variable
131
171
- return $var * $var;
132
172
+ return $number * $number;
133
173
}
174
+ """
175
+
176
+ Scenario : Rename a function's parameter
177
+ Given a PHP File named "src/Foo.php" with:
178
+ """
179
+ <?php
180
+ function operation($number)
181
+ {
182
+ $var = 2;
183
+
184
+ for ($i = 0; $i < 3; $i++) {
185
+ $var = pow($var, $number);
186
+ }
187
+
188
+ return $var * $var;
189
+ }
190
+ """
191
+ When I use refactoring "rename-local-variable" with:
192
+ | arg | value |
193
+ | file | src /Foo .php |
194
+ | line | 2 |
195
+ | name | number |
196
+ | new -name | power |
197
+ Then the PHP File "src/Foo.php" should be refactored:
198
+ """
199
+ --- a/vfs://project/src/Foo.php
200
+ +++ b/vfs://project/src/Foo.php
201
+ @@ -1,10 +1,10 @@
202
+ <?php
203
+ -function operation($number)
204
+ +function operation($power)
205
+ {
206
+ $var = 2;
207
+
208
+ for ($i = 0; $i < 3; $i++) {
209
+ - $var = pow($var, $number);
210
+ + $var = pow($var, $power);
211
+ }
212
+
213
+ return $var * $var;
134
214
"""
0 commit comments