What’s New in PhpStorm 2020.1

Experience hyper-productivity with this major IDE update

Out-of-the-box composer.json support

Manage dependencies with ease: all the actions are now available right in the editor of a composer.json file.

Arrow Functions

Managing dependencies

We’ve deprecated the old Manage dependencies dialog because working with the packages from inside the composer.json file is a lot easier.

To add a new package, you can start typing its name in the require(-dev) section, or press Ctrl+Space, and choose the one you need from the suggestion list.

All the available versions of the specific package will be listed, too.

Create new composer.json file

Creating new composer.json file

When you start a new project, you can create a composer.json file using the template in the IDE. Right-click in the project tree and select New -> composer.json File.

Updating and installing packages

Updating and installing packages

If there’s a dependency that is specified in composer.json but has not yet been installed, PhpStorm will detect and highlight it.

Install it by pressing Alt+Enter and choosing Update package or Update all packages.

Navigation to files and folders

Navigating to files and folders

You can use Ctrl+Click on a package to have PhpStorm highlight the folder of that package under the vendor directory in the Project Tree. For files, this will open them in the editor.

The same Ctrl+Click, or Ctrl+B, trick works to open any link in composer.json in a browser.

Composing and running scripts

Composing and running scripts

Each entry in the scripts section has a play icon in the gutter that you can click to instantly run the script.

When adding a new script entry, autocompletion now supports script references, binary files from the vendor/bin directory, and any PHP files from your project source.

Code coverage with PCOV and PHPDBG

PSR-12

In addition to Xdebug, it is now possible to use either a lightweight PHP extension krakjoe/pcov or the built-in PHPDBG to generate coverage reports much faster.

You can create a Run configuration for tests. In the Run configurations settings, there is a dropdown to choose your preferred coverage driver: Xdebug, PCOV, or PHPDBG.

Select your preferred driver, click the Run with Coverage button in the main toolbar, and observe the coverage results.

PHPUnit toolbox

WSL adding interpreter

PhpStorm 2020.1 has tools to help you upgrade to the latest PHPUnit version quickly and easily.

Every deprecation will be highlighted in the editor. Put the cursor over a deprecated item and press Alt+Enter, then select your preferred quick-fix from the list that appears. Or just choose it at the bottom of the error description window.

To quickly create a new PHPUnit test class, you can now use the Create new PHP Test intention by pressing Alt+Enter on a class name.

PHP type inference improvements

The core of PhpStorm – the type inference engine – has received a few nice improvements.

Typed Properties

Detecting redundant @var tag

If the @var tag with type info is redundant and PhpStorm already knows the correct type of the variable, then this tag will be highlighted. You can delete it with the Remove @var quick-fix by pressing Alt+Enter.

Arrow Functions

Better tracking of null

Tracking nullability is a tough task, and there used to be some places where PhpStorm was unable to detect it. This is no longer the case for the 2020.1 version. PhpStorm lets you know whether a variable is null or not and helps you avoid nullability problems.

Numeric Literal Separator

Completion in array_map/filter

There is now a full completion option for parameter variables inside of the closures that are passed to array_map() and array_filter() functions.

Nested ternary operator

Infer a non-generic array type from an initializer

If you’re iterating over an array with a known set of items, you no longer need an additional @var tag to specify the type, as PhpStorm will propagate it automatically.

And even more

ML-assisted ranking for code completion

ML-assisted ranking for code completion

We introduced machine-learning-assisted ranking of completion options for PHP back in v2019.3. This feature improves code completion by reordering the elements in the completion popup so that the most relevant items are ranked higher.

By default, ML-assisted completion is disabled. To turn it on, select the checkboxes Rank completion suggestions based on Machine Learning and PHP under Preferences/Settings | Editor | General | Code Completion.

Move method refactoring

Move method refactoring

Moving a method from one class to another is now easier, as it can be done with a single atomic action.

Place the cursor over a method and press F6 (or Ctrl+T, 3). Then choose a destination class and you’re done.

Remove PHPDoc with just type annotation

Remove PHPDoc with just type annotation

If a PHPDoc block has only @param tags with types, then it can be completely removed in favor of native type declarations for parameters.

Press Alt+Enter and choose the Remove redundant PHPDoc comment quick-fix.

Find redundant ternary expressions

Find redundant ternary expressions

PhpStorm will highlight any ternary expressions that can be reduced and simplified. And by using a quick-fix (Alt+Enter), you can replace them with a simple equivalent expression.

Eliminate redundant pass-by-ref occurrences

Eliminate redundant pass-by-ref occurrences

Using pass-by-reference can lead to unexpected consequences. PhpStorm 2020.1 detects and highlights parameters that are unnecessarily marked as passed-by-reference.

The same works for redundant by-ref values in foreach loops.

Metadata

There is a way to extend PhpStorm’s “code awareness” by providing additional information in a special file, .phpstorm.meta.php. This area has received several improvements.

Parameter index in override, map, and type

Parameter index in override, map, and type

Previously, with override(), map(), and type() directives, it was possible to adjust the behavior only of the first parameter of the functions. In PhpStorm 2020.1 this has been fixed, and it is possible to specify the index of the parameter explicitly.

Arrow Functions

Support for property access via __get

If you had to receive some objects via the __get() magic method, then you would likely lose type information. Instead of using an @var or an @property tags, you can now specify this information in a .phpstorm.meta.php file. This can work even if the type is not known beforehand.

Custom exit points

Custom exit points

PhpStorm considers the die() and exit() functions, or any functions throwing an exception, to be terminating calls. But in applications, there may be some other custom functions that have to be considered as “exit points”, for example, in debugging functions like dd(). It is now possible to mark any function as an exit point.

Completion for keys in ArrayAccess objects

Completion for keys in ArrayAccess objects

Metadata assistance already made it possible to retain access to code completion even if you wanted to use an object as an array container for other objects. However, the completion was not available for keys. This has been added in 2020.1.

Gutter icon for functions with meta overrides

Gutter icon for functions with meta overrides

Last but not least, in the editor you will now see if a behavior has been modified by the .phpstorm.meta.php file with override(), exitPoint(), or expectArguments() directives. And since there can be any number of such metafiles in the project, by clicking the icon, you will open the one that is used in this specific place.

HTTP Client

PHP Debug in HTTP Client

PHP Debug in HTTP Client

When developing web applications or API endpoints, you can now easily start debugging without leaving the PhpStorm window.

To do this, create or open an .http file, add a request, and then use the Alt+Enter intention to run PHP Debug. This will add an XDEBUG_SESSION cookie to the request, and it works similarly to the Xdebug browser extension.

Web Technologies

All the new features and improvements of WebStorm 2020.1 are available in PhpStorm 2020.1, either out of the box or with free plugins available in the Plugin Marketplace.

New smart intentions and inspections for JavaScript and TypeScript

New smart intentions and inspections for JavaScript and TypeScript

Use new smart intentions and inspections (Alt+Enter) to save yourself some time when coding! For example, you can now quickly convert the existing code to optional chaining and/or nullish coalescing, the syntax introduced in the latest versions of JavaScript and TypeScript.

Vuex and Composition API support for Vue.js

Vuex and Composition API support for Vue.js

With out-of-the-box support for the Vuex library and the Composition API from the upcoming Vue 3, you can build great Vue.js applications even more smoothly.

Running Prettier on save

Running Prettier on save

With the new Run on save for files option, WebStorm will apply Prettier formatting to all files specified in the IDE settings and edited in the project as soon as you save those files – a file watcher or a third-party plugin is no longer needed.

IDE

Smart Grammar and Spell Checker

Smart Grammar and Spell Checker

The advanced proofreading and grammar check plugin Grazie is now available out of the box. Get instant highlighting for typos and mistakes and fix them with a quick-fix action, just like any other errors in code.

Spell checking is enabled by default in markdown files. To get checks in any PHPDoc comments, HEREDOC/NOWDOC strings, or string literals in PHP files, you’ll need to enable it under Preferences/Settings | Editor | Proofreading | Grammar.

In order to get even more profound grammar checks, you can enable Grammar inspection under Preferences/Settings | Editor | Inspections -> Proofreading.

Using PhpStorm for quick editing

Using PhpStorm for quick editing

A new LightEdit mode makes it possible to use PhpStorm as a notepad-style light editor to make some quick changes in files without having to open the IDE completely.

To try it, open a file from the command line (see Working with IDE features from command line for more instructions) or from your OS system file manager. And if PhpStorm is not already running, then the file will be opened in LightEdit mode.

Date format customization

Split terminal sessions horizontally or vertically

It is now possible to open any number of terminal sessions at once and observe the output on all of them simultaneously without switching between tabs.

You can invoke the context menu from the Terminal to create, navigate, and close a split terminal session.

Unified SSH configuration

Unified SSH configuration

All SSH connections have now been brought into a single place under Preferences/Settings | Tools | SSH Configurations.

This makes it possible to create a connection in one place and then reuse it anywhere in the IDE, for example, in the deployment configuration, for remote PHP interpreter via SSH, or as an SSH terminal.

Appearance

Updated light theme

Updated light theme

The light theme is now unified for all operating systems and goes by the name IntelliJ Light. If you’d like to go back to the old theme, you can switch under Preferences/Settings | Appearance & Behavior | Appearance | Theme.

Date format customization

New default font

JetBrains Mono is a free and open-source typeface we have developed specially for developers to make reading code easier. And it is now used as the default editor font.

Zero-distraction development mode

Zero-distraction development mode

The new Zen Mode combines the Distraction Free Mode with the Full Screen Mode, so that you can dive deep into your code.

To try Zen Mode, go to View | Appearance | Enter Zen Mode.

Version Control

Reworked dialog for Git Rebase

Reworked dialog for Git Rebase

The Interactively Rebase from Here dialog is now truly interactive and makes it possible to control every aspect of the rebase process:

  • Select an action you want to perform on each commit in your branch.
  • Check a graph showing which actions have been applied.
  • View the commit details.
  • See a diff, and review or reset the changes if necessary.
Push any branch

Changes to the commit flow

In order to streamline the commit flow, we’ve developed a new Commit tool window for handling all commit-related tasks. It is enabled for all new users by default.

If you’re an existing user and want to give it a try, select Use non-modal commit interface in Preferences/Settings | Version Control | Commit.

Database Tools

The DataGrip team has made some really cool improvements to the database tools in PhpStorm. Take a look at What’s new in DataGrip 2020.1.

Export to Excel

Export to Excel

Finally, it is possible to export a query result or a table to Excel file.

In-editor results

In-editor results

Now you can see the results right in the code editor. To try out this feature, check the Preferences/Settings | Database | General | Show output results in the editor option.

Run configurations

Run configurations

The concept of Run configurations is quite familiar to PhpStorm users. In addition to running PHP scripts, Tests, or HTTP requests, it is now possible to execute DB queries too.

Other Improvements:

  • All members and items marked as @deprecated are displayed as strikethrough in the Structure tree view.
  • There is a new action to quickly jump to the closing or opening brace.
  • Lexer Syntax for Twig can now be customized.
  • The Config files path has changed – learn more.
  • Run configurations can be saved outside of the .idea folder and shared via version control. Open the Run/Debug Configurations dialog, check Store as project file option.