What’s New in PhpStorm 2020.3

PHP 8

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.

See language version   See language version   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 doesn’t list any restrictions on the PHP version. Add named arguments identifiers   Named arguments   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: Check that argument names are correct. Add parameter names automatically with an Alt+Enter quick-fix. Remove redundant arguments. Convert to promoted property   Constructor property promotion   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. Validate nullsafe operator usages   Nullsafe operator   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. Convert switch statement to match expression   Match expression   The new expression is a type safe and compact alternative to the statement. A expression can be used as a value and assigned to a variable or returned.   PhpStorm will determine whether a block can be converted to a 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. New functions for strings   New functions for strings: str_contains(), str_starts_with(), str_ends_with()   In PHP 8, you can use the function to determine whether a string is part of another string. PhpStorm 2020.3 draws your attention to any usages of that can be replaced with .   PhpStorm also highlights the places where old calls can be replaced with the new, more self-explanatory and functions. Other PHP 8 features supported   Other PHP 8 features supported   Trailing comma after the last parameter in a function call and in the section of closures. Non-capturing catches are useful to catch exceptions when you don’t need an exception object. Throw can now be used as an expression (i.e. it is allowed in arrow functions, the coalesce operator , and the ternary/elvis operator ). To get a class FQN from an object, you can do instead of . Use an Alt+Enter quick-fix for this.   PHP 8 attributes   Convert PHPDoc to native union types   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] attribute   #[Deprecated]   Like the 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.   Specify the and 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. #[ArrayShape] attribute   #[ArrayShape]   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. #[Immutable]   #[Immutable]   Mark objects or properties with the 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. #[Pure] attribute   #[Pure]   Mark functions that do not produce any side effects as to improve the code flow analysis in PhpStorm. The IDE will highlight redundant calls of pure functions.   If you mark a function as 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., , are already marked in PhpStorm. #[ExpectedValues] attribute   #[ExpectedValues]   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.   is an advanced version of from . #[NoReturn] Attribute   #[NoReturn]   Mark the functions that can terminate a script execution with a 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. #[Language] attribute   #[Language]   Add this attribute to string parameters containing text in another language, such as RegExp, SQL, and so on. This will reveal additional PhpStorm features.   Psalm and PHPStan Support   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 and turn on the corresponding inspection by clicking a wrench icon near the tool. PHPStan and Psalm   PhpStorm also provides code completion for 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 prefix from tags, i.e. can simply be and 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   Xdebug 3   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.   Code With Me   Collaborative development via Code With Me   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.   Tailwind CSS   Quick access to settings of tools added as dependencies   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 files.   HTTP Client   Run Guzzle requests with the HTTP client   Run Guzzle requests with the HTTP client   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 scratch file with the parameters prefilled.   Play around with the request and then save it as an file in your project. Export HTTP requests to cURL   Export HTTP requests to cURL   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.   Editor   Markdown editing and preview enhancements   Markdown editing and preview enhancements   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. Improved spelling and grammar checking   Improved spelling and grammar checking   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. Split the editor with drag and drop   Split the editor with drag and drop   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. Preview Tab   Preview Tab   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.   IDE   Search Everywhere improvements   Search Everywhere improvements   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.   Web Technologies   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. TypeScript in the Problems tool window   TypeScript in the Problems tool window   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. Create a React component from usage   Create a React component from usage   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.   Version Control   Git stage support   Git stage support   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.   Database Tools   Take a look at What’s new in DataGrip 2020.3 – all these features are available in PhpStorm, too. SQL for MongoDB   SQL for MongoDB   You can now use SQL to query MongoDB databases. PhpStorm 2020.3 supports queries with clauses such as , , , , , , , 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. Couchbase support and new data extractors   Couchbase support and new data extractors   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 statement with multiple new rows to be inserted. Download Learn more