
Hi, Habr!
We are glad to present the first major release of PhpStorm this year!
Review release can be viewed on the page
“What's new” . And under the cut supplemented translation of this page with a demonstration of the most interesting new features.
Download the new version on the
website or using the
Toolbox App . As always, a 30-day trial version is available. The full version can be used by the owners of the
current subscription to PhpStorm or All Products Pack, and for free -
students and
developers of open source projects.
')
A total of 1118 bugs were fixed in the release and many new features were added. Here are the most interesting ones.
Debugging Twig and Blade Templates
Thanks to the debugger, you can quickly deal with the most intricate bug, but to find problems in the templates, you have to wade through the wilds of computer-generated code. In PhpStorm 2019.1, we added the ability to debug original uncompiled template files
.twig and
.blade.php .
To do this, simply specify the path to the compiled templates (cache) in the IDE settings:
Languages & Frameworks | PHP | Debug | Templates for
Twig or
Blade .
In the case of Twig, you also need to specify the
debug
and
auto_reload
in the configuration.
And for Blade everything will work automatically, but only starting with version Laravel 5.8.
After that you can turn on the debugger and set breakpoint directly in the template. The execution will stop at the specified location, and all the usual debugging features will be available: stepwise execution, local and global variables, value tracking (watch) and everything else.

Speaking of debugging: we actively support the author Xdebug Derick Rethans to improve the debugger, solve the
accumulated problems and expand the possibilities of its use in PhpStorm.
Dead Code Detection
PHP is turning 24 this year, and it’s not surprising that you often have to deal with legacy code. The first thing I want to do is clean up and remove the excess. New inspection
Unused declaration will just help in this matter.
PhpStorm 2019.1 can analyze your code on the fly and highlight directly in the editor those classes, class members and functions that are probably not used anywhere.

You can also find all unused items in batch mode. To do this, call the menu
Code -> Run Inspection by Name and select the
Unused Declaration inspection . You will receive a report with a list of all problems with the description and quick fixes.

New refactorings and quick actions
By tradition, we have added several new refactorings to make routine actions quick and error free.
String manipulationIf you press
Alt + Enter on any string expression, you will see a whole list of available transformations. For example, there is already a conversion from / to NOWDOC / HEREDOC, replacing quotes, dividing a string into two with concatenation.
And in this release we added a few more handy things - copying the concatenated string to the buffer, replacing the concatenation of the lines with interpolation or calling the
sprintf () function
and, respectively, inverse actions:
Delete unused variablesThe new inspection will detect and allow the deletion of an unused variable in assignment operations and
use
constructs in closures.
Refactoring Move to ClassWith this refactoring, you can safely move functions from PHP files to classes. PhpStorm will update all calls to these functions.

When restoring order, you may need to move several functions at once - this is also supported by PhpStorm. You must select the desired functions in the Structure window and then call the Move to Class refactoring.
Inspection Method May Be 'static'This inspection will detect methods that can be converted to static, that is, those that do not use an instance of the class. Such methods will have a context action available - you can press Alt-Enter and select “Make static”. As expected, all calls will be corrected automatically.

Improved autocompletion mechanisms
Using the .phpstorm.meta.php file, you can tell the IDE which arguments are expected in the function or what values it can return. PhpStorm will use this information for autocompletion.
Let's say a function expects a constant as an argument. Formally, the type of this constant is, say, an
integer
, but in reality we know the set of possible constants.
For example,
json_encode($data, /* JSON_* */)
We can also have a function that returns a constant, for example
json_last_error()
.
In PhpStorm 2019.1, autocompletion for these and many other built-in functions already works out of the box:


Moreover, such autocompletion can be done in any project / library / framework by simply adding a special .phpstorm.meta.php file to the project. And there may be many such files, PhpStorm will find and merge them.
For example, there are already such files for Symfony in the form of the
King2500 / symfony-phpstorm-meta package - it comes with the
Symfony plugin .
Read more in the post
about the new features .
Phpstorm.meta.php .
Import optimization
The system of analysis and correction of imports was somewhat reworked. Now PhpStorm will, if possible, suggest replacing the full name of the class with import or delete it altogether if it is redundant.
Also added is the ability to sort
use
expressions alphabetically or by length.
Code Cleanup Tool
This tool allows you to make safe conversions in batch mode. For example, in the whole project at once, in a certain directory, etc.
In PhpStorm, it was available for a long time, but only in 2019.1 PHP features were added. First of all, it supports two tools for coding style correction: PHP CS Fixer and phpcbf from PHP_CodeSniffer. As well as two inspections to optimize imports from the previous paragraph.

This tool can be launched at any time manually or before a commit, simply by ticking the appropriate box in the commit dialog:

Reuse Docker Containers
Added support for launching Docker containers in docker-compose run and docker-compose exec modes. The first mode is suitable for lightweight containers that stop immediately after launch. The second allows you to reuse running containers without having to restart.
Among other improvements:- Flexible settings PHPDoc: you can customize the order of elements and indents in Preferences | Editor | Code Style | PHP tab PHPDoc;
- The default PHP file template has been cleaned - no more “Created by PhpStorm”;
- A new quick action to add a class property to the constructor;
- You can enable strict mode globally,
even if the files have no declare(strict_types = 1);
directive declare(strict_types = 1);

VCS
There are many useful improvements in the version control system:
- Fixup and Squash actions added to Git log;
- When viewing diffs, you can now swap panels;
- Push-to-force is now safer because the
--force-with-lease
flag is used; - In the commit dialog, the Uncheck all option for partial commits has been added - with it, you can disable all changes and then select only the ones you need:

IDE Improvements
Recent Locations DialogMost of the time when working on a task, developers have to read the code, not write. Therefore, fast navigation between files is always very relevant. PhpStorm already had
Search Everywhere ( Shift-Shift ) ,
Bookmarks and Favorites ( Cmd + 2 / Alt + 2 ), go back and forward in history ( Cmd + [ - Cmd +] / Ctrl + Alt + Left - Ctrl + Alt + Right ), or view the latest files ( Cmd + E / Ctrl + E ) .
In PhpStorm 2019.1, we added another interesting feature - the Recent Locations dialog (
Cmd-Shift-E / Ctrl + Shift + E) , which will show the latest pieces of code that you have viewed or edited. This can be useful if you want to quickly move through the history and see the context in order to understand exactly where to move.
New interface themesPhpStorm comes with three themes: Light, Darcula and High Contrast. If you want to try something fresh, then install one of the new themes:
Dark Purple ,
Gray or
Light Cyan . Also now you can create themes yourself, while it is possible to set the color of any element or icon. Read more
in the documentation .
Soft-wraps depending on file typeIf you often work with markdown or text files, now line wrapping for them will be enabled automatically. You can also set other file types in
Preferences | Editor | General | Soft-wrap files.PhpStorm as always includes all updates from WebStorm :The documentation of CSS properties, HTML tags and browser support is now taken from MDN and contains links to relevant articles, TypeScript support in Vue applications has improved, 17 new inspections for Angular applications have been added, and new and new debuggers in JavaScript and Node.js panels have been added interactive consoles.
... and from DataGrip :Now additionally supported by Greenplum, Vertica, Apache Hive; Now you can choose the default project folder; as well as improved means of completing structures and attributes.
This is all that I was able to tell about - but not all that was included in the release. A full list of changes, as always, can be found in a very large
release notes .
Thanks for attention!
Team JetBrains PhpStorm