Files and code generation enhancements

Posted on by Anton Monakov

PhpStorm 2017.3 has a number of subtle, yet effective, enhancements to help you with your file and code generation.

PHP File templates

PhpStorm 2017.3 unifies the way you work with your PHP file templates. The New PHP Class dialog now picks your custom file templates too – in addition to the built-in Class, Interface, and Trait templates:

new-class-dialog

As a result, you get namespace auto-completion when creating a custom PHP class. In your template, you can make use of the ${NAMESPACE} variable, which will be substituted with the actual class namespace in the created file.

The include templates in PhpStorm 2017.3 now support the ${DATE}, ${TIME}, ${YEAR}, ${MONTH}, ${DAY}, ${HOUR} and ${MINUTE} variables.

Fields default visibility

To quickly initialize class fields in a constructor, PhpStorm provides you with the Initialize fields intention action. Prior to version 2017.3, all fields were generated as private. Now, you can bring this under control.

Navigate to Settings | Editor | Code Style | PHP. On the Code Generation tab, you will see the Fields Default Visibility option button, which allows you set the preferred visibility:

fields-default-visibility

This feature also works as part of the Change signature refactoring invoked on a constructor:

change-signature

If you select the Create and initialize class properties checkbox, class fields will be initialized according to the selected default visibility.

We hope you’re enjoying PhpStorm 2017.3. Stay tuned for more updates!

Your JetBrains PhpStorm Team
The Drive to Develop

Subscribe

Subscribe for updates