PhpStorm 2019.1 Beta

We are happy to announce that PhpStorm 2019.1 Beta is now available for download!

PhpStorm 2019.1 Beta

Below is a roundup of the notable highlights: You can now debug Twig and Laravel Blade templates, use a special code cleanup tool for PHP, and have PhpStorm detect dead code. We’ve also reworked imports, improved autocompletion for function arguments and return values, and added a Recent Locations popup!

Debug Twig and Laravel Blade templates

With PhpStorm 2019.1, you’ll be able to debug original uncompiled template files of two popular engines, Twig and Blade. Simply specify the path to the template cache folder, turn on debug mode (for Twig), and set a breakpoint in the template file. The debugger will stop the execution at that line and you’ll be able to see what’s going on right in the IDE: the context, local and global variables, and so on.

twig-debug

laravel-blade-debug-2

Docker support improvements

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 start).

docker_compose_lifecycle

Locating Dead Code

PhpStorm 2019.1 can help you find redundant code by highlighting classes, class members, or functions that are never used. Find candidates for removal instantly by turning on the ‘Unused declaration’ inspection under Preferences | Editor | Inspections in PHP | Unused. The inspection takes into account dynamic usages of the code, for example via magic methods. You can check the report for the whole project by selecting Code -> Inspect Code…

dead-code

Code Cleanup for PHP

In PhpStorm, Code Cleanup is a batch action that lets you run a number of safe transformations on the whole project or a part of it.

In PhpStorm 2019.1, Code Cleanup 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.

Code Cleanup can be executed automatically before changes are committed, or you can trigger it manually at any time via Code -> Code Cleanup…

code-cleanup-inspections

Reworked Imports

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 it is possible, or replace it with the corresponding ‘use’ import statement.

Also, now when you paste some code into a file, PhpStorm will ask to reuse an existing alias.

import-on-paste

Improved Autocompletion

With the help of a special file, .phpstorm.meta.php, PhpStorm can now 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.

count_completion-after

Or if you expect some function to return a certain constant, but with type hints, you could only know that it’s an integer:

expected-return-value-

You can also improve suggestions in PhpStorm for your library or project by providing your own .phpstorm.meta.php file. Check out, for example, this symfony-meta package for the Symfony framework.

VCS improvements

This release comes with neat improvements for VCS. For example, there’s a new “Uncheck all” checkbox for partial Git commits which lets you clear the current selection, and then select a specific set of changes to commit. In addition, fixup, squash, and cherry-pick actions are now available right in the Git log.

partial-commit-uncheck-all

Recent Locations popup

In the new navigation popup, you’ll find recently visited code points presented in 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.

recent-locations

Custom Themes

If Default white and Darcula themes are not enough, create a custom one! Every UI aspect of your IDE, from icons to radio buttons and arrows, are now configurable. You’ll be able to customize and save as a new theme plugin. Stay tuned for more information!

Other improvements for PHP

  • New inspection: method may be ‘static’
  • New refactoring: Move to class for functions and constants
  • New quick-fix: Remove unused variable
  • Multiple new intentions for manipulating strings
  • New coloring options for primitive parameter types and class members by visibility
  • PHPDoc styling configuration improved: sort use statements, define the order of tags, customize the number of spaces

Web technologies

  • The documentation (F1) for CSS properties and HTML tags and attributes now shows the up-to-date descriptions and information about the browsers support from MDN
  • New browser compatibility inspection for CSS properties
  • Run and debug Node.js app when using Docker Compose
  • Extract CSS variable refactoring
  • New inspections for Angular applications
  • Convert a function with Promise to an async function with an intention
  • New intentions that introduce object or array destructuring

Database tools

  • Support for new databases: Greenplum, Vertica, and Apache Hive
  • Code completion supports combined statements for CREATE and DROP
  • Support for DEFINER attributes in MySQL and MariaDB
  • Support for the Oracle mode in MariaDB
  • You can now set the default folder for a project

Download the beta from our website or via Toolbox App.
Please feel free to share with us any feedback that you have: add comments on this blog post or speak up in our public issue tracker. Stay tuned as the PhpStorm 2019.1 release is coming soon!

The JetBrains PhpStorm Team
The Drive to Develop

This entry was posted in Release Announcements and tagged . Bookmark the permalink.
  • Martin Melka

    For the potential readers excited about the support for docker-compose exec, it does not provide any customizability, so if you rely on e.g. running as a particular user, you are out of luck.

  • Greg

    Two questions:

    1. Does the “.phpstorm.meta.php” have any provisioning for libraries creators? i.e. do you load “.phpstorm.meta.php” from vendor?
    2. Is it possible, using “.phpstorm.meta.php”, suggest where user may get the value? Example is Doctrine (for context look at second code block in https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/query-builder.html#high-level-api-methods) – every time you use `->where()` you should either supply string OR you should supply return value of (effectively, from the perspective of the class) `$this->expr()->…..`?

    Especially the second one will allow native support for sooo many framework scenarios where imperfect plugins are needed now.

    • http://jetbrains.com/webide Alexey Gopachenko

      1. The intent is yes, pick up meta from libs, and you can easily pack it as a IDE plugin too.
      2. Your example is unclear, it may be better to start a new issue to discuss.
      Overall, we plan to introduce as much features that we found common to custom frameworks as possible

    • Kirill Smelov

      Hello Greg, about the second case: we don’t have support of this exact case right now, but we already have similar functionality to bond some expected/return values:

      //.phpstorm.meta.php
      registerArgumentsSet('mySet', 1,2,3);
      expectedArguments(func(), 0, argumentsSet('mySet'));
      expectedReturnValues(MyClass::myMethod(), argumentsSet('mySet'));


      $a = new MyClass();
      func() //here $a->myMethod() will be suggested

      Will it suit your needs? If no, could you please share your idea as feature request?

  • Николай Конев

    Sounds nice. But what about Focus Mode introduced here?

    Didn’t try EAP yet, waiting for that feature. Is it shipped already?

    • Maxim Kolmakov

      Sorry but the mode is still not completely finished and doesn’t provide a pleasant experience so far.
      Because of that, we had to move it to 2019.2. But 2019.1 has a lot of goodies beside it so give it a try:)

  • techniczny

    Since 2019.1 the “Qualifier is unnecessary and can be replaced with an import…” inspection for namespaces is now coloring the redundant namespace part gray instead only underline. Ok, but it looks like a comment now and it’s very confusing. Where can I change this color? I cannot find this anywhere. Which setting is it and what’s the name of this inspection?

    • Dmitry Tronin

      This inspection is called PHP | Code Style | Fully qualified name usage. The coloring is applied based on File | Settings | Editor | Color Scheme | General > Errors and Warnings | Unused symbol color. Unfortunately the “Unused symbol” effect can’t be disabled for this inspection: you can submit a feature request to add a control over it at https://youtrack.jetbrains.com/newIssue

  • http://about.me/MichaelUssher Michael

    Not a fan of the new debug button, previously it was green when on and greyed out when off. That makes sense. Now it is green/red/grey when off and green/grey when on. This does not make sense to me.

    • Eugene Morozov

      You mean, the Start Listening for PHP Debug Connections button?
      It hasn’t changed since 2018.3 I believe.

      • http://about.me/MichaelUssher Michael

        I think the issue may have been the “idea 2016.2 icon pack” or the “Legacy Icon Pack 2018.2+” have yet to be updated to work with the new version. The result is: previously I had a green phone icon when debugger is on and a grey phone icon when debugger is off. Now I have a 3 color icon when the debugger is off and a different multi colored icon when the debugger is on. I like clean and simple. This upgrade changed that well used button for me and I’d prefer that it hadn’t. I try to upload an image here, but get “You must be logged in to upload an image.” ( I am logged in, so not sure what the issue is.)

  • MatKus

    About detecting dead code – is there way to define dynamically loaded files? For example, i have “controller” directory, where classes and methods are loaded by router dynamically depending on URI, so all methods there are probably used, but all are shown as unused.

    • Eugene Morozov

      If those classes and methods have certain names you can describe with a part of the name and an asterisk, you can add them to entry points.
      Otherwise, you can create a scope that would not include the `controller` folder and make the inspection run only against this scope.

      • MatKus

        They have common namespace, so maybe i could use it.
        But i don’t see where to declare entry poits.
        Googled for it for a while and found how to do this in Java, but not in php. All I found was inspections->PHP -> unused->unused declarations -> [entry points] tab, but there is only one checkbox “assume test declarations as entry points”, so this will not solve problem.

  • michaeldevery

    I don’t see this mentioned here so maybe it’s just something with my configuration – I get lots of warnings about “Qualifier is unnecessary and can be replaced with an import.” but for root namespaced classes. For example Exception or Throwable will give me a warning saying it can be replaced, but I don’t think that makes sense.

    • Dmitry Tronin

      Please open the inspection settings (Alt+Enter on a warning > right arrow > Edit inspection profile) and enable “Ignore global namespace” checkbox.

      • michaeldevery

        Perfect, thanks!