PhpStorm 2020.3 is a major update that introduces support for PHP 8, PHPStan, Psalm, Tailwind CSS, Xdebug 3, and collaborative development via Code With Me.
PHP 8.0 is a major language update with many incredible new features. PhpStorm will help you verify that your existing code is compatible with it, update your codebase more quickly, and take advantage of the latest language improvements.
Now you can always see which language version is being used in a project. We have placed the corresponding indicator in the status bar. From there, you can also change the language version if
composer.json doesn’t list any restrictions on the PHP version.
Function and method arguments in PHP 8 can be passed by specifying a parameter name. This eliminates the need to set optional parameters, and it means calls are now self-documented.
PhpStorm can help:
This feature lets you reduce the amount of boilerplate code when you initialize variables through a constructor.
In PhpStorm, you can convert constructor-initialized properties into promoted properties or change them back with Convert to promoted property Alt+Enter quick-fix.
Instead of having to use cumbersome conditions with null checks, the new
?-> operator allows you to build chains of calls with implicit checks for null for each element.
PhpStorm makes sure that the operator is being used correctly.
match expression is a type safe and compact alternative to the
switch statement. A
match expression can be used as a value and assigned to a variable or returned.
PhpStorm will determine whether a
switch block can be converted to a
match expression, and it will automatically do so with an Alt+Enter quick-fix.
With the new expression it might be hard to see misusages. PhpStorm will highlight them for you.
In PHP 8, you can use the
str_contains() function to determine whether a string is part of another string. PhpStorm 2020.3 draws your attention to any usages of
strpos() that can be replaced with
PhpStorm also highlights the places where old
substr() calls can be replaced with the new, more self-explanatory
usesection of closures.
??, and the ternary/elvis operator
get_class($object). Use an Alt+Enter quick-fix for this.
PHP 8 allows you to use attributes to specify metadata in a structured way instead of having to rely on PHPDoc annotations.
PhpStorm provides highlighting, code completion, finding usages, refactorings, and other coding assistance for working with attributes. It also has inspections to make sure the attributes are declared and are validly used.
PhpStorm 2020.3 comes with several PHP 8 attributes available right away in the IDE. We also provide them in a composer package jetbrains/phpstorm-attributes, so feel free to add it as a dependency in
@deprecated PHPDoc tag, you can use this attribute to mark methods, functions, classes, or class constants that will be removed in future versions of the software.
replacement so that your users understand why they need to upgrade, and make it possible for them to do so automatically with an Alt+Enter quick-fix.
Use this attribute to define the keys and value types of object-like arrays. This will improve the coding assistance and analysis you get from PhpStorm.
Note: If written on one line, this also works in PHP 7.4 and earlier.
Mark objects or properties with the
#[Immutable] attribute when you want to prevent any attempts at changing the object after it is initialized.
This makes the program state more predictable and debugging easier.
Adjust the write scope restriction of properties with one of the following constants passed to the attribute constructor:
Note: If written on one line, this also works in PHP 7.4 and earlier.
Mark functions that do not produce any side effects as
#[Pure] to improve the code flow analysis in PhpStorm. The IDE will highlight redundant calls of pure functions.
If you mark a function as
#[Pure] but in its body there is an attempt to change something from the outer scope, then PhpStorm will highlight the unsafe code.
All such PHP internal functions, e.g.,
array_merge(), are already marked in PhpStorm.
Use this attribute to specify which values a function accepts as parameters and which it can return. This will improve code completion and help detect possible bugs.
#[ExpectedValues] is an advanced version of
Mark the functions that can terminate a script execution with a
#[NoReturn] attribute to get more accurate control flow analysis.
PhpStorm will offer to propagate the attribute down across the hierarchy with a quick-fix to get even more well-defined analysis.
Add this attribute to string parameters containing text in another language, such as RegExp, SQL, and so on. This will reveal additional PhpStorm features.
Both of these static analyzers can be used in PhpStorm 2020.3 as first-class tools to highlight issues in the editor. Add them as dev-dependencies in
composer.json and turn on the corresponding inspection by clicking a wrench icon near the tool.
PhpStorm also provides code completion for
@psalm-* tags and treats them as special, so there won’t be issues with highlighting, undefined classes, and so on. In most cases, it is now safe to remove the
@psalm- prefix from tags, i.e.
@psalm-return can simply be
@psalm-param can be
Many psalm types are supported, including scalar, numeric, and types with constants. Consequently, everything that depends on type inference has become more accurate: inspections, code generation, and completion.
Xdebug 3 is a fresh rework of the PHP debugger. It works much faster and is easier to set up.
To configure Xdebug 3, the only thing you need to specify is
The default debugging port for Xdebug has been changed from 9000 to 9003. To ease migration, PhpStorm listens to both ports by default. The port and other settings for Xdebug can be adjusted under Preferences/Settings | Languages & Frameworks | PHP | Debug.
Learn more about Xdebug 3 in the Upgrade Guide.
PhpStorm 2020.3 supports Code With Me – a new service from JetBrains for collaborative development and pair programming. Code With Me enables you to share the project you currently have open in your IDE with others and work on it together in real time.
Check out these posts to learn more about Code With Me.
PhpStorm can now help you work with Tailwind CSS more productively.
The IDE will autocomplete your Tailwind classes, show you a preview of the resulting CSS on mouseover, and support the customizations you make using
Guzzle is one of the most popular HTTP clients for PHP. In PhpStorm 2020.3, you can test Guzzle requests without running the actual code.
If the request is supported, there will be a gutter icon next to it. Click it to create a new
HTTP scratch file with the parameters prefilled.
Play around with the request and then save it as an
.http file in your project.
To get a cURL string from an HTTP request, press Alt+Enter in the HTTP request editor and select Convert to cURL and copy to clipboard.
You can use the cURL string in the terminal or with your choice of HTTP client.
Mermaid.js diagrams and charts can now be rendered inside the IDE. Enable this support under Preferences/Settings | Languages & Frameworks | Markdown.
There is an Auto-Scroll Preview button in the top right corner of the preview pane that enables and disables synchronous scrolling with the editor.
We’ve added a bunch of popular Markdown code style presets that work when you reformat code with Ctrl+Alt+L. Settings are in Preferences/Settings | Editor | Code Style | Markdown.
The grammar checking engine supports more languages and provides higher-quality grammar checks.
When a mistake is highlighted, there will be a popup with an explanation and a suggested fix.
If you press Alt+Enter with a caret over the highlighted text, you will see all the suggested replacements in the top level, instead of a nested list like before.
Open multiple tabs side by side by dragging a tab over to the desired side of the screen.
Another way to open tabs in split mode is to press Shift+Enter on a selected file in Project view or in any search window.
You can preview files in a special tab without actually opening them. To enable this feature, click the gear icon in the Project view and select both Enable Preview Tab and Open Files with Single Click. If you start editing a file you are previewing, the tab will become an ordinary file.
In the Search Everywhere popup (Shift+Shift), results will be shown in a slightly different way. Instead of being grouped by type, they are now grouped based on their relevance to the search query.
It is now also possible to perform simple math calculations in Search Everywhere. Type some numbers and math operators and see the results of the calculation right away. This eliminates the need to switch to a calculator app and disrupt your flow.
Search Everywhere can also search through Git history, including information about branches and commits.
All the new features and improvements from WebStorm 2020.3 are also available in PhpStorm 2020.3, either out of the box or with free plugins from the Plugin Marketplace.
We’ve integrated the TypeScript language service into the Problems tool window and removed the TypeScript tool window so that it’s easier to review the problems in your code from one place. We’ve also moved the actions previously available within the TypeScript tool window to a dedicated widget on the status bar.
If you have an unresolved React component in your code, place the caret at it, press Alt+Enter, and select Create class/function component from the list – the IDE will create the relevant code construct for you.
PhpStorm 2020.3 comes with support for the Git staging area. To turn it on, tick the Enable staging area checkbox in Preferences/Settings | Version Control | Git.
Go back to the Commit tool window using Alt+0 to see staged and unstaged files.
Stage files by clicking the + icon near them.
You can stage specific lines using the gutter icon near the changes in the editor.
Take a look at What’s new in DataGrip 2020.3 – all these features are available in PhpStorm, too.
You can now use SQL to query MongoDB databases. PhpStorm 2020.3 supports
SELECT queries with clauses such as
OFFSET, and all available MongoDB functions except map, reduce, filter, and let. If you want to learn more about SQL for MongoDB, read this blog post.
PhpStorm now supports the Couchbase Query service. We’ve also introduced two new extractors: One-Row, which allows you to copy a column to a comma-separated string; and SQL-Insert-Multirow, which generates a single
INSERT statement with multiple new rows to be inserted.