PhpStorm 2020.1 EAP #2

Last week, we launched the Early Access Program for PhpStorm 2020.1. For the next two months, we are going to be releasing updates every week. That means it’s time for the second build of the 2020.1 EAP.

In this blog post, you can read about type inference improvements for PHP, as well as new inspections and a couple of other enhancements. The post also offers an overview of the brand new Commit tool window, LightEdit mode, and Zen mode.

  • Important! PhpStorm EAP builds are not fully tested and may be unstable.
  • You can install an EAP build side by side with a stable PhpStorm version to try out the latest features.
  • EAP builds are free to use but expire 30 days after the build date.

Download PhpStorm 2020.1 EAP

PHP

Type Inference Improvements

The core of PhpStorm – the type inference engine – has received a few noticeable improvements.

Detecting redundant @var tag
It is a good idea to add a @var tag over a variable to suggest its type to PhpStorm. But as we constantly improve type inference, some of those suggestions are redundant and can be safely removed because PhpStorm already knows the correct type. The tag will be highlighted and you can delete it with the “Remove @var” quick-fix (Alt+Enter alt-enter):

type-inference_var@2x

Better tracking of null
Tracking nullability is a tough task, and there were some places where PhpStorm was unable to detect it. This is no longer the case for the upcoming 2020.1 version. Consider the following code. It is highlighted in previous versions.

type-inference_null-tracking_2019

PhpStorm 2020.1 will know when the variable is null or not and prevent the problem.

type-inference_null-tracking_2020

If there is a null guard, then later in the code null will not be suggested as a possible variable type:

type-inference_null-guard@2x

Infer a non-generic array type from an initializer
Let’s say you have an array with a known set of items and later you want to iterate over items. In this case, you’d expect to get completion, but PhpStorm was missing a type and you had to explicitly declare it with a @var tag.

type-inference_array_2019@2x

This issue is 9 years old, so we’re really excited to finally put it to rest 2020.1!

type-inference_array_2020@2x

Completion in array_map/filter
In PhpStorm 2020.1, the array element type will automatically be detected for the closure parameters of array_map() and array_filter() functions.

type-inference_array_map@2x

New Inspections

Private property can be local variable
If there is a class property that is used only in a single method and is immediately overwritten there, then it’s likely better to make it a local variable and eliminate possible side effects.

The property declaration will be highlighted and you can use a quick-fix (Alt+Enter alt-enter ) “Replace property with local variable”.

inspection_private-to-local@2x

Redundant property initializer
Let’s say there is a default value for a private property in a class, but then the constructor property is immediately assigned some other value. In this case, the default value is redundant and adds confusing noise.

The default initializer will be highlighted as unused and can be removed with a quick-fix (Alt+Enter alt-enter ) “Remove redundant initializer”.

inspection_redund_prop_init@2x

Small Enhancements

Highlight matching <?php / ?> tags
This is a small enhancement that can improve readability in template files.

php_tags_highlight@2x

Go to matched brace action
With Ctrl+M (Shift+Ctrl+M on Win/Linux), you can jump between the opening or closing parentheses ( ), brackets [ ], braces { }, or php <?php ?> tags anywhere in the code.

jump_brace@2x

New Commit Tool Window

The non-modal commit UI has been in development for quite a while. It was turned on by default during the EAP cycle of 2019.2, but it didn’t make it into the final release version.

In 2020.1 we are happy to present a separate Commit tool window, which will be the new home for the Local Changes and Shelf tabs. This tool window will cover commit-related tasks – checking diffs, selecting files and chunks to commit, and entering the commit message.
This vertical tool window opens on the left side of the screen (though you can drag it to the right).

  • The UI is not blocked when preparing a commit, and you can access other files and folders at the same time.
  • This creates more space for the list of files and the Commit message field.
  • It also leaves more space for the diff preview, as it is shown in a separate editor tab.
  • All commit controls are included by default.

Give this new commit flow a try and let us know what you think!

commit_flow

The old modal commit dialog can still be enabled by unchecking the Commit from Local Changes without showing the Commit dialog option under Preferences/Settings | Version Control | Commit Dialog -> Commit from Local Changes.

LightEdit Mode

The new LightEdit Mode allows you to open files in a simple editor window without creating or loading a project. It’s been developed in response to the frequent requests for the ability to use IntelliJ-based IDEs as a general-purpose text editor [IDEA-62898].

To try LightEdit mode, open a file from the command line (for instructions on doing so, see Working with IDE features from command line).

  • Create a command-line launcher Tools | Create Command-line Launcher
  • In your terminal, run “pstorm file” where file refers to a file that exists in the local file system.
  • If PhpStorm has already been launched, then the file will be opened in it. If PhpStorm is not already running, then LightEdit will be opened instead.

light_edit@2x

Zen Mode

The new Zen Mode has been added to get rid of possible distractions and to help you focus completely on your code. In essence, this new mode combines the Distraction Free Mode with the Full Screen Mode, so that you don’t have to enable or disable both of these modes every time you want to enter or exit them.

To enable Zen Mode, go to View | Appearance | Enter Zen Mode.


This release brings plenty of other exciting features, and we will continue to describe notable changes in subsequent posts. So be sure to follow our updates on Twitter and Facebook!

The full list of changes, including bug-fixes and improvements, is available in the release notes.

Please report any problems you find to our issue tracker, or by commenting on this post. Your feedback is much appreciated, and the most active EAPers will get special limited-edition gifts from us!

Your JetBrains PhpStorm team
The Drive to Develop

This entry was posted in Early Access Program and tagged , , , . Bookmark the permalink.