What’s New in PhpStorm 2018.1

Experience The Drive to Develop with the first major update for PhpStorm in 2018.

PHP Language

Inline function/method refactoring

Inline function/method refactoring

Using the method’s body in your code can sometimes be more practical than using the method itself, in which case you will need to replace the calls to the method with the actual method’s content. This can be tricky in some cases since you'll need to handle multiple function calls, maintain proper variables' scopes and default values, and reformat the resulting code. The new Inline refactoring will help you with all of the above.

Refactor your code to functional style

Refactor your code to functional style

To help you easily migrate your code between the imperative and functional coding styles, PhpStorm 2018.1 introduces several new inspections and quick fixes. These will convert loops into the array_map, array_filter and array_fill function calls, and vice versa. Only the equivalent transformations are performed, and the logic of your code does not change.

Configurable unchecked exceptions

Configurable unchecked exceptions

PhpStorm 2017.3 introduced a new exception analysis engine that can catch unhandled exceptions, detect missing @throws tags, and so on. To add the sometimes needed configurability, in PhpStorm 2018.1 we’ve added the list of exceptions to be excluded from analysis.

Tests

Creating class from test

Creating class from test

With TDD becoming more and more popular, the situations are pretty common, in which the test is already in place, but the covered class does not exist yet. To handle such situations, PhpStorm 2018.1 will help you generate a class together with the class methods from an existing test. PhpStorm will also take your PSR-0/PSR-4 structure into account to generate the target class and the class methods in their respective locations.

Codeception: code coverage

Codeception: code coverage

We’ve heard your requests for implementing code coverage for Codeception. It’s implemented in PhpStorm 2018.1, and it works exactly like PHPUnit coverage. You will see the coverage results in the Project view as well as in the code editor’s left gutter: the covered code lines will be indicated with the green markers, while the uncovered lines – with red markers.

HTTP Client

Assertions support

Assertions support

Working with responses in the HTTP client has been significantly enhanced, too. PhpStorm 2018.1 brings support for assertions and custom JavaScript (ECMAScript 5.1) code that you can run upon receiving an HTTP response. Since the response is treated as a JavaScript object, you can quickly get access to all its details. You can also create tests that will assert that the request returns what is actually expected. The test results will be displayed on the Test tab, allowing you to navigate to the originating request and re-run a test.

Simplified first start

Simplified first start

PhpStorm 2018.1 will help you jump-start the new HTTP client and migrate from the now-deprecated GUI-based REST client. Live Templates will allow you to quickly insert a request skeleton without much typing; the collection of the most frequently used requests will provide examples useful requests examples. The default HTTP request template is now non-empty and contains some clues for a quicker start, too.

Web Technologies Support

Reformat with Prettier

Reformat with Prettier

With the new Reformat with Prettier action (Alt-Shift-Cmd/Ctrl-P), you can now format the selected code, a file or a whole directory using Prettier. Note that Prettier should be installed as your project dependency or globally on your machine.

Create new Vue project

Create new Vue project

You can now create new Vue projects in WebStorm using Vue CLI. Install it by running npm install --g vue-cli, then press Create New Project – Vue.js on the IDE’s Welcome screen, and answer questions about the template and tools you want to use in your new project.

As usual, all the features and improvements of WebStorm are available in PhpStorm, either out of the box or with free plugins available in the repository. Other noteworthy web-related features include TypeScript 2.7 support and Surround with type guard quick-fix for unresolved properties, Extract Vue component intention, debugging React Native apps, new Node.js Debugger Console and other.

IDE Improvements

Partial commits in Git

Partial commits in Git

With the support for partial Git commits you can now commit only selected changes from the file. Use checkboxes in the diff view of the Commit Changes dialog to select chunks of code you want to commit. You can also add changed lines of code to a new changelist using actions on the editor gutter and then commit the changelist.

Database Tools

Improvements in Database tools

Database tools in PhpStorm have been improved thanks to our colleagues on the JetBrains DataGrip team:

  • Data editor SQL log
  • Now you can tell PhpStorm how to switch schemas: Automatic, Manual, Disabled
  • External schemas in Redshift and virtual schemas in Exasol

Other improvements:

  • Goto Symbol navigation improvements
  • Hierarchy checks for class aliases
  • Gutter icons for running tests
  • New Composer actions
  • Better @covers support
  • New Documentation UI
  • Better HiDPI support on multiple displays for Windows
  • Improved XDebug Profiler viewer
  • Reworked focus subsystem
  • Open Terminal in a specific folder
Learn about PhpStorm 2017.3

Editor-based REST client

New REST client interface

New REST client interface

With the new REST client, all the powers of the PhpStorm code editor are now available for your REST requests. Use code completion to assist you with composing a request, apply refactorings to it, store the request as part of the project and add it to VCS, execute the request, and examine server responses – all without leaving the code editor.

Support for environment variables

Support for environment variables

Define environment variables to hold the values specific for your working environment, for example, the names of your development and production hosts. When composing a REST request, you can substitute its part with a variable to keep a single request suitable for multiple purposes.

Compare your requests

Compare your requests

The diff viewer now handles server responses. If you want to see how your changes affect the response, simply execute a REST request several times. Then, pick a pair of results, invoke the diff viewer right from the code editor, and examine the differences.

PHP Language

Performance Improvements

Performance Improvements

We’ve been working hard on performance improvements in this release. As a result, typing latency in very complex PHP files has decreased significantly. We’ve examined typing latency in the mPDF main file, which is a 38k-line-long mix of PHP, JS, and HTML, and it is down by 75% in PhpStorm 2017.3!

Support of nullability in refactoring

Support for nullability in refactoring

PhpStorm 2017.3 brings nullability support introduced in PHP 7.1, which is now available for the Extract Interface and Change Signature refactorings. It will help you avoid omitting the type declaration, or providing the default null value for the function parameter when you really want to pass or return null. PhpStorm will now preserve nullability when you apply Extract Interface and will no longer signal an error when it detects a nullable type while applying Change Signature.

Improved code templates

Improved code templates

To simplify the creation of classes in namespaced code, the New PHP Class dialog now lets you select a custom PHP file template. Use the ${NAMESPACE} variable in your template and take advantage of namespace completion and PSR-0 / PSR-4 namespace detection as you create the class.
You can also specify the day, year, and month in any PHPDoc template, not just in file templates.

Bring exceptions under control

New Inspection: Unhandled Exception

Unhandled exception

The new Unhandled exception inspection reports exceptions that are neither enclosed in a try-catch block nor documented using a @throws tag. The inspection helps you find all the places in your code where thrown exceptions would lead to a Fatal Error. Accordingly, you can resolve such issues by using quick-fixes like Add @throws tag and Surround with try/catch.

Redundant/Superfluous @throws tag

Redundant @throws tag

Ever forget to update your PHPDoc after refactoring your code? We’ve added the new Redundant @throws tag inspection, and the corresponding Remove @throws tag and Update PHPDoc quick-fixes will now help you clean up your PHPDoc.

Redundant catch clause

Redundant catch clause

The new Redundant catch clause inspection and the corresponding Delete catch clause quick-fix will let you know when the exception you are trying to catch is actually never thrown and therefore your catch block is redundant.

Testing

Create new Codeception test

Create new Codeception and PHPSpec test

The Create New PHP Test dialog adds new templates for the Codeception Unit, Codeception Functional, and PHPSpec test types so you can create new Codeception and PHPSpec tests with more ease.

Test method generation

Test method generation

No more manual creation of test methods! Use the brand new method selector in the Create New PHP Test dialog instead. Simply select all or just a couple of class methods for which you’re going to provide tests, and PhpStorm will generate the test class and the test methods stubs for you. Templates for all supported frameworks are provided to cover your needs for generating project-specific code.

Rerun of PHPUnit test with specific dataset

Rerun of PHPUnit test with specific dataset

In PhpStorm 2017.3, you can rerun a failed PHPUnit test with specific dataset. If you have a test method that uses the data provider and only one of the data sets fails, you don’t have to re-run the entire test anymore. Simply choose a specific data set from the previous test run and Run/Debug it again.

Undefined PHPUnit data provider

Undefined PHPUnit data provider

PhpStorm 2017.3 introduces the Undefined PHPUnit data provider inspection, which indicates a @dataProvider method that’s not found in unit tests. You can then easily create the missing method by applying the suggested Create data provider quick-fix.

Twig support

Injections in Twig templates

Injections in Twig templates

We’ve implemented language injections for Twig custom tags and named blocks. You can inject a language into the named block or between custom tags. You can also create permanent injection rules.

Improved Twig formatting

Improved Twig formatting

PhpStorm 2017.3 brings improved Twig formatting that can now handle complex structures and provide correct indentation for them.

Web Technologies Support

Improvements in Vue.js support

Improvements in Vue.js support

This update brings lots of improvements to PhpStorm’s support for Vue.js! Code completion and navigation to the definition now work for Vue props, properties in the data object, computed properties, and methods. Closing curly braces are now added automatically in Vue templates. We've also added a collection of code snippets for Vue. These code templates can help you save time typing some frequently used blocks of code. With a new Vue file template, you can also create new components faster.

Better code completion and documentation for JavaScript

Better code completion and documentation for JavaScript

Code completion and parameter info for the standard JavaScript objects and methods and Web APIs has improved, as these features are now powered by the TypeScript declaration files. The documentation available via F1 now also includes a brief description for methods, which either comes from the bundled definition files or is fetched from MDN.

New Pull Member Up refactoring

New Pull Member Up refactoring

With the new refactoring you can now move class methods up the class hierarchy – from your current JavaScript or TypeScript class to its parent class or interface. Or if there’s no parent class yet, you can extract fields and methods to a superclass using the new Extract superclass refactoring.

As usual, all the features and improvements of WebStorm are available in PhpStorm, either out of the box or with free plugins available in the repository. Other noteworthy web-related features include Extract type alias and Extract interface refactorings in TypeScript, multiple JavaScript versions in a project, improved Jest integration, better support for CSS, Import code style from ESLint and TSLint and other.

Version Control

Version Control

Version control comes with the following changes:

  • Switch between branches preserves your workspace
  • Changelists can now be renamed in the Shelf tab
  • D'n'D between Shelf and Local Changes tabs

Database Tools

Improvements in Database tools

Database tools in PhpStorm have been improved thanks to our colleagues on the JetBrains DataGrip team:

  • Improved Database view
  • SQL generator
  • JOIN statement completion
  • SSH tunneling

Other improvements:

  • Redesigned Code Style|PHP settings page
  • New Composer Log
  • Improved PHPUnit Run configuration
  • Define visibility for initialize fields intention
Learn about PhpStorm 2017.2

Composer

New Composer Actions

New Composer actions

Now you can execute the actions Update Dependencies, Install Dependencies, Remove Dependencies, and Self-update directly from the IDE, without having to switch to the command line.

PhpStorm and Composer.json settings synchronization

PhpStorm and composer.json settings synchronization

Since composer.json contains the most up-to-date information about project, the synchronization of new settings between PhpStorm and composer.json ensures that PHP Language Level, PhpStorm Source and Test folders exactly match the project settings and structure specified in composer.json. This significantly simplifies project configuration in PhpStorm.

Global installation and easy project creation

Seamless work with composer global installation

Now you can use globally installed composer. PhpStorm detects whether you have it installed and simplifies project creation in case you do. You can also set globally installed composer for existing projects and make it default for all projects. All this will save you time that you spent on looking for the previously downloaded composer.phar or on downloading yet again composer.phar into the project.

PHP Runtime

Docker Compose

Docker Compose

PHP interpreter based on Docker Compose is now supported in PhpStorm. Now you don’t have to duplicate all settings, such as volumes, networks, environment variables, and others, from docker-compose.yml to PhpStorm. Docker Compose based interpreter includes all the familiar features of remote interpreters, so you can run/debug PHP code, and execute/debug PHPUnit, Codeception, Behat and PHPSpec tests.

Detection of enabled/disabled extensions from PHP interpreter

Detection of enabled/disabled extensions for PHP interpreter

In the previous PhpStorm release, we made it possible to configure which PHP extensions are used in the project. We’ve now added automatic detection of enabled/disabled extensions from the selected PHP interpreter. This will help you synchronize your project extension settings and extensions that are actually installed in your PHP distributive. The feature works for local PHP interpreters and for all types of remote ones as well.

Preserve state of Start Listening for PHP Debug Connection option

Preserve state of Start Listening for PHP Debug Connection option

In PhpStorm 2017.2, if you had Start Listening for PHP Debug Connection enabled in a project, the option will be restored on project reopening. This will help you avoid situations where debugging doesn’t work because you forgot to enable the option.

PHP Language Support

Reworked polymorphic types support

Reworked polymorphic types support

We’ve completely reworked support for polymorphic types, such as $this, static, self and parent. This fixes many related issues, for instance, missing type in chain call if a method has a double return type, lost type with new static() call if method from base class returns $this, returning self in traits not resolved correctly, and many others. In addition, we’ve improved support for composed traits.

Reworked polymorphic types support

Support of PHP 7.2 2017.2.1

PHP 7.2 is now in Beta and now you have a chance to experiment with the new version of PHP in PhpStorm. PhpStorm 2017.2.1 brings support for all the features of PHP 7.2, including a possibility for overriding of abstract methods, parameter type widening, trailing commas in list syntax, and object typehint.

Better Refactoring for PHP 7/ 7.1

Better refactoring for PHP 7/7.1

PhpStorm 2017.2 brings better refactoring for PHP 7/7.1. In particular, return types are now supported for the Change Signature refactoring, and the Extract Constant refactoring now allows you to use visibility level for constants.

$this highlighting

$this highlighting

In PhpStorm 2017.2, when you place your caret on $this, PhpStorm highlights all usages of this variable across the whole class. It can be extremely helpful as you can easily see all the usages of the variable.

New inspections

New inspections

PhpStorm 2017.2 bring new handy inspections, such as

  • Statement has empty body inspection
  • Usage of strict_types declaration for PHP 7 and higher
  • Method declaration of super class is incompatible with implemented interface
  • Short open tag usage inspection 2017.2.1

Testing

Automatic run of PHPUnit tests

Automatically run PHPUnit tests

In PhpStorm 2017.2, you can re-run PHPUnit tests automatically with a specified delay. Enable auto-run for a particular configuration, set the delay value, and your tests will be re-run automatically with that delay after you stop editing a file.

Unified Test Frameworks settings

Unified Test Frameworks settings

We continue to simplify and unify PhpStorm settings. In this small but pleasant update, PHPUnit, Behat, PHPSpec, and Codeception testing frameworks have a single settings page.

Improved PHP Formatting

New formatting options

New formatting options

PhpStorm 2017.2 brings new useful code style options:

  • Spaces around null coalescing operator
  • New formatter options for blank lines
  • New parenthesis options for if statements
  • Separate option for brace placement for closures
  • New Return type on new line option

Web Technologies Support

Support for webpack enhanced module resolution

Support for enhanced webpack module resolution

Coding assistance in JavaScript files now respects webpack module resolution. This means that now, if you’re using a complex webpack configuration with aliases and multiple modules, PhpStorm will properly resolve the import statements.

Import from ESLint

Import from ESLint

You can now import some ESLint code style rules to the IDE’s JavaScript code style settings. Reply ‘Yes’ when prompted about this in the .eslintrc file to apply the matched rules and make the IDE formatting more consistent with your ESLint configuration.

Rearrange code for JavaScript and TypeScript

Rearrange code for JavaScript and TypeScript

The new code style options allow you to configure how different blocks of code such as the constructor, fields and methods are ordered in your JavaScript and TypeScript classes. Call the Rearrange Code action or use it together with Reformat Code to make code more readable and consistent.

As usual, all the features and improvements of WebStorm are available in PhpStorm, either out of the box or with free plugins available in the repository. Other noteworthy web-related features include support for Angular Material, parameter hints and type info in TypeScript, move symbol refactoring, and other.

IDE Improvements

Version Control

Version control

Version control comes with the following changes:

  • Reverting and rewording commits
  • Formatting commit messages
  • Reworked Shelf
Find in Path

Find in Path improvements

The Preview panel in Find in Path now has a “gutter” – a left-side pane like that in the editor – with line numbers, navigation icons, and local change markers. In addition, search results from the same lines are now merged together.

Pause indexing

Pause indexing

The indexing process now can be paused, for instance, if you need your CPU power for an urgent task.

Database Tools

Improvements in Database tools

Improvements in database tools

Database tools in PhpStorm have been improved thanks to our colleagues on the JetBrains DataGrip team:

  • Several databases in one PostgreSQL data source
  • Get notified when a large query is finished
  • Transaction Control

Other improvements:

  • Unified settings for PHP frameworks
  • SSH-Agent support
  • Create new field/method actions for PHP UML diagrams
  • Better HiDPI support
  • Blade: support for @guest and @endguest2017.2.1
  • Navigation to an appropriate loop from break/continue2017.2.1