supersan
supersan

Reputation: 6181

Automatically generate classes in phpstorm?

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) {
    }
}

Upvotes: 1

Views: 1428

Answers (2)

DrafFter
DrafFter

Reputation: 481

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

Upvotes: 2

LazyOne
LazyOne

Reputation: 165501

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.

Upvotes: 0

Related Questions