Tutorial: Find usages of implemented and overridden PHP methods
In the PHP context, IntelliJ IDEA applies the Find Usages functionality to implemented and overridden methods. Let's consider the following example:
-
Create an interface, an abstract class that implements it, and two classes that extend the abstract class, organized as follows:
-
An interface
MyInterfacewith afoo()method. -
An abstract class
MyAbstractClassthat implementsMyInterface. -
A class
MyClassthat extendsMyAbstractClass, implementsfoo()required by the interface, and overrides the methods of the parent class. -
A class
MyClassWithDelegatethat extendsMyClassand implementsfoo()with a delegate. -
The
$band$cvariables that callfoo()fromMyClassandMyClassWithDelegaterespectively:
<?php interface MyInterface { //press Alt-F7 on foo() here public function foo(); } abstract class MyAbstractClass implements MyInterface { public function foo () { // TODO: Implement foo() method. } } class MyClass extends MyAbstractClass { public function foo() { parent::foo(); } } class MyClassWithDelegate extends MyClass { public function foo() { foo(); } } $b = new MyClass(); $b->foo(); $c = new MyClassWithDelegate(); $c->foo(); -
-
From
MyInterface, invoke Find Usages Settings forfoo()by pressing Ctrl+Alt+Shift+F7 or choosing from the main menu. -
In the Find Usages. Method Options dialog that opens, select the Include overriding/implementing methods checkbox and click Find.
-
IntelliJ IDEA will find the methods that implement or override the base method and display them in the Find tool window:
