问题
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.
回答1:
From my comment: You could try ALT + ENTER. This normaly shows up a small "dialog" to autogenerate phpdoc, functions, etc.
回答2:
Sure, you can.
There are 3 ways to do it :
- Press
Ctrl + I
- On main menu, click
Code --> Implement Methods
- 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.
来源:https://stackoverflow.com/questions/28052463/how-to-auto-generate-methods-of-the-implemented-interface