PhpStorm 2021.3 Early Access Program Is Open
Today we’re starting the Early Access Program (EAP) for PhpStorm 2021.3.
The third major release of PhpStorm this year will bring full support for all PHP 8.1 features, more enhancements for generics, rsync support, other improvements for deployment, a bunch of new inspections, improved refactorings, and a whole lot more.
Join the Early Access Program to be among the first to try out the updates, share your feedback, and influence the development of PhpStorm.
Along with the build, every week we will publish a post with a story about new features and changes every week. Follow us on Twitter at @phpstorm and be among the first to get each new post.
With that said, let’s take a look at the first portion of the updates in the upcoming 2021.3 release.
We started to roll out support for PHP 8.1 back in the last major release – PhpStorm 2021.2 came with full support for enums. Here you can read up on how to use enums in PhpStorm.
The PHP 8.1 RC 2 has been shipped, so the list of changes is now final. Let’s go through the features that await you in the upcoming version of PhpStorm.
As usual, you can try new features by setting the project language level to PHP 8.1. You can switch from the toolbar or by specifying the requirement in composer.json.
Readonly properties are properties that cannot be changed after initialization, i.e. after a value is assigned to them.
You could achieve similar behavior in previous versions of PHP with a private setter, but the readonly keyword makes classes cleaner and constraints stricter.
A readonly property can be initialized only in the same scope where it’s declared. This means you can assign a value either in the declaration itself or in a class method.
Properties with the readonly flag must be typed, but if you don’t know the specific type then you can use the mixed type.
If a readonly property is initialized by an object, it does not become immutable. That is, its internal state can still be changed.
A readonly property cannot have a default value, but you can initialize it in the constructor as a promoted property. PhpStorm has an Alt+Enter quick-fix for this:
Pure intersection types
Union types were added in PHP 8.0, and now PHP 8.1 is introducing intersection types.
The syntax is TypeA&TypeB, and it means that the variable must be both instanceof TypeA and instanceof TypeB.
In PhpStorm 2021.3, code completion for this will be pretty much the same as it is for union types, because a union can contain members of all involved types, and an intersection must contain members of all types.
The feature is called pure intersection types because combinations with union types are not supported and are being left for future consideration. PhpStorm 2021.3 will check the syntax:
In older PHP versions it was quite common to use intersection types in PHPDoc annotations. Those will also be supported in PhpStorm 2021.3, and if you decide to upgrade to PHP 8.1, you can add a native type declaration:
New return type: `never`
In PHP 8.1 a new type for return values will be available: never.
A function or method declared with the never type indicates that it will not return a value and will either throw an exception or end the script’s execution with a call of die(), exit(), trigger_error(), or something similar.
This type improves code analysis, and it’s pretty much the same thing that the #[NoReturn] attribute has been doing in PhpStorm. It’s great that this is a language feature now!
In PHP 8.1 it will be possible to declare final class constants, so that they cannot be overridden in child classes.
Note that in PHP 8.0 and earlier versions, constants in interfaces were implicitly final and you could not directly change them. But in PHP 8.1, they are not final by default.
There are plenty of other changes in the upcoming PHP 8.1. PhpStorm 2021.3 will support them all and will help make your code compatible. Stay tuned for updates.
More for generics
In PhpStorm 2021.2, we added long-awaited support for generics. It covered basic use cases, but there’s still work to be done. Thank you for your feedback and tickets in the tracker!
Here’s what’s in the upcoming batch of enhancements for generics:
Improved support for Doctrine Collections
We’ve added support for the IteratorAggregate interface in @template annotations.
As a result, iterating over Doctrine Collections now works out of the box!
Support for future Laravel collections
In the upcoming Laravel release, the illuminate/collections package is getting generics annotations. With PhpStorm 2021.3, you’ll get a better completion for them too.
Infer generic types from constructor
Let’s say there is a generic @template parameter in a constructor, and you want to specify the type by passing an object as an argument. This would not have worked before, as the type would be missing and you would not get code completion. It is now possible, however.
This is also a common scenario for collections, and has been supported since PhpStorm 2021.2.1.
Support for the phpstan-* annotation for templates
PhpStorm now supports any annotations for generics. You can either use a @psalm-* or @phpstan-* prefix or use pure tags without prefixes, like @template.
Faster and better deployment
In PhpStorm 2021.3 it will be possible to use rsync and multiple connections as deployment options. This brings a tremendous speed improvement. There will be a few more updates, so stay tuned!
Subscribe to our blog mailing list here to get updates sent straight to your inbox.
And be sure to follow us on Twitter @phpstorm!
New debugger UI
Our built-in debugger is a powerful tool that, in conjunction with Xdebug, helps you explore code behavior and fix bugs.
However, its design has become cluttered over the years, and as a result, the workflow has become overly complicated. In PhpStorm 2021.3 it will be simpler, neater, and more concise.
The new design is more modern and minimalist, which speeds up the debugging workflow and makes popular actions more discoverable.
New debugger layout
There is now a single horizontal toolbar at the top of the window. We’ve removed the vertical toolbar on the left and collapsed all the others. This layout reorganization lets us save a lot of space and makes the UI more intuitive. The changes help you focus better on essential debugging tasks like analyzing variables and navigating frames.
The most popular actions can now all be found in one place, and you can access the rest using the More icon. If the default configuration doesn’t work for you, you can customize it in Preferences | Appearance & Behavior | Menus and Toolbars | Debug Header Toolbar.
We’ve also made the Evaluate expression dialog more discoverable – you can now access it right from the Debug tool window.
Other notable improvements
Here are some other notable fixes available in this build:
It’s now possible to use the mouse wheel to change the font size in your editor for all opened files, not only the current one. To enable this setting, go to Preferences / Settings | Editor | General and choose All editors under Change font size with Command / Ctrl + Mouse Wheel in (IDEA-158642).
You can now turn off smart list editing in Markdown. To do so, go to Preferences / Settings | Languages & Frameworks | Markdown and deselect Automatic assistance in the editor checkbox (IDEA-273049).
We’ve fixed a known issue that was causing the IDE to crash on Linux (IDEA-248140).
The full list of changes in this build is available in the release notes.
You are welcome to share your feedback in the comments below, by tweeting @phpstorm, or via our issue tracker.
If you’re not familiar with our EAP, here’s a quick recap.
We publish new EAP builds every week and showcase upcoming features.
Download builds from the EAP page or receive them automatically in the IDE by selecting Check IDE updates for Early Access Program under Settings/Preferences | Appearance & Behavior | System Settings | Updates.
You can install the EAP version side by side with your stable version of PhpStorm — there is no need to uninstall it.
The Toolbox App is the easiest way to get the EAP builds and keep both your stable and EAP versions up to date.
EAP builds are free to use and don’t require a license.
Your JetBrains PhpStorm team
The Drive to Develop
The PhpStorm Blog : The Lightning-Smart IDE for PHP Programming | JetBrains Blog