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 204167

Summary: Method renaming doesn't cover parent calls
Product: php Reporter: dagguh
Component: RefactoringAssignee: Ondrej Brejla <obrejla>
Status: NEW ---    
Severity: normal CC: andyr_it, ppisl, squarestar
Priority: P3    
Version: 7.0.1   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:

Description dagguh 2011-10-24 16:05:26 UTC
Example code:

protected function foo() {
    parent::foo();
}

Action:
Apply rename refactor on method foo, renaming it to bar.

Expected result:

protected function bar() {
    parent::bar();
}

Actual result:

protected function bar() {
    parent::foo();
}
Comment 1 Ondrej Brejla 2011-10-27 12:50:49 UTC
I'm not sure if it should be implemented. parent::foo() is not the exact usage of of your protected function foo() {}...P4 for me.
Comment 2 dagguh 2011-10-27 12:56:21 UTC
I'm applying rename refactor on the parent.
I expect all calls to this method and all overrides to be renamed too.
Comment 3 dagguh 2011-10-27 12:57:30 UTC
PS. To clear things up: this is not a static method
Comment 4 Ondrej Brejla 2011-10-27 13:03:00 UTC
I know that it's not a static call and method, I just didn't know that you apply rename to parent function (it wasn't clear from your report). So:

<?php
class Mother {
    protected function foo() {} // Here you apply rename?
}

class Child extends Mother {
    protected function foo() {
        parent::foo();
    }
}
?>

What is your result of this example and what you expect? Or do you apply rename elsewhere?
Thanks for your coop!
Comment 5 dagguh 2011-10-27 13:10:57 UTC
Initial code:
<?
class Mother {
	// parent declaration
	protected function foo() {}
}

class Child extends Mother {
	// child override
	protected function foo() {
		// call to parent
		parent::foo();
	}
}
?>

Case A - rename at parent declaration:
<?
class Mother {
	protected function bar() {}
}

class Child extends Mother {
	protected function bar() {
		parent::foo();
	}
}
?>

Case B - rename at child override:
<?
class Mother {
	protected function foo() {}
}

class Child extends Mother {
	protected function bar() {
		parent::foo();
	}
}
?>

Case C - rename at call to parent:
<?
class Mother {
	protected function bar() {}
}

class Child extends Mother {
	protected function bar() {
		parent::foo();
	}
}
?>

Clearly cases A and C are bugged. Case B is debatable.
Comment 6 Ondrej Brejla 2011-10-27 13:18:46 UTC
Now it's clear, thanks.
Comment 7 Ondrej Brejla 2012-03-28 12:25:30 UTC
*** Bug 196765 has been marked as a duplicate of this bug. ***
Comment 8 dagguh 2012-08-24 11:58:24 UTC
Still reproducible in NetBeans IDE Dev (Build 201208240001)
Comment 9 Ondrej Brejla 2014-07-09 13:48:58 UTC
*** Bug 242762 has been marked as a duplicate of this bug. ***
Comment 10 Ondrej Brejla 2014-07-22 07:54:19 UTC
*** Bug 245143 has been marked as a duplicate of this bug. ***