1

It is easy to generate undefined methods in PHPstorm for classes by pressing Alt+Enter over an undefined method.

https://i.sstatic.net/qCk9S.jpg

But is there a way to generate Classes also?

Lets say I have this code

    $x = new Person('String', 'String');

But Person is not defined so far.

Is there a way to press Alt+Space on Person so that PHPstorm automatically creates a Person.php class with the following constructor?

<?php

Class Person {
    public function __construct($string, $string) {
    }
}

2 Answers 2

2

In PhpStorm functionality was added to version 9.x (edited again, thanks @LazyOne)

With your caret over the missing class name, simply press Alt+Enter to fire the “quick fix” menu, then select Create class to open the Create New Class dialog

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

3 Comments

I am sure it was at least since version 7.
@matiit Sorry, but you are wrong. Accordingly to the actual ticket (in my answer) it was added only in v9 -- otherwise you would not see all those "when it will be added" comments in 2015...
Ok, I am pretty sure that this answer was talking about version 10 at the time I was leaving my comment :)
0

Quick Fix (a.k.a. Alt + Enter) does not support creation of missing classes this way yet.

http://youtrack.jetbrains.com/issue/WI-6148 -- subscribe to the ticket (star/vote/comment) to get notified on progress.

Comments

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.