PhpStorm 2022.1 is now available
Newsletter Releases 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 PHP Static analysis IDE 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. 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 […]
