This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 257532 - Refactoring Extract Method does not work
Summary: Refactoring Extract Method does not work
Status: RESOLVED INVALID
Alias: None
Product: php
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 8.1
Hardware: PC Linux
: P1 normal (vote)
Assignee: Ondrej Brejla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-12 09:19 UTC by fanphp977
Modified: 2016-01-27 09:02 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description fanphp977 2016-01-12 09:19:18 UTC
Hi guys,

I don't know if it is a bug or something else; "Extract Method" in php platform, does not work as it should; Every time I try to create a new method from a method of class , I get the error "You can't refact here".
 
In general, Refactoring in PHP projects seems to not work as it should, except for "Rename" functionality 

Is it possible to fix/enhance php refactoring section? 

Refactoring, in modern php development ( TEST DRIVEN DEVELOPMENT ), is very important!!
Comment 1 Tomas Mysik 2016-01-19 12:09:59 UTC
Can you please attach a sample project and provide exact steps to reproduce?

Simply reopen this issue, thanks.
Comment 2 gianluca.ferrantelli 2016-01-19 13:25:40 UTC
Hi,
yes it is very simple:

This the project structure:

$ tree
.
├── index.php
├── MyClass.php
└── nbproject
    ├── private
    │   ├── config.properties
    │   ├── phpcsmd.xml
    │   ├── private.properties
    │   └── private.xml
    ├── project.properties
    └── project.xml

2 directories, 8 files


My simple class looks like this:



class MyClass
{

    public function __construct() {
        
    }
    
    public function tryToRefactorMe()
    {
        //... code here
        $html  = '';
        $params = ['name1', 'name2'];
        foreach ($params as $value) {
            $html .= $value;
        }        

        return $html;

    }

}




I 'd like to extract a new method from the existing "tryToRefactorMe" method,
to get something similar:



    //... class code here

    public function tryToRefactorMe()
    {
        //... code here
        $html  = $this->newExtractedMethod($params);
        //... code here

        return $html;

    }

    private function newExtractedMethod($params)
    {
        //... code here     
    }
    //... class code here




If I try to surround the part of the code to be refactorized, the submenu does not show the universal know "extract method" refactoring option; I have only have "move", copy", etc and no one of these command works.


I know that IDEs who implement refactoring, usually have mode options, such as "Extract Method", etc etc ...


thanks in advance!
Comment 3 Tomas Mysik 2016-01-27 09:02:41 UTC
The cause is simple: "Extract Method" refactoring is currently not supported in
PHP support (it is supported perhaps only in Java support).

Thanks for reporting.