Other functions/places you have to do manually -- you can do such "replacement" from the same screen actually: So ... in your example, After you've executed Code | Refactor | Extract Method:
Make duplicate #2 to be displayed on right side in diff viewer (it is by default)
Click on 2) to copy call to extracted method to that duplicate #2
Make duplicate #3 to be displayed on right side in diff viewer (the icon in 1) should be green)
Click on 2) to copy call to extracted method to that duplicate #3
After making these operations the result will be:
function test1 () {
ABC();
}
function ABC()
{
$aaa = "aaaaa";
$bbb = "bbbbb";
$ccc = "ccccc";
}
function test2 () {
ABC();
}
function test3 () {
ABC();
}
Hi there,
Please select such code and try "Refactor | Extract | Method..."
Hello!
Thanks for the information.
Unfortunately, the result is not as hoped.
I have a file.
--------------------------
function test1 () {
$ aaa = "aaaaa";
$ bbb = "bbbbb";
$ ccc = "ccccc";
}
function test2 () {
$ aaa = "aaaaa";
$ bbb = "bbbbb";
$ ccc = "ccccc";
}
function test3 () {
$ aaa = "aaaaa";
$ bbb = "bbbbb";
$ ccc = "ccccc";
}
------------------------------
This file is duplicate code.
With code -> Locate Duplicates ..
can I find duplicate code.
If I use the duplicate code
Refactor -> Extract -> Method ...
alters I get the file.
-------------------------------
function test1 () {
myDuplicateCode ();
}
myDuplicateCode function ()
{
$ aaa = "aaaaa";
$ bbb = "bbbbb";
$ ccc = "ccccc";
}
function test2 () {
$ aaa = "aaaaa";
$ bbb = "bbbbb";
$ ccc = "ccccc";
}
function test3 () {
$ aaa = "aaaaa";
$ bbb = "bbbbb";
$ ccc = "ccccc";
}
-------------------
Why not in the other functions?
Sincerely yours
Stephan
Other functions/places you have to do manually -- you can do such "replacement" from the same screen actually:

So ... in your example, After you've executed Code | Refactor | Extract Method:
After making these operations the result will be: