How to auto-generate methods of the implemented interface
Asked Answered
Q

2

6

Is there a way in PhpStorm to automatically generate the empty methods that are required by the interface the given class is implementing?

Say we have an Interface with 3 methods - when defining the new class that implements this interface - some option to auto-generate containers for all required methods.

Quotha answered 20/1, 2015 at 18:19 Comment(0)
I
14

From my comment: You could try ALT + ENTER. This normaly shows up a small "dialog" to autogenerate phpdoc, functions, etc.

Indentation answered 20/1, 2015 at 19:11 Comment(1)
Just to highlight - I'm on Mac and it's Ctrl + Enter - then select Implement Methods. Thanks again.Quotha
G
16

Sure, you can.

There are 3 ways to do it :

  1. Press
    Ctrl + I
  2. On main menu, click
    Code --> Implement Methods
  3. On the code editor, press right click on your mouse, then click
    Generate --> Implement Methods

After that, you can select one or some method(s), then click OK.

Gizmo answered 11/3, 2015 at 2:44 Comment(2)
If you're implementing an interface, you're required to implement every method, so why would you only select some methods?Coptic
abstract classesScum
I
14

From my comment: You could try ALT + ENTER. This normaly shows up a small "dialog" to autogenerate phpdoc, functions, etc.

Indentation answered 20/1, 2015 at 19:11 Comment(1)
Just to highlight - I'm on Mac and it's Ctrl + Enter - then select Implement Methods. Thanks again.Quotha

© 2022 - 2024 — McMap. All rights reserved.