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

Stop rename local variables corrupting variables with similar names #45

Merged
merged 1 commit into from
Apr 14, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions features/rename_local_variable.feature
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,45 @@ Feature: Rename Local Variable
}
}
"""

Scenario: Rename variable in method other other similarly named variables on same line
Given a PHP File named "src/SimilarVariableName.php" with:
"""
<?php
class SimilarVariableName
{
public function operation()
{
$var = 2;

$varsecond = 5;

return $var + $varsecond;
}
}
"""
When I use refactoring "rename-local-variable" with:
| arg | value |
| file | src/SimilarVariableName.php |
| line | 6 |
| name | var |
| new-name | number |
Then the PHP File "src/SimilarVariableName.php" should be refactored:
"""
--- a/vfs://project/src/SimilarVariableName.php
+++ b/vfs://project/src/SimilarVariableName.php
@@ -3,10 +3,10 @@
{
public function operation()
{
- $var = 2;
+ $number = 2;

$varsecond = 5;

- return $var + $varsecond;
+ return $number + $varsecond;
}
}

"""