PhpStorm 2019.1 EAP #2

PhpStorm 2019.1 EAP build 191.4738.10 is now available!

This build delivers updates for Docker – reusing containers and docker-compose exec support, multiple new intentions for juggling strings, improved autocompletion for function arguments, new inspections and refactorings, Git support improvements, and much more!

You can download it on the website and in the JetBrains Toolbox App. Or, if you have the previous PhpStorm 2019.1 EAP build (191.4212.35) installed, you should soon get a notification in the IDE about a patch update.

Download PhpStorm 2019.1 EAP

If you’re not yet familiar with our Early Access Programs, here are the basics you should know:

  • Every week we publish a fresh build for the upcoming version of PhpStorm.
  • EAP builds provide access to the newest features we’re currently developing.
  • EAP builds are free to use but expire within 30 days of the build date.
  • Important! PhpStorm EAP builds are not fully tested and might be unstable.
  • You can install an EAP build side by side with a stable PhpStorm version.
  • Your feedback is very welcome in our issue tracker: youtrack.jetbrains.com/issues/WI. Please don’t forget to mention the build number you’re using.

Docker support improvements

In PhpStorm 2019.1, we’ve made a number of improvements for Docker support. First of all, PhpStorm is now capable of reusing containers!

Earlier, whenever you ran an action via Docker, the IDE would recreate a container, which made the whole process a bit slower. But not anymore! Now all run-configurations will use docker-compose exec or docker-compose up and then docker-compose exec if the service is not yet started.

There are the following limitations:

  • We support docker-compose file version 2.2+.
  • It’s not possible to execute services without daemon entry points (it shouldn’t exit immediately after docker-compose up), i.e. we can run a service based on php:7.1-apache image but we can’t run a service based on php:7.1.
  • The working directory will be always used from the docker-compose file or the image it’s based on.

String juggling toolbox

PhpStorm already has some useful string manipulation actions. For example:
Convert to NOWDOC/HEREDOC syntax:
string-to-nowdoc
Replace quotes:
string-replace-quotes
Split string in two strings and concatenation:
string-split

You can see them all and run them by calling a quick-fix action on a string: either press Alt+Enter or click the 💡 icon.
We’ve added even more actions now!

Convert string concatenation to interpolation:
string-concat-to-interpol
Convert concatenation or interpolation to sprintf call:
string-concat-to-sprintf
Copy concatenated string to clipboard:
string-copy-concat

When you combine this with extract variable refactoring you can do some pretty cool things.

Move to class refactoring for functions and constants

Sometimes you may think that some function belongs to a class. You could move it manually, but that would also mean that you need to manually find and modify all the usages.

The new refactoring does it all for you automatically. Place the caret on the function, press Ctrl+T (Shift+Ctrl+Alt+T on Windows/Linux) and select Move…
With the same way, you can move constants as well.
move-function-and-constant

Check out the many other refactorings available out there in PhpStorm in the documentation https://www.jetbrains.com/help/phpstorm/refactoring-source-code.html
If you like to explore the features on your own, try pressing Ctrl+T in your code and see the available refactorings for the piece of code under the caret.

New inspection: method may be ‘static’

If a class has a method that doesn’t use any instance references, then PhpStorm will now highlight it saying that the method may be declared as static. You then have the option to choose what to do: you can apply a quick-fix and make the method static; you can suppress the warning for the current statement or the whole file; or you can just disable this inspection.
method-may-be-static

Improved auto-completion for function arguments

Lots of PHP functions expect a specific set of values as an argument. For example, count(): this function accepts an array or a countable as a first argument. However, you could also pass the second optional argument, $mode, which can only be values of predefined constants COUNT_NORMAL or COUNT_RECURSIVE.

In previous versions, PhpStorm would not suggest during auto-completion:
expected-args-before

In 2019.1, you’ll see those constants in bold at the top of the suggestions list!
expected-args-count-after

This works for other built-in functions:
expected-args-after-all

And for methods too:
expected-args-methods

It works based on PhpStorm stubs, which you a very welcome to contribute to and add any missing parts in meta/.phpstorm.meta.php.

Moreover, you may add this kind of argument awareness to your own projects. Basically, you just need to place a metadata PHP file in your project. Let’s say you have the following class:

Now, to help PhpStorm auto-complete method arguments with the correct values, you’ll need to add a file named .phpstorm.meta.php to your project. And then add the following content to it:

Now you’ll have customized completion for the Foo::bar() method arguments:
expected-args-custom

There is room for many improvement here, and we are planning to work on this in the next iterations. Let us know what you think about this feature!

Version Control Improvements

Fixup and Squash actions in Git log
In the upcoming PhpStorm 2019.1, you can invoke the Fixup and Squash actions from the context menu of the VCS Log tab. These actions help to create commits with the correct fixup! and squash! commit messages.
git-fixup
Cherry-pick a file from a commit in Git log
With the upcoming PhpStorm 2019.1, you will be able to cherry-pick selected files from the commit right out of the context menu in the VCS log.
git-apply-changes


See all the PHP-related bug-fixes and improvements in our issue tracker or the full list of changes in the release notes.

Please report any problems to our issue tracker, or in the comments to this post. Your feedback is much appreciated. And the most active EAPers will get prizes from us!


Download PhpStorm 2019.1 EAP build 191.4738.10 for your platform from the project EAP page or click “Update” in your JetBrains Toolbox App.

Your JetBrains PhpStorm Team
The Drive to Develop

This entry was posted in Early Access Program and tagged . Bookmark the permalink.