19

I'm looking for a generate method from usage. IntelliJ supports extract, rename etc. But if i write, for instance, $this->new_method($a) i would like to quickly generate this method in the same class. Does this exist or maybe there is a plugin for it?

Thanks for any help

1 Answer 1

33
  1. Place cursor on non existing method
  2. Alt + Enter (or wait and click on light bulb)
  3. Choose Add method from submenu.

enter image description here

Sign up to request clarification or add additional context in comments.

9 Comments

Yes i found out that i had removed "method" from inspections as it introduces a lot of warnings in the IDE. Thanks four your help.
Is it possible to tell PhpStorm signature of method? This intention creates private method with that name, it is possible to make protected method?
@JayGridley Unfortunately such option is not yet implemented for @method (but available when doing similar for @property) -- youtrack.jetbrains.com/issue/WI-7192 (star/vote/comment to subscribe to get notified on progress). P.S. If you have "Shifter" plugin installed, you could use it to quickly iterate between private/public/protected -- faster that retyping it.
I am not able to get this Add method option in my phpstorm8 . Am i doing anything wrong ? Do i need to enable any setting ?
@maj So what menu do you get there on Alt+Enter? But in case if this option is available via separate intention, then please check if all options enabled in Settings | Intentions | PHP
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.