What’s New in PhpStorm 2019.2
Experience hyper-productivity with the second major PhpStorm update of 2019.
The release of PHP 7.4 is expected at the end of November. PhpStorm is starting to roll out support for it early, so that you have time to test and start planning the migration. The most anticipated feature is probably the new Typed Properties, which PhpStorm 2019.2 already fully supports. New inspections will highlight the type violations, and you can update your codebase using the quick-fix Add declared type for the field. PhpStorm will detect the type automatically based on the PHPDoc, default value, or argument type declaration in a constructor.
Having the same code block appear several times in your project can cost you time making changes, or even cause regression bugs if you ever forget to update all the occurrences. PhpStorm helps prevent the creation of code duplicates in your code by highlighting them on the fly so you can easily spot them. Now, if you stumble across an existing duplicate, or somehow create one in your code, you will know it instantly! The new inspection is called Duplicated code fragment and is enabled by default. To configure it, go to Preferences | Editor | Inspections | General. You can adjust the relevant settings under Preferences | Editor | Duplicates. And, of course, you can run it on the entire project (or custom scope) anytime via Code → Run Inspection by Name.
RegExps are an extremely useful tool for searching and replacing in strings. Now in PhpStorm, you get automatic injections for RegExps in PHP. This means that whenever your code uses
preg_* functions, the pattern will be highlighted and verified for correctness. Moreover, you can now test your patterns right in the IDE! Move the caret over the pattern and press Alt+Enter to see the quick action Check RegExp.
Previously you had to have a local PHP interpreter to run Composer. The problem with that was the local environment often didn’t reflect the real production setup or there might not even be a local PHP interpreter at all. In PhpStorm 2019.2, you can choose any remote interpreter to run your Composer with: Docker, Vagrant, via SSH, or anything else – you name it!
Go to Preferences | Languages & Frameworks | PHP | Composer, select Remote Interpreter, and choose an interpreter from the dropdown – or add a new one.
PhpStorm comes with multiple intentions Alt+Enter to manipulate strings. There’s a new one for 2019.2.
If you need to introduce a new parameter in a
sprintf expression, simply select it, run the Extract selected string part as format function argument intention, and PhpStorm will choose the correct place for a parameter for you. This works for concatenation as well.
According to PSR-2, lines longer than 80 characters should be split into multiple subsequent lines of no more than 80 characters each. So if your parameters list or array has become too long, you can now split it with one-click using the new intention Alt+Enter Split comma-separated values into multiple lines. The reversed intention is also available for cases where you want to combine items into one line.
It is now possible to add branches faster by copying existing ones and then modify them. You can use Alt+Enter on the body-less case statement and choose Copy ‘switch’ branch. Don’t forget to modify the copied one, because PhpStorm will warn you if a switch block has a duplicated branch, i.e. the same body, which can either be redundant or written by mistake. Also, in PhpStorm 2019.2 if you have a switch statement without a default branch in your code, you can quick-fix this with Alt+Enter too.
.phpt files can help you write functional tests in a simple way. This format is used to test the PHP core. PhpStorm 2019.2 comes with support for
.phpt files, including highlighting for sections and scripts, PHP and INI languages auto-injection to corresponding sections, completion of section names, and jumping to files referenced in EXTERNAL sections.
Docker has been moved to the new Services tool window. The goal of this tool window is to provide a single location to view all the connections and running processes. So far in PhpStorm, it includes Docker and Database connections.
It is now possible to view the file system of the running Docker container. The file system is displayed in the newly added Files tab.
Simple as it is, copy the cURL request string from your browser dev tools, documentation, terminal, or anywhere else, and then just paste it to
.http file in PhpStorm and see it expanded to a full request! After that go ahead and play around with your request with the power of smart completion.
Let’s say you’ve made a request to authenticate on the service and in subsequent requests you would like to call some endpoints that require additional permissions. Previously, you would lose the cookies from the first response. But not anymore: PhpStorm now keeps all the cookies for you and transfers them in the next requests.
With the new Propagate to destructuring intention Alt+Enter, you can replace an extra variable with another destructuring. To remove a destructuring completely, use the intention action called Replace destructuring with property or index access.
The IDE will now warn you if a boolean expression in a condition has any unnecessary parts and will suggest simplifying it.
Are you using Vuetify or BootstrapVue in your Vue.js application? Code completion for components and their props from these and other Vue component libraries is now more precise. This was made possible by a new approach we’ve adopted to working with these libraries in the IDE.
PhpStorm 2019.2 provides out-of-the-box syntax highlighting for over 20 different programming languages including Ruby, Python, Go, and others. The highlighting is based on integrated TextMate bundles, so if you need any additional language, feel free to download the corresponding bundle for this language and import it into the IDE.
PhpStorm now supports
.editorconfig files out of the box! You can have as many of them as you wish. Create them in any folder and the specified code style settings will be applied to the files in that folder only.
In addition to all the standard properties of the EditorConfig standard, you can now also specify PhpStorm-specific code style options. It’s never been easier to define common code-style standards for the whole team.
This release offers rich editing support for shell scripts, including word and path completion, Quick documentation, and even the Rename refactoring. You can also create run configurations for executing shell scripts.
We’ve integrated PhpStorm with several external tools for even more advanced shell script support. From now on, you can use Shellcheck to detect and fix errors in your script, mvdan/sh to properly format your shell script, and Explainshell to get a full description of a command by pressing Alt+Enter.
You can now add files to the list of ignored files from either the Project Tree or the Local Changes tab of the VCS tool window. If you prefer editing
.gitignore, you can use path completion in the editor.
PhpStorm 2019.2 brings a big change for projects that use Git or Mercurial. Now you can commit files from the Local Changes tab of the Version Control tool window. There, you can review the modified files and make changes if necessary because the commit dialog doesn’t block the rest of the IDE. To give it a go, select the “Commit from the Local Changes without showing a dialog” checkbox in Preferences | Version Control | Commit Dialog.
If you are committing some files and PhpStorm 2019.2 detects that there are other files changed that you often commit together with the currently committed ones, then the IDE will warn you about it so you don’t miss anything.
Now you can choose which columns you want to see in the Log tab of the Version Control tool window. Click the eye icon, select ‘Show Columns’, and then select the columns you want to display: author, date, or commit hash.
Now you can search for the necessary data even if you don’t know its exact location. Right-click the data source or a group of data sources that you want to search through, and select Full-text Search, or pressCmd+Alt+Shift+F.
The results are filtered to show you only those strings in which the data is found. If you cannot locate the data because there are too many columns, use the text search in the data editor: Cmd+F.
Locating an object in the GoTo popup is not easy sometimes, because often there are too many similar items. In PhpStorm 2019.2, you can choose where to search: in a particular data source or in a group of sources. The same works for Find In Path. This is extremely useful if you are looking for source code inside of DDLs of other objects.
Debugging is very effective when you face a nasty bug or dive deep into a codebase. But it's a nightmare to go through the machine-generated code of compiled templates. With PhpStorm and Xdebug, you can now do step-debugging in original uncompiled .twig and .blade.php files of these two popular template engines. All debugging benefits are available here: see the context, local and global variables, add watches, run step-by-step, and more!
If you’re dealing with a legacy codebase and want to clean up things, a good way to start is removing dead code. Now PhpStorm detects redundant code and highlights classes, class members, and functions that are probably never used. The Unused declaration inspection takes into account dynamic usages of the code, for example via magic methods. To check the report for the whole project, select Code -> Inspect Code….
We’ve added multiple new intentions for manipulating strings. You can now convert string concatenation to interpolation, convert a concatenation or interpolation to a sprintf call, copy a concatenated string to the clipboard, and do many other things. Press Alt+Enter on a string to see the available actions.
PhpStorm 2019.1 introduces a new quick-fix that helps you get rid of the unused variables that appear in assignments’ or closures’ use lists. The quick-fix is smart enough to detect situations when the assignment expression may have side effects.
With the new Move to Class refactoring, you can transit functions or constants to the Class they logically belong to, and PhpStorm will find and modify all usages for you. You can move multiple functions simultaneously by selecting them in Structure tool window.
If a class has a method that doesn't use any instance references, PhpStorm will detect it and offer a handy quick-fix: press Alt+Enter on the method, and make it static. All the usages will be updated automatically.
For interpreters based on Docker Compose, you can now choose between docker-compose run or docker-compose exec for executing containers. If you have a heavy container that you don’t want to restart on each test run, you may reuse it by choosing the docker-compose exec option. Or you can use docker-compose run for lightweight containers or those not working in daemon mode (that is, stopping right after they start).
With the help of a special file, .phpstorm.meta.php, PhpStorm is now able to suggest arguments and return values better. This is to cover situations when, instead of some simple type like integer or string, you would like to see a certain set of constants suggested. Or if you expect some function to return a certain constant. You can also improve suggestions in PhpStorm for your library or project by providing your own .phpstorm.meta.php file.
We’ve reworked the inspections and intention actions related to namespaces importing and using FQN. The main idea behind them is to avoid qualifiers as much as possible. Now, PhpStorm will let you simply remove a redundant qualifier if possible, or replace it with the corresponding ‘use’ import statement. Also, when you paste some code into a file, PhpStorm will ask to reuse an existing alias.
In PhpStorm 2019.1, the Code Cleanup tool comes with PHP-specific intentions: it can optimize full class name occurrences by either adding the ‘use’ statement or removing the unnecessary part from it. It can also automatically fix code style issues with PHP CS Fixer or PHP_CodeSniffer’s phpcbf. Execute a cleanup before VCS commit, or trigger it manually at any time via Code -> Code Cleanup…..
As usual, all the features and improvements of WebStorm are available in PhpStorm, either out of the box or with free plugins available in the repository.
The documentation (F1) for CSS properties and HTML tags and attributes now shows up-to-date descriptions and information about the browser support from MDN as well as links to the full MDN articles. Also, to check that all the CSS properties you use are supported in the target browser version, you can enable a new Browser compatibility inspection in preferences.
PhpStorm now leverages the TypeScript language service together with its own TypeScript support for TypeScript code in .vue files. This means you’ll now get more accurate type checking and type info, be able to use the quick-fixes provided by the service, and see all the TypeScript errors in the current file in the TypeScript tool window.
For Angular applications, PhpStorm adds 17 new inspections that will help you detect Angular-specific errors in your app as you type, and will suggest appropriate quick-fixes. Working both in the TypeScript and template files, these inspections will check your use of bindings, directives, components, and many other things.
In this new navigation popup, you’ll find recently visited code points presented with a context – a couple of lines before and a couple of lines after. All the locations are chronologically ordered in this popup, with the last visited location at the top. To call up the new Recent Locations popup, press Cmd-Shift-E / Ctrl+Shift+E. Type in any text to search within the context.
A new ‘Uncheck all’ checkbox for partial Git commits lets you uncheck all the code chunks at once, and then choose the ones you want to commit. In addition, fixup, squash, and cherry-pick actions are now available right in the Git log.
The database tools in PhpStorm have got some cool improvements thanks to our colleagues on the DataGrip team:
One of Doctrine ORM's key features is the ability to write database queries in DQL, which is a query language for your object model. It means that in your queries, you’ll be using PHP classes’ and fields’ names to fetch or update data. PhpStorm comes with full advanced DQL support. You’ll get all the inspections and refactorings: find usages, rename entity or field, associations support, and even more.
The latest PHP interpreter update brings with it a lot of new features for the community. PhpStorm supports all of them, including flexible Heredoc and Nowdoc syntax, trailing comma in function and method calls, literals as the first operand of
instanceof, and the
list() reference assignment.
Press Ctrl+. in the suggestions list to get the completed item followed by an arrow. You can then type in the method name right away.
PhpStorm adds Support for Intersection Types “
&”. If you annotate a variable as
Foo&Bar, then it is of type
Foo and of type
Bar at the same time. PhpStorm will also suggest members of both classes.
PhpStorm makes it easier to use
sprintf() and prevent common mistakes.
PhpStorm 2018.3 delivers many refactoring improvements and related intention actions:
PhpStorm lets you copy files and folders to a remote server using FTP/SFTP/FTPS, as well as to a local or mounted folder as a destination. Now you can deploy to multiple servers at once by using server groups. Add as many groups as you wish with an arbitrary number of destinations in each group, and deploy to all servers in a group simultaneously in one click.
Now with PHP CS Fixer support, it becomes possible to automatically fix code style issues. Not only will PhpStorm detect the path to PHP CS Fixer for you, but it will also autodetect your custom ruleset and turn on the corresponding inspection. Go to some file with code style issues, and run quick-fix that will update the whole file at once.
Non-PSR coding standards for PHP_CodeSniffer will be autodetected from your composer.json for the following frameworks: Symfony, Doctrine, Drupal, WordPress, Joomla!, Magento, MediaWiki, Yii 2, and CakePHP.
The quality tools settings have been simplified: you can now configure all supported tools (PHPCS, PHPMD, and PHP CS Fixer) in one place.
You can now work with pull requests inside PhpStorm. Select VCS | Git | View Pull Requests in the menu to open a new tool window with a list of all the pull requests in your project. You can see the description, assignee, reviewers, labels, and changed files from the pull request. See diffs and create a new local branch from pull requests right there.
All the familiar features in the Git integration, such as update project, commit changes, view diff, and conflict resolution, now work with Git submodules.
You can now ignore or trim whitespaces while merging – the configuration is available in the new drop-down at the top of the Merge Revisions for… dialog. Whitespaces are also ignored by default when you use Annotate for a file.
Advanced navigation in the VCS log with arrow keys, a parallel fetch of multiple Git repos, better support for pre-commit hooks, and a lot of other improvements are in store.
PhpStorm is now much better at helping you edit Angular templates. Сode completion and Go to definition for variables, pipes and async pipes, as well as for the template reference variables, are now much more accurate. In total, over 50 known issues have been fixed in Angular and AngularJS support.
PhpStorm can now better detect situations that lead to a TypeError because a method is invoked on a value that is undefined or null, or it is passed to a function, or its property is used.
PhpStorm now provides code completion for components from Vuetify version 1.1 or later.
In React apps, code completion now suggests all component lifecycle methods. The Unresolved variable inspection will now warn you about any potentially undefined components.
As usual, all the features and improvements of WebStorm are available in PhpStorm, either out of the box or with free plugins available in the repository.
The new Search Everywhere dialog is a better way to navigate the project and the IDE – search classes, files, symbols, and even actions and settings. Press Shift-Shift to search everywhere, and switch contexts by pressing Tab.
To make PhpStorm more accessible, we’ve added a new high-contrast UI theme. The IDE now allows screen readers to read line numbers, VCS annotations, breakpoints, and other gutter icons. Learn more about screen reader support in the documentation.
Database tools in PhpStorm have been improved thanks to our colleagues from the DataGrip team: