What’s New in PhpStorm 2022.1

PhpStorm 2022.1 is a major update that brings support for multiline and nested array shapes, inplace Extract Method refactoring, enhanced support for Blade templates, WordPress, generics in PHP, and much more.

Multiline and nested array shapes

Array shape support in PHPDoc blocks have been supported since PhpStorm 2021.2. However, only single-line and single-level annotations were supported.

In PhpStorm 2022.1, we’ve added full support for multiline and nested array shapes in both PHPDoc and in #[ArrayShape] attribute!

Add array shape annotations to get the code completion for the keys and infer the value types in simple array data structures or object-like arrays. You can use both PHPDoc and Attribute syntax in PhpStorm, whichever you prefer. The syntax is supported for return types and parameter types.

Inplace Extract Method refactoring

Extract Method is one of the most used refactorings in PhpStorm. In order to simplify code and create a new method, just select the piece of code and press ⌘⌥M (Cmd+Alt+M / Ctrl+Alt+M).

Previously, this would open a dialog for the refactoring configuration. No one likes pop-ups though, so now, in many cases, for extracting a method you can use the inplace refactoring instead.

There will be no dialog, and a new method (or function) will be created right away in the editor. The cursor will be active to edit the name of the new method.

Enhanced support for Laravel Blade templates

Previously, PhpStorm treated every code block in Blade templates as an independent scope. This often caused issues with code completions and insights.

In PhpStorm 2022.1, we significantly reworked how the IDE handles Blade templates. As a result, you’ll get way better code completion in your .blade.php files.

Many more issues with code completion and formatting in Blade templates were resolved as well. Learn more.

Improvements for WordPress

Support for dynamic paths with `get_template_directory_uri()`

In PhpStorm, you can ⌘+Click (Ctrl+Click) on file paths to open the corresponding files in the editor. That didn’t work for dynamic paths in WordPress code when the path was compounded with WordPress functions.

In this release, we are adding support for the get_template_directory_uri() function in paths. More functions to be supported in the next updates.

Jump from hook invocation to registrations

The WordPress hook system is powerful, but it was not possible to jump from where a hook was called to where the handler is declared.

Now there is a gutter icon to the left of an invocation. Click it to see the list of hook usages, including registration and other invocations.

New advanced PHP metadata capabilities

As you may know, besides having built-in “code awareness” capabilities, PhpStorm also has external knowledge of code. This knowledge comes in the form the .phpstorm.meta.php file. You can use it to teach PhpStorm more information about the codebase, resulting in improved completion.

Support to magic __call and __callStatic

If you rely on the magic methods _call or _callStatic, then you would lose code completion for the methods, as they are not defined.

In this release, you can add the corresponding metadata entry and get autocompletion for such calls.

You can even automatically handle dynamic calls, receiving a specific method name from a parameter value.

Support union types

You can now specify union types as @|MyClass in .phpstorm.meta.php – this can improve the coding assistance for mocks.

Learn more about other metadata features in the documentation.

Improved annotations support and generics

We continue to improve our support for annotation-based generics in PhpStorm. In this release, we covered a few more cases, including, but not limited to:

  • @psalm-import-type, @phpstan-import-type
  • @psalm-trace, @phpstan-trace
  • Generics in @method tags

New Composer Project wizard

In PhpStorm 2022.1, when creating a new empty project, you have the option to automatically generate a composer.json file for it and provide the desired dependencies. After the project is created, PhpStorm will prompt you to install them.

User Experience

New Notifications tool window

We replaced the Event Log instanсe with a new Notifications tool window. It helps you maintain a better overview of the IDE notifications and reduces the chance of missing anything important. By default, the new tool window is located in the bottom-right corner of the IDE window. All notifications come in two categories: Suggestions and Timeline.

Updated Structural Search and Replace dialog

Invoke Structural Search and Replace from the main menu Edit | Find | Search Structurally

We’ve redesigned the Structural Search and Replace dialog to feature a list of all the templates to make it easier to navigate through them.

We’ve also added a Pin Dialog icon in the upper right corner of the Structural Search and Replace dialog.

Evenly split tabs

You can now evenly distribute the working space among editor tabs to have the same width. Enable Settings / Preferences | Advanced Settings | Editor Tabs | Equalize proportions in nested splits.

Export UML diagram to other formats

It is now possible to export UML diagrams as yEd .graphml, JGraph .drawio, Graphviz .dot, Mermaid .md, Plantuml, and IntelliJ IDEA .uml files, which makes them compatible with third-party tools.

Improvements for Markdown

Run commands from Markdown files

README files often describe the steps needed for running an app and list the commands you need to use. PhpStorm 2022.1 will let you run those commands right from the markdown file – just click on the Run icon in the gutter to the left of the command.

Copy code snippet for Markdown

We’ve also added a new Copy code snippet action to Markdown blocks, which will let you quickly copy their contents to the clipboard.

Updated Markdown Editor Floating Toolbar

We’ve reworked the floating toolbar that appears on text selection, to make it easier to format Markdown files. In addition to the new design, the toolbar now lets you create lists and provides a menu for selecting header styles.

The toolbar is customizable, so you can fill it with the options you need most. Go to Settings / Preferences | Appearance & Behavior | Menus and Toolbars | Markdown Editor Floating Toolbar.


Updated Annotate with Git Blame

We’ve improved the functionality of Annotate with Git Blame to make investigating introduced changes easier. The IDE highlights the difference in the lines right in the editor when you hover on an annotation and opens the Git Log tool window when you click on it.

Suggested changes in pull request comments

It’s now easier to work with suggested changes in PhpStorm as you can now apply or commit changes locally, right in the IDE.

Updated Commit Details pane in Git tool window

The Commit Details pane now includes information about GPG signatures and build status. Previously, this data was shown only as a column in the Git log.

Git File History: new UI without index

The new UI for the Git File History tool window is now independent of the indexing process. The data is represented with a new interface even if the Log index is off.

These are the most important changes in the release. If you’d like a closer look at all the finer details and other cool enhancements we’ve implemented, check out the release announcement on the PhpStorm blog.