PhpStorm 2022.1 Is Now Available

What's new in PhpStorm 2022.1

This new major PhpStorm release includes improved Blade and Twig support, added functionality to docblock type annotations and attributes, a bunch of new and useful inspections, several improvements to the editor, and more.

You can download PhpStorm 2022.1 here and read through this post to learn about all the new features and improvements inside. Let’s dive in!

What’s new?

Frameworks and languages


Static analysis


Improvements for Blade templates

Previously, PhpStorm treated every code block in Blade templates as an independent scope. It caused many issues, such as losing code completion:

In PhpStorm 2022.1, we’ve significantly reworked how the IDE handles Blade templates. As the result, you’ll get much better code completion in your Blade files:

Namespace imports with autocompletion

You can now also import namespaces in your blade files, instead of always having to use FQCNs:

Many other issues with code completion and formatting in Blade templates were resolved as well, including:

  • WI-37741 AutoCompletion of PHP Variables in Blade
  • WI-64460 Blade: missing completion for methods inside tags if there is php block ()
  • WI-64463 Blade: two consecutive @php fragments are merged together and produce “expected: expression” warning
  • WI-31196 Blade: wrong formatting with HTML comments
  • WI-28285 Blade doesn’t indent nested statements when formatting
  • WI-25667 Blade: formatting blocks are not aligning if there is a HTML comment after a closing tag
  • WI-40358 Blade: @section inside @if block throws “Directive is not closed”
  • WI-64594 Blade: support @js directive
  • WI-65562 Blade: support @checked, @disabled, @selected, @prependonce, @pushonce directives

You can see the full list of fixed issues in our issue tracker.

We plan to continue improving our Blade template engine support.

Improvements for Twig templates

Just like Blade, we have also been improving our Twig support. Some users prefer their Twig tags not to be closed automatically after typing {%. This behavior is now configurable under Preferences | Editor | General | Smart Keys | Twig.

Opening and closing tags will be also edited simultaneously now when you update them from {% to {{ or vice versa.

Improvements for WordPress

Jump from hook invocation to registrations

The WordPress hook system is powerful, but it relies on the string names of events (actions). Because of that, it was not possible to jump straight from where a hook is called to where the handler is declared.

In PhpStorm 2022.1, there is a gutter icon on the left of invocation. Click it to see the list of hook usages, including the registration and other invocations.

Support for dynamic paths with get_template_directory_uri()

In PhpStorm, you can use ⌘+Click (Ctrl+Click) on file paths to open the corresponding files in the editor.

Previously, this behavior didn’t work for dynamic paths in WordPress code when the path was compounded using WordPress functions.

In this release, we are adding support for get_template_directory_uri() function in paths.

Inplace Extract Method refactoring

Extract Method refactoring has been available in PhpStorm since 2011. It is one of the most used refactorings. We’ve already made quite a few improvements for it in PhpStorm 2021.3.

To use this refactoring, you can select a piece of code and press ⌘⌥M (Cmd+Alt+M / Ctrl+Alt+M).

Previously, this would open a dialog for refactoring configuration. No one likes pop-ups, though, so in PhpStorm 2022.1, an in-place refactoring will be available instead in many cases where a method is being extracted.

There won’t be any dialog. Instead, a new method (or function) will be created right away in the editor. You can edit the name straight away, and press enter when you’re done.

You can still open the dialog and adjust the refactoring settings by clicking on the gear icon.

Multiline and nested array shapes

In PhpStorm 2021.2, we introduced support for array shapes in PHPDoc blocks. But this came with a significant limitation – only single-line and single-level annotations were supported.

To get multiline support, you had the option of using the #[ArrayShape] attribute. However, this still had no support for nested structures.

In PhpStorm 2022.1, we’ve added full support for multiline and nested array shapes in both PHPDoc and attributes!

While PHP has a great object system, there are times when defining a real class can feel excessive and it would be more convenient to work with simple data structures or object-like arrays.

In such cases, you need to define the structure of arrays with array shape annotations to get the code completion for the keys and infer the value types.

You can use both PHPDoc and attribute syntax in PhpStorm, whichever you prefer. The syntax is supported for return types and parameters type definitions. Here is an example of attribute syntax:

Along with the multiline and nested annotations support, there are many additional improvements for array shapes in PHPStorm 2022.1, including:

Support for array shapes with numeric keys:

Support for specific arrays in object-like arrays:

Support for lists in array shapes:

Support for @var array shape annotations of variable usages:

Improved annotation support

We’ve continued to improve support for type annotations in PhpStorm. In the upcoming release, we covered a few more annotations:

Generics in @method annotations

PhpStorm 2022.1 supports generic types in @method definitions:

Support for generics in @method tags is especially useful when extending generic classes provided by, for example, frameworks, and when you want to specify the types of methods without having to manually reimplement them:

New advanced PHP metadata capabilities

As you may know, in addition to its built-in “code awareness” capabilities, PhpStorm also has reliable external knowledge of code. This knowledge comes in the form of PHP stubs and the .phpstorm.meta.php file. As a user, you have access to this file, allowing you to make project-level changes to how PhpStorm, for example, understands vendor code – code that you’d otherwise have no access to.

Support to magic __call and __callStatic

If your code relies on the magic methods __call or __callStatic, then you may not have 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 @|MyClass type

You can now specify union types as @|MyClass – this can improve coding assistance for mocks.

You can learn more about our other metadata features in the documentation.

New inspections

With each release, we try to add new inspections to help you prevent bugs in your code early, before you commit. You can manage and configure these inspections under Preferences | Editor | Inspections.

Some of the inspections, however, might not be relevant to you. Now you can simply disable them by pressing Alt+Enter on the highlighted code and choosing Disable inspection under the inspection name.

If you ever come across an inspection that you think can be improved, don’t hesitate to submit an issue in YouTrack, we’re happy to help!

Let’s take a look at some of the notable new inspections we’ve added in v2022.1.

Duplicate array key

The behavior of array_merge() and merging with the + operator is different in PHP. The latter will not override the value if the key is duplicated. That could lead to confusion and bugs, so PhpStorm will highlight such cases.

Usage of count($array) as array index

To append an item to an array, there is no need to explicitly specify the index. PhpStorm is able to warn you about the redundant count() call.

Replace pow() call with **

PHP has had an exponentiation operator ** available since version 5.6. PhpStorm will not highlight pow() usages, but it will show you a handy quick-fix (Alt+Enter) to replace the old pow() calls with the ** operator.

Property can be declared readonly

Private properties with read-only access inside a class can be declared with the readonly flag. Use the Alt+Enter quick-fix to update the property declaration.

Class constant can be final

Starting with PHP 8.1, it is possible to declare constants as final. This is why PhpStorm allows you to add a final modificator to constants that are not inherited (just use Alt+Enter).

rand function arguments in reverse order

This inspection highlights function calls from the rand family where the max argument is less than the min. For example, calling rand(10, 1) is the same as calling rand(1, 10), but mt_rand() is strict about the order of its arguments.

Invalid mocking target with PHPUnit

PhpStorm will warn you when you try to access a private or final method on a mock object.

Redundant modifier

This new inspection will report the modifiers that are used in regular expression patterns but do not affect the match:

  • /i (case insensitivity) in patterns that contain no letters.
  • /D (PCRE_DOLLAR_ENDONLY) in patterns that contain no dollar sign, or containing the \m (PCRE_MULTILINE) modifier.
  • /s (dot matches line breaks) in patterns that contain no dots.

Unsupported modifier

This inspection will report the usages of the /e modifier, which is deprecated in PHP 7.0 and later.

Markdown editor improvements

Run commands from Markdown files

README files often describe steps for running an app, listing the commands that need to be used. 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.

The new option can be managed via Detect commands that can be run right from Markdown files in Preferences / Settings | Languages & Frameworks | Markdown. It’s also worth noting that this feature currently only supports a limited number of commands like bash and npm. We’ll add php and composer support in the future.

Copy code snippet for Markdown

We 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

To make it easier to format Markdown files, we’ve reworked the floating toolbar that appears when text is selected. 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 add the options you use most. To do so, go to Settings / Preferences | Appearance & Behavior | Menus and Toolbars | Markdown Editor Floating Toolbar.

Improvements to VCS integration

This release of PhpStorm also features a bunch of improvements that came with IntelliJ IDEA 2022.1.

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 between lines right in the editor when you hover over an annotation and opens the Git Log tool window when you click on it.

Updated Commit Details in Git tool window

The Commit Details now include information about GPG signatures and the 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 from the indexing process. The data is represented with a new interface, even if the Log index is off.

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 in the IDE.

Define external diff and merge tools by file media type

PhpStorm 2022.1 now allows specifying different external diff and merge tools based on the file type. To configure them, go to Settings / Preferences | Tools | Diff & Merge | External Diff Tools.

User Experience

Updated Structural Search and Replace dialog

Structural Search and Replace, or simply SSR, allows code-aware searches. For example, you can find classes that were inherited from a certain base class via a class’ intermediate ancestor. That’s something you could not achieve easily with grep, but you can with SSR. You can see SSR in action in this video if you want to take a closer look at what is possible with SSR.

In PhpStorm 2022.1, we’ve redesigned the Structural Search and Replace dialog to feature a list of all templates to make it easier to navigate between them.

Also, we’ve added a Pin Dialog icon in the upper right corner of the Structural Search and Replace dialog and moved the Injected code and Match case checkboxes to the bottom of the Search template pane.

HTTP Client: Run requests with one click

When developing APIs, it’s super convenient to test endpoints with the built-in HTTP Client in PhpStorm.

Previously you could place the cursor over the endpoint in an .http file and use an intention (Alt+Enter) to run PHP Debug. This would add an XDEBUG_SESSION cookie to the request. However, you had to go through the submenu every time.

In this release, the gutter icon will be updated according to the last chosen option. This way you can debug endpoints in one click.

New Notifications tool window

We replaced the Event Log instanсe with a new Notifications tool window. We hope it helps you maintain a better overview of the notifications from the IDE so you don’t miss anything important.

By default, the new tool window is located in the bottom-right corner of the IDE window. All notifications that appear in it can be divided into two categories: Suggestions and Timeline. Here’s an example of what the Notifications tool window will look like:


We will continue working on the Notifications tool window to enhance the overall workflow of receiving and managing suggestions, warnings, reports, and other helpful messages.

Evenly split tabs

You can now evenly distribute the working space among editor tabs so that they are the same width. To set this up, go to Settings / Preferences | Advanced Settings | Editor Tabs | Equalize proportions in nested splits.

Hidden tab labels in Debugger

To maximize the usable space in the Debug tool window, we’ve hidden the tab labels by default. To make them visible again or to customize their location, use the Show Tab Labels option in the Layout Settings or call it via Search Everywhere (⇧⇧ on macOS / Shift+Shift on Windows/Linux) with the Debug tool window in focus.

Improvements for Docker

New Services view UI

We’ve reworked Docker’s UI in the Services tool window. The makeover has been implemented for containers, images, networks, and volumes.

Docker Registry V2 support

We’ve added support for Docker Registry HTTP API V2 to use with Docker 1.6+. You can create simple or password-protected Docker V2 registries and perform the usual actions like viewing, pushing, and pulling images.

Code reformatting in LightEdit mode

In LightEdit mode, you can quickly edit files without creating or loading the whole project. It is also now possible to reformat your code while in LightEdit mode. To do this, go to Code | Reformat Code in the main menu or press ⌥⌘L / Ctrl+Alt+L.

New Composer Project wizard

We’ve enhanced the New Project wizard. Now, when you are creating a new empty project, you can choose 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.

Improvements to Vue

PhpStorm incorporates all the improvements for HTML/CSS/JS and other web technologies from WebStorm.

The 2022.1 version of JetBrains’ IDE comes with several improvements to Vue 3. In this version, if you define components as global, the IDE will recognize them in your .vue files. PhpStorm will also properly support the createApp syntax. It will correctly match applications created using createApp with their related elements.


This version also includes support for Nuxt 3, a new version of the popular Vue framework.

Remote development updates

Remote development is a feature that allows you to run your IDE on a remote server, and connect to it using a thin client instead of having to run the whole IDE on your local machine. This release of PhpStorm also includes a couple of new remote development features.

The most notable feature is the Backend Control Center widget, which shows CPU load, memory, disk capacity, and other parameters you may need to monitor the backend status.

WebDAV support

In this release, we are introducing support for using WebDAV servers for deployment. To configure a new server, go to Preferences | Build, Execution, Deployment | Deployment, add a new server of the WebDAV type, and provide the connection parameters:

Overriding Rsync command-line parameters

In PhpStorm 2021.3, we’ve introduced Rsync for SFTP support to provide significantly faster deployments. The Rsync tool was executed with the -zar command-line options so that it would compress the transferred data (z), preserve permissions, ownership, and timestamps of transferred files and folders (a), and recurse into subdirectories (r).

In this release, the options can be customized. Go to Settings / Preferences | Tools | Rsync and provide the required set of options:

The full list of changes in PhpStorm 2022.1 is available on the release notes page.

That’s all for today. Thanks for keeping up with the changes! We hope they improve your PhpStorm experience.

Your JetBrains PhpStorm team
The Drive to Develop

image description