IntelliJ IDEA 2018.3 Help

Tutorial: Finding 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:

  1. Create an interface, an abstract class that implements it, and two classes that extend the abstract class:

    1. Create an interface MyInterface with a foo() method.

    2. Create an abstract class MyAbstractClass that implements MyInterface.

    3. Create a class MyClass that extends MyAbstractClass and implement the foo() method required by the interface and overrides the methods of the parent class.

    4. Create a class MyClassWithDelegate that extends MyClass and implement foo() with a delegate.

    5. Create variables $b and $c that call foo() from MyClass and MyClassWithDelegate respectively:

    <?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(); // TODO: Change the automatically generated stub echo "foo"; } } class MyClassWithDelegate extends MyClass { public function foo() { foo(); } } $b = new MyClass(); $b->foo(); $c = new MyClassWithDelegate(); $c->foo();

  2. From MyInterface, invoke Find Usages for foo() by pressing Alt+F7 or choosing Edit | Find | Find Usages on the main menu. By default, IntelliJ IDEA shows only the delegates to the super method and method calls:

    find usages without overridden

  3. To additionally find the methods that implement or override the base method, click Gear icon in the Find tool window. Then in the Find Usages. Method Options dialog that opens, select the Include overloaded methods checkbox and click Find. As a result, all the usages of the foo() method are found in all the classes that implement or extend MyInterface:

    find usages with overridden

Last modified: 1 February 2019