We have started rolling out support for PHP 8 with support for Union Types. In PHP 8.0 it will be possible to declare more than one type for properties, arguments, and return types. PhpStorm already fully supports this feature and can help you migrate effectively.
Union types used to be provided via PHPDoc, and now PhpStorm highlights such occurrences.
With the Alt+Enter quick-fix, they can now be converted into native union types.
This works anywhere that union types are applicable, including function arguments, return types, and properties. For properties, it takes into account default values, too.
To enable the PHP 8 related features, switch the language level to PHP 8 in any of the following ways:
composer.json, and PhpStorm will pick it up automatically.
PhpStorm analyzes calls, calculates possible types, and highlights problem areas relating to union types.
The checks work on all levels: properties, arguments, and return values.
In complex code bases, it helps you see the problems at first glance. PhpStorm will highlight places that require attention even before the code is run.
There are many type combinations that are forbidden or redundant. For example:
All of them are highlighted by PhpStorm as invalid.
When there is a single nullable type, it is allowed to use either
Type|null in PHP 8.
But when there are multiple types combined with null, using
forbidden as ambiguous.
PhpStorm highlights these violations and provides an Alt+Enter quick-fix to convert them.
During inheritance, PHP allows you to modify types if you follow these basic rules:
Luckily, with PhpStorm there is no need to remember these rules as it will check the code and highlight any violations.
In PHP 8 there will be a special
false pseudotype that can be used only in
union type declarations.
It is widely used in the standard library, see
array_search(), for example, and can be applied elsewhere to indicate a
PhpStorm highlights incorrect usages and takes type inference into account.
After adding a native union type declaration, a PHPDoc may become unnecessary because it does not provide any extra information.
You can now remove it with a quick-fix Alt+Enter.
PhpStorm can now analyze complex code paths and detect if the condition in an
if-else block makes sense or is redundant.
Similar to conditions, PhpStorm is able to detect when
instanceof checks are
appropriate, or if they always evaluate to true because of the inferred type in the type
The new action lets you see the inferred type of any selected expression.
When coding, you can select an expression and check its type by using the shortcut Ctrl+Shift+P or View | Type Info menu.
PhpStorm can detect when the variable is guaranteed to be
null only. In this
case, the IDE suggests simplifying the expression to make it clearer.
"exclude-pattern"section, PhpStorm will now take this into account and not analyze files under the specified path.
Managing Composer dependencies can be done in the editor directly inside the composer.json file.
If there are custom sources specified in the
“repositories” section, you will get completion for custom packages.
There is now a gutter icon showing the current state of the caching of custom repositories.
When a package has multiple versions separated with a comma or pipes (
PhpStorm provides completion with all available versions for this package.
It used to be that completion was lost after typing
>=, but now it works as expected with any of these range
constraints in composer.json.
PhpStorm provides many integrations with third-party tools. Now, if a supported tool is declared in composer.json, there will be a wrench icon in the gutter beside it. You can click it to go straight to the corresponding section of preferences.
If a class gets cluttered and burdened with a lot of additional responsibilities, it is now possible to refactor it by moving methods and properties to a new class with the Extract Class refactoring.
Select a function, a method, or a property you’d like to move and press Ctrl+T and select Extract class.
The refactoring will create a new file, instantiate an object of the class in the constructor, and adjust the usages automatically.
Support for remote interpreters is now available for PHP Command Line Tools.
Under Preferences/Settings | Tools | Command Line Tool Support, add a new tool entry and choose one of the configured remote interpreters.
Laravel Artisan will now be detected automatically! It means that when you open a Laravel project, you can press Ctrl-Ctrl and start typing a command. PhpStorm will provide completion and suggest available commands.
If there is an array declared and updated somewhere in the code, but it is never read, it means that the array is very likely redundant and adds noise to the code.
The inspection detects such cases and prompts you to remove the array to make the code cleaner.
If a typed property does not have a default value, it is considered uninitialized. Reading
uninitialized properties will generate a
TypeError (unless magic
__get() is defined).
PhpStorm detects uninitialized properties and highlights code that attempts to read them.
The entire Pull Request workflow can now be done in PhpStorm, and there is no longer any need to switch to a browser. You can manage pull requests; view the timeline and inline comments; add comments and reviews; and accept changes.
To start working with GitHub pull requests, open the Pull Requests tool window either from the toolbar or by pressing Ctrl+7.
Then select a pull request in the list to view all its details: the message, branch names, author, and so on.
From here, you can start the review process by checking the changed files and commenting on the changes – on both the commit level and line level.
Merging pull requests without leaving the IDE is also possible. There’s no need to create a local branch from a pull request, it all works out of the box.
PhpStorm 2020.2 supports the OpenAPI Specifications plugin. This is a free plugin developed by JetBrains that provides completion, navigation, and validation in the OpenAPI spec files (openapi.yaml/openapi.json and swagger.yaml/swagger.json).
The plugin also provides:
In the top right-hand corner of the editor, you’ll see the brand new Inspections Widget with a summary of the problems in the current file.
Want to use Prettier instead of the built-in formatter to tidy up your code? With this update, it has become even easier than before. Just tick the new On code reformat checkbox and the IDE will use Prettier whenever you reformat your .js, .ts, .jsx, and .tsx files. Other file types can be easily added, too.
Nuxt.js support, Vue-specific code style settings, improvements around Vue in TypeScript projects, and a lot of other things were added in the past year. Vue support in PhpStorm has never been so advanced!
New smart Alt+Enter intentions will help you perform some
actions faster. For example, you can now quickly convert a for loop with a numeric index
forEach array method. Looking through documentation comments in
the editor, minimizing distractions.
PhpStorm 2020.2 supports Git installed in WSL 2 for working with projects located in Linux and Windows file systems.
The IDE can switch between Git executables depending on the project location. When a project
is opened from WSL (via
\\wsl$ path), the IDE will automatically switch to Git
from WSL, and it will also provide you with the ability to use all the Git-related features
in the IDE.
When you want to compare two branches to see which commits do not belong to one another, PhpStorm 2020.2 will show the logs in the editor instead of the Git tool window. This will ensure that there is enough space to display all the information.
Choose the Compare with Current action from the Git Branches popup menu VCS | Branches.
You can now easily remove redundant local commits by selecting them in the Log tab of the Git tool window and choosing Drop Commit from the context menu.
It is also possible to combine several local commits into one single commit, for example to clean up history before pushing.
In the Git tool window, select commits and choose Squash Commits… from the context menu.
The IDE will run an interactive rebase behind the scenes.
Take a look at What’s new in DataGrip 2020.2 – all these features are available in PhpStorm too.
Now if you have a huge value in your cell, it can be viewed or edited in a separate panel. You can also toggle soft wrap mode using the right-hand toolbar. Use all the power of our code editor for your data.
We’ve added a new SQL dialect: Google BigQuery. Full support for BigQuery is not here yet, but all things must begin somewhere. So far, PhpStorm can correctly highlight and provide coding assistance for your queries if you use Google BigQuery.
You can review the query that represents your changes in the data editor. There is a DML button that is active if there are pending changes. This query is not the exact SQL that will be run to modify your data, because PhpStorm uses a JDBC driver to update tables, but most of the time it will be the same.