PhpStorm 2019.3 Released: Full PHP 7.4 Support, PSR-12, WSL, MongoDB, and More
PhpStorm 2019.3 is now available!
This major release is focused on performance and quality, expect a more stable and faster IDE. It also brings full support for PHP 7.4, PSR-12 code style, WSL for remote interpreters, MongoDB support, HTTP Client updates, and many usability improvements!
In this blog post, we’ll provide a detailed overview of all the changes and things that you should know about this new version. It’s a combination of all the EAP blog posts that we’ve been publishing here over the past several months plus many other useful additions that have not yet been covered. Fasten your seat belts as we have a ton of GIFs for you!
Performance and Quality
Every release we dedicate a significant amount of time to performance and quality. But for this release, we went even further and held a full-blown quality-marathon. During this time the whole IntelliJ Platform team focused on polishing the IDE and making performance improvements. And we have achieved the following results:
- Faster IDE startup
- Better UI responsiveness
- Reduced memory consumption
Depending on your platform, you should see much faster IDE loading. Because we parallelized some of the processes that used to run sequentially, we reorganized the classes in a way that makes the initial class loading faster, and much more.
We were able to resolve a number of issues that were responsible for over 1600 reports of UI freezes.
There are performance optimizations in the Version Control subsystem too. We’ve managed to revamp the processing of events and the handling of ignored files. There are fewer freezes and faster status updates in large projects.
We plan to continue working on this, so you can expect even faster startup and more optimizations to come in the next few releases.
This is probably the most anticipated feature of PHP 7.4. PhpStorm has supported it since 2019.2. Let’s take another look at it, as in this release we’ve fixed a few issues with it and covered some corner cases.
First of all, PhpStorm will, of course, highlight type violations:
It is more likely than not that you will want to quickly add type declarations for your properties. This should be quick as PhpStorm can detect the type of the existing properties based on the PHPDoc, default value, or if you have a defined type when you injected the value into the constructor.
Anyway, you can press Alt+Enter on a property without a type, and then choose Add declared type for the field and that’s it, it’s done.
If you have an anonymous function with a single statement in the body, in PHP 7.4, you can now convert it to a short arrow function:
fn(parameter_list) => expr
And there is no need to write
use section as it has an automatic by-value binding of outer scope variables:
Press Alt+Enter on the anonymous function and use Convert closure to arrow function option:
Numeric Literal Separator
You can now add underscore symbols anywhere in the numbers to visually format them. Press Alt+Enter on any number and apply Add number separators. This will add an underscore ‘
_‘ after every third digit for decimal numbers, or every fourth digit in hex, binary, and octal.
Nested Ternary Operator
Almost all programming languages compute the ternary operator from right to left. PHP did it differently, which was counterintuitive and could lead to mistakes. Now, PHP 7.4 deprecates left associativity. This means that you either should not be using nested ternaries at all, or if you have to, then you should use parentheses to explicitly declare the order of computation.
PhpStorm 2019.3 highlights deprecated expressions, and you can use a quick-fix (Alt+Enter – you know, right?) to clarify the behavior.
New Serialization Mechanism
As the issues with existing serialization were not fixable, the PHP core team decided to introduce two new magic methods
__unserialize(). PhpStorm will help find usages of those methods in the code:
Covariant Returns and Contravariant Parameters
PHP 7.4 fixes multiple inconsistencies, and one of them relates to the type system. When you work with a method inherited from a parent class, it will now be possible to define a more specific return type, and less specific parameter types for it.
The good thing about PHP releases is that they not only add new features but also deprecate old ones, making the language cleaner and more pleasant to work with. The PHP 7.4 release comes with a whole bunch of deprecations.
PhpStorm 2019.3 highlights code pieces that need your attention. Where possible, you’ll have an option to quick-fix the deprecated behavior automatically.
⚠️ With the PHP 7.4 release, older versions of PHP are going to be abandoned. PHP 7.2 goes into security-fixes-only for one more year. PHP 7.1 is now officially not supported. This means that if a vulnerability is now found, there will never be a fix for it and getting hacked is just a matter of time. Get ready to upgrade.
This new PSR-12 standard supersedes the dear old PSR-2, adapting it to all the new language features that we’ve been given in the last years, and cleaning up a few inconsistencies. Kudos to PHP-FIG for this great update! If you’ve been using PSR-2, check out what has changed in PSR-12.
PhpStorm 2019.3 comes with a predefined PSR-12 code style, and the IDE will suggest that you switch to it. You can also always switch to it manually with the Set from… action under Preferences | Editor | Code Style | PHP:
Some PSR-12 rules are added as inspections which are off by default, but PhpStorm suggests to turn on the inspection when you choose the PSR-12 code style. You can adjust the inspections as you like, under Preferences | Editor | Inspections in PHP | Code Style | PSR-12:
After this, you can reformat code in the editor by pressing Cmd/Ctrl+Alt+L:
Or you can have PhpStorm run it automatically on the cleanup stage before a commit:
PhpStorm will now support developing in a WSL (Windows Subsystem for Linux) environment, which is when you have launched your IDE on a Windows 10 machine, but you target WSL/Linux in your development. You’ll be able to specify a remote PHP interpreter in the WSL and use it for running scripts, tests, Composer commands, and debugging.
- To get started, make sure you have installed the WSL on your Windows 10 machine, and the Linux distribution of your choice. See the installation guide.
- Depending on the distribution you may have PHP already preinstalled. If not, you’ll have to install it manually via the command line. For example in Ubuntu you can run something like this:
sudo apt update
sudo apt install php php-mbstring php-dom php-xml php-zip php-curl php-xdebug
- When you have PHP in your WSL environment you’re ready to set up PhpStorm.
- Add a CLI interpreter under File | Settings | Languages & Frameworks | PHP
That’s all there is to it! Now you can specify this interpreter for running tests, Composer, or for any other run-configurations that you have.
Traditionally in PhpStorm, you had resolving for FQNs and links in PHPDoc, but the whole block was displayed in one color and styled just like regular comments.
In PhpStorm 2019.3, doc blocks get full highlighting for all the types, variables, params, methods, and properties. If you have HTML in your comments, it will also be highlighted as such.
PHP Highlighting in Markdown and Strings
Sometimes you may need to use PHP inside a string literal. We hope it’s not in
eval(), but you get the point. Or maybe you want to get PHP highlighting in code blocks in Markdown files.
In PhpStorm 2019.3, you get all of these, thanks to a special PHP dialect called InjectablePHP. This dialect works similar to PHP, but the opening tag can be omitted.
It will be automatically injected in markdown fences with the info string equal to
Heredoc/Nowdoc strings with
Well, and in
eval() calls too:
Handy little improvements
Quick-fixes for conditions
if-else statement is probably the most used construct in the language. So in PhpStorm 2019.3, we’ve added a few nice and quick actions to manipulate conditions.
If you have an assignment inside an
if statement, PhpStorm will suggest extracting it to a variable with Alt+Enter:
If you have nested
if conditions, it is now possible to quickly merge them into one with Alt+Enter:
You can merge
else followed by
if into a single
Or you can do the opposite and split
Inline constant refactoring
This refactoring is opposite to the Extract constant and it results in replacing constants occurances with value. Press Cmd/Ctrl+Alt+N on constant.
Discover many more refactotings by pressing Cmd/Ctrl+T.
Unwrap function argument (remove function call)
Press Shift+Cmd/Ctrl+Delete to remove redundant function call:
Auto-insert <?php when just <? is typed in
Short tags are likely to remain a part of PHP, at least for the next few years, as the last RFC vote did not pass.But PhpStorm can help you with deprecating short tags, by automatically inserting
<?php as soon as you type
Automatically complete ‘=’ to ‘=>’ after array key
There’s another little timesaver we’ve included in 2019.3. When you are adding an item into an array, and you type a key and then want to type
=> to specify a value, just press
= and PhpStorm will automatically insert
Other PHP-related updates
Specify the interpreter for PHP test run configurations
Previously, if you wanted to, let’s say, run tests in PhpStorm with a remote PHP interpreter, you had to create a separate run-configuration. In PhpStorm 2019.3, we’ve added interpreter option for any php run-configurations, so you can choose any interpreter that you have to run your tests with. Feel free to use Docker, Vagrant, or any other remote interpreter too.
Fonts & colors for $this variable
Whenever you open an
.rest file, you have a toolbar with quick access to common actions:
Run All Requests in File
With the editor-based HTTP Client in PhpStorm, you can write multiple requests in one
.http file by separating them with
###. This is quite convenient if you need to do request chains when one request depends on the result from previous ones.
Earlier, you had to run each request one by one, now in PhpStorm 2019.3 you can run them all at the same time.
If you are sending a request with a long body, for example, multipart form data or maybe many headers, you may want to fold it to reduce noise in the editor.
You can fold the whole request leaving the first line, or only the body part:
Completion for hosts
When composing a new request, you no longer need to type the hostname you used earlier. PhpStorm will offer you a list of hostnames in the suggestion list:
We’ve added three dynamic variables that you can use anywhere in the requests:
$uuid– Generates a new UUID-v4 (e9e87c05-82eb-4522-bc47-f0fcfdde4cab)
$timestamp– Current Unix timestamp (1563362218)
$randomInt– A random integer between 0 and 1000
Use double curly brackets to insert one of these variables where needed:
See all the essentials you need to know in the video overview of
HTTP Client in PhpStorm.
Reworked UI for cloning projects
Now you can log into GitHub from this dialog, or if you’re already logged in, the IDE will instantly preview lists of all the repositories which will be grouped by accounts or organizations.
We’ve removed the Checkout as action and introduced 2 new separate actions instead: New Branch from Selected and Checkout. The new New Branch from Selected action creates a new branch and doesn’t set tracking. The Checkout action silently creates a new local branch, checks it out, and sets tracking of the selected remote branch if there is no local branch with the same name.
Push any branch
You can now push changes from any branch without switching to it. In the VCS | Branches popup – select a branch and then use the Push action from the menu.
Date format customization
You can configure the date format for VCS Annotate and VCS Log actions. For example, you can set it to
mm/dd/yyyy if you want to use the US format.
Better plugin management
PhpStorm has lots of incredible plugins that you can install to extend its functionality and customize its appearance. Managing plugins was a bit of a hassle, as it required restarting the IDE each time. We’ve addressed this issue in PhpStorm 2019.3 by implementing core underlying infrastructure – support for dynamic plugin installation. This basically means that the IDE can now load and unload plugins without restarting. It is currently enabled for the theme and keymap plugins. In future releases, we plan to extend this to most plugins.
The scrollbar can now be made more visible thanks to the “Use contrast scrollbars” checkbox at Preferences/Settings | Appearance & Behavior | Appearance.
Smooth mouse scrolling
If the option Smooth scrolling is enabled under Preferences | Appearance & Behavior | Appearance, the entire interface will scroll smoothly instead of line by line when using a mouse wheel/touchpad.
Search within selected text
Select the code piece you need in the editor and invoke the Find action by pressing Cmd/Ctrl+F and the IDE will search only in the selected area. If you need to extend the search area and search throughout the whole file, press Cmd/Ctrl+F again, or alternatively toggle the In Selection option in the toolbar.
New editor command to sort lines alphabetically
Now you can easily sort lines alphabetically by selecting lines in the editor and choosing Edit | Sort Lines from the main menu or by running this action from Find Actions by pressing Cmd/Ctrl+Shift+A:
See all the changes made by our colleagues from the WebStorm team on the What’s new in WebStorm 2019.3 page. Everything mentioned there is incorporated in PhpStorm 2019.3 as well.
The day has finally come for us to start working on MongoDB support.
What actually works in this version:
You can observe collections and fields in the database explorer. We fetch the first 10 documents from each collection to get information about the fields. This can be customized via the JDBC parameter fetch_documents_for_metainfo which is available in the Advanced tab of the data source properties dialog.
Open any collection or observe the query result and you have the option to sort by columns or filter the values, also paging works as well.
It’s also possible to explore data as a tree. To turn it on, click the Gear icon | View as… | Tree.
There is currently no coding assistance, but this doesn’t stop you from running queries and getting back the results. To run a statement, put the caret on it and run it via Cmd/Ctrl+Enter or by using the Play button on the toolbar.
Completion for queries will come later.
PhpStorm includes all the features of DataGrip out of the box, so there are many other new things to discover in DB tools. Stay tuned for a detailed overview of the DataGrip 2019.3 release.
A full list of all the changes in this release is available in the really long release notes.
That’s all for today. Thanks for reading till the end! Send us your questions, suggestions, bug reports, and just your thoughts in the comments.
Your JetBrains PhpStorm Team
The Drive to Develop
Subscribe to Blog updates
Thanks, we've got you!
PHP Annotated – November 2023
Welcome to the November edition of PHP Annotated! In it, we look back over some of the most interesting developments in the PHP community during the past month, featuring handpicked news, articles, tools, and videos. (more…)…
PHP Annotated – October 2023
Welcome to the October edition of PHP Annotated! We'll recap the most interesting developments in the PHP community over the past month, featuring handpicked news, articles, tools, and videos. (more…)…
The Pest Plugin Is Now Maintained by JetBrains
You've probably heard about the Pest test framework developed by Nuno Maduro and the community. There is also a dedicated PhpStorm plugin for Pest, which until now has been brilliantly developed by Oliver Nybroe. In this post, we will talk about how JetBrains is going to maintain the plugin, and her…