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.
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.
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.
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
Many more issues with code completion and formatting in Blade templates were resolved as well. Learn more.
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.
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.
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.
If you rely on the magic methods
_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.
You can now specify union types as
@|MyClass in .phpstorm.meta.php – this can improve the coding assistance for mocks.
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:
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.
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.
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.
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.
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.
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.
We’ve also added a new Copy code snippet action to Markdown blocks, which will let you quickly copy their contents to the clipboard.
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.
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.
It’s now easier to work with suggested changes in PhpStorm as you can now apply or commit changes locally, right in the IDE.
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.
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.