Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method Extraction does not go all the way out of brackets #411

Open
Gert-dev opened this issue May 4, 2018 · 0 comments
Open

Method Extraction does not go all the way out of brackets #411

Gert-dev opened this issue May 4, 2018 · 0 comments
Labels

Comments

@Gert-dev
Copy link
Owner

Gert-dev commented May 4, 2018

Originally posted by @agleis:

I've posted a gif of this issue below, but basically, in certain situations (especially in highly complex or nested functions), method extraction will 'paste' the method outside of the wrong set of brackets, such that it is still inside the original method. An example of this would be:

public function method() {
    if(8 == 8) {
        for($i = 0; $i < 10; $i++) {
            $i++;
            $i--;
        }
    }
}

Extracting the $i++ and $i-- lines would produce:

public function method() {
    if(8 == 8) {
        for($i = 0; $i < 10; $i++) {
            $this->test($i);
        }
    }
    /**
     * @param $i
     */
    public function test($i) {
        $i++;
        $i--;
    }
}

As you can see, the new function is still inside the original method brackets. It probably wouldn't happen with a function this small, but that's the idea. I have noticed this quite a few times when I've been working on more complex classes, and it is a bit annoying. See the gif below for a real example of this bug happening.

extract-method-error

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@Gert-dev Gert-dev added the bug label May 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant