Tutorial: Find usages of implemented and overridden PHP methods
In the PHP context, PhpStorm 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
MyInterface
with afoo()
method.An abstract class
MyAbstractClass
that implementsMyInterface
.A class
MyClass
that extendsMyAbstractClass
, implementsfoo()
required by the interface, and overrides the methods of the parent class.A class
MyClassWithDelegate
that extendsMyClass
and implementsfoo()
with a delegate.The
$b
and$c
variables that callfoo()
fromMyClass
andMyClassWithDelegate
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(); } } 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 settings dialog that opens, select the Include overriding/implementing methods checkbox and click Find.
PhpStorm will find the methods that implement or override the base method and display them in the Find tool window: