PhpStorm 2020.1 EAP #4
The Early Access Program continues, and the fourth build for PhpStorm 2020.1 is now available!
This blog post is dedicated to updates in advanced metadata support.
As you may know, there is a way to extend PhpStorm’s “code awareness” by providing additional information in a special file
.phpstorm.meta.php. For example, this is exactly how container access works in barryvdh/laravel-ide-helper or additional features in Symfony plugin thanks to King2500/symfony-phpstorm-meta.
In the upcoming PhpStorm 2020.1, this meta feature gets a few upgrades.
Parameter index in override, map, and type
type() directives, it was possible to adjust behavior only of the first parameter of the functions. In PhpStorm 2020.1 this finally will be fixed, and it will be possible to specify the index of the parameter explicitly:
Support for property access via __get
If you had to receive some objects via the __get() magic method, then you would likely lose type information. To make it available, you then had to add either a @var or a @property tag. The latter is not applicable in case you didn’t know the type beforehand.
For example, let’s say you had a
ServiceManager and in its
foo property you wanted to expect to have
FooService. In 2019.3, this was not possible.
Now it will be possible to provide such information via metadata.
Completion for keys in ArrayAccess objects
If you’d like to use some object as an array container for other objects and still have code completion, this worked as expected with metadata assistance. However, there was no completion for available keys. Now this will be added in 2020.1.
Custom exit points
PhpStorm considers the functions die() and exit() or the ones throwing an exception as terminating calls. But in applications, there may be some other custom functions that have to be considered as “exit points”, for example, if it’s a debugging function like
dd() or error function like trigger_error with E_USER_ERROR argument.
In PhpStorm 2020.1, it will be possible to mark any function as a custom exit point. This will effectively make a control flow engine take all these function calls into account.
Gutter icon for functions with meta overrides
And last but not least, in the editor you will now see if the behavior was modified by .phpstorm.meta.php file with
expectArguments() directives. And since there can be any number of such metafiles in the project, by clicking the icon, you will open the one that is used in this specific place.
You can hide these icons under Preferences/Settings | Editor | General | Gutter Icons.
The full list of changes in this build, including bug-fixes and improvements, is available in the release notes.
- Important! PhpStorm EAP builds are not fully tested and may be unstable.
- You can install an EAP build side by side with a stable PhpStorm version to try out the latest features.
- EAP builds are free to use but expire 30 days after the build date.
Your JetBrains PhpStorm team
The Drive to Develop