Phpstorm Latest



A new PhpStorm EAP cycle is going to be closed soon. But there is still time to try upcoming features and provide feedback. Download the latest. Video: What’s Coming in PhpStorm 2021.1 – Episode 1 Early Access Program. A new PhpStorm EAP cycle is now in full swing. The main focus for this upcoming release is stability, but. This is actually not a question. I just need the default snippet from PhpStorm when you create a new empty.php file and just write! + Tab It will spit out the HTML5 basic template.

Early Access ProgramNewsletter

The third major release of PhpStorm this year will bring support for PHP 8, Xdebug 3, a reworked Welcome screen, IDE themes synced with OS settings, editor splitting with drag-and-drop tabs, Guzzle integrated with HTTP client, and a whole lot more.

In this first EAP blog post we go through all the changes related to PHP 8 support. PhpStorm 2020.3 will allow you to try new language features, check code for compatibility, and quickly upgrade to the newest PHP version.

❗ PhpStorm EAP builds are free to use but expire within 30 days of the build date.
We encourage you to participate in the EAP and share your thoughts on the latest improvements and the new functionality so that we can continue to make PhpStorm better for you. The most active reporters will receive gifts from us, including an exclusive PhpStorm elephpant!

The EAP build is available for download from our website and in the JetBrains Toolbox App. You can also enable the option to have builds delivered automatically to your IDE under Preferences/Settings | Appearance & Behavior | System Settings | Updates.

We started to roll out support for PHP 8 back in the last major release – PhpStorm 2020.2 came with full support for union types.

The first release candidate of PHP 8 was shipped today, so the list of changes is final. That means we can now tell you what PHP 8 features await you in the upcoming version of PhpStorm.

Set Language level from status bar

To see all the PHP 8 features in action, you need to set the language level in PhpStorm to 8. You can do this by adding a constraint in the require section of the composer.json file, or you can set it manually.

In PhpStorm 2020.3 the current language level is now always displayed in the status bar. You can also switch which language level you use from there.

Now let’s get straight to the new PHP 8 features.

Named Arguments RFC

Previously, it was possible to pass parameters to PHP functions only by position.

PhpStorm has been able to highlight argument names for a long time and readability was not a problem.

But if there were several parameters with a default value, and only one of them had to be changed, you still had to pass everything.

For example, to change only the double_encode parameter in htmlspecialchars, you had to list all the preceding parameters with their defaults. In PHP 8 you can just pass it by name and omit others.

Of course, PhpStorm will warn you if the parameter name is incorrect or has a typo:

You can add parameter names in the function call either one by one or to all of them at once using an Alt+Enter quick-fix Add name identifiers:

Also, if there are unnecessary arguments in the list, i.e. when the passed value is the same as the default value, PhpStorm will highlight them as unused and offer to delete them with a quick-fix:

You’ll often see options arrays being used. With named arguments this is not necessary, because you can pass only the parameters you need. And as a bonus, parameters passed in this way are type-safe, unlike array elements.

Attributes RFC

Attributes a.k.a. annotations are metadata. In the past, such metadata could be specified in PHPDoc comments, but its format was not validated and was not supported at the language level.

Now they can be declared in a structured way as full-fledged language constructions.

Phpstorm latest version

Another way of specifying metadata in PhpStorm is in the .phpstorm.meta.php file. Learn more about it in the documentation.

To create an attribute you need to declare a usual class and add an #[Attribute] marker on top of it.

PhpStorm provides all the features that you would expect here: highlighting, code completion, find usages, refactorings, and so on.

You can specify attribute flags to define target and repeatability. PhpStorm provides completion for that too:

There is also a bunch of validation rules that PhpStorm will check for:

  • The specified class can really be an attribute.
  • This attribute is applied only in the allowed targets: class, property, method, parameter, function, or class constant.
  • This attribute is repeated only if it has the Attribute::IS_REPEATABLE flag.

Note, that validation of attributes by PHP itself only happens when calling ReflectionAttribute::newInstance(). If not accessed via reflection, attributes get ignored completely to avoid having to load classes and create objects.

With PhpStorm, you will see if attributes are valid or not without running reflection API.

PHP 8 will not bring any attributes out of the box. But PhpStorm 2020.3 will!

We have already added two ready-to-use custom attributes that improve inference type and control flow analysis, and we plan to add more. Stay tuned for an upcoming blog post with more details. Joystick mapper app.

Attributes in action with Symfony:

Constructor property promotion RFC

This feature allows you to reduce the size of boilerplate code in common cases where you initialize variables through a constructor. It makes objects smaller and more readable.

You can convert constructor properties to promoted properties, or change them back, with a quick-fix. Put your cursor over the property in a constructor and call Alt+EnterConvert to promoted property.

PhpStorm makes sure that promoted properties are only used in the way allowed by PHP 8.
For example:

Phpstorm
  • Cannot declare promoted property outside a constructor.
  • Cannot declare promoted property in an abstract constructor.
  • Cannot declare variadic promoted property.
  • Property cannot have type ‘Callable’.
  • Redeclaration of property is not allowed.


If the property is promoted, but there is a left-over assignment in the constructor body, then PhpStorm will suggest removing it.

Match expression RFC

PHP 8 introduces a new expression match which is similar to switch but solves its issues.

switchmatch
❌ Loosely compares () the given value to the case values.✅ The comparison is strict i.e. with respect to types.
❌ Needs a break; after each section. If this is not done, the switch will continue to execute.✅ No need to specify break; – it will stop execution at the end of an arm implicitly.
❌ Cannot be used as an expression or assigned to a variable.✅ It’s an expression, so its result can be assigned to a variable.

The new match expression will be fully supported in PhpStorm 2020.3:

PhpStorm will determine if a switch block can be converted to a match and will do it automatically with an Alt+Enter quick-fix:

With the new expression it might be hard to see misusages. This is where PhpStorm will help.

PhpStorm will check the condition type against the argument type and warn you if there is no overlap.

For example, if the condition is unhandled, as this will cause Fatal Error. You can use Add ‘default’ match arm quick-fix here:

Or if the condition is never matched:

Each arm of the match expression can contain a list of possible values. PhpStorm detects duplicates that will never run. You can jump to the duplicate element and remove either the whole arm or only one value from the list.

Match expressions can only contain one default arm, so any violation will be highlighted and you can remove an erroneous arm with a quick-fix:

A match expression with a single default arm can be safely replaced with a ternary expression.

And if there is only a default arm left, then you might not need the match at all, so PhpStorm will draw your attention to it.

And lastly, if there are identical bodies in different arms, they can be merged into one to reduce the size of the block.

Nullsafe operator RFC

Instead of cumbersome conditions with null checks, you can now use a chain of calls with the new ?-> nullsafe operator.

Phpstorm Latest

PhpStorm will check that the operator is used correctly. You can’t use the nullsafe operator in write context and as a reference:

Those are the biggest new PHP8 features, but there are many other changes in PHP 8 and PhpStorm supports them all.

Trailing comma

It’s now valid to add a comma after the last parameter in a function call and in use list of closures.


Non-capturing catches RFC

In PHP 8 it is possible to catch exceptions without capturing them to variables.

Phpstorm latest update

You can use an Alt+Enter quick-fix both to add or remove a variable in catch statement:

Throw expression RFC

Throwing exceptions will be allowed in arrow functions, the coalesce operator ??, and the ternary/elvis operator ? :, which was not possible before.

To quickly add a throw expression you can type thr and press tab – this will expand a live template.

Allow ::class on objects RFC

In previous PHP versions to get an FQN you could do ClassName::class but on objects you had to call get_class().

In PHP 8 you can safely replace get_class($object) with $object::class. PhpStorm provides an Alt+Enter quick-fix for that and will also warn if ::class is used inappropriately.

New functions for strings: str_contains() RFC, str_starts_with(), str_ends_with() RFC

How do I check if a string contains a specific word? – is the most viewed PHP question on Stack Overflow ever.

Now in PHP 8, there is a clear answer to that question: use the str_contains() function.

Phpstorm update to latest version

To make code more readable, PhpStorm 2020.3 will detect strpos() usages that can be replaced with str_contains():

There are also new str_starts_with(), str_ends_with() functions to determine if a string starts or ends with a specific substring. PhpStorm will highlight the places where old substr() calls can be replaced with the new, more self-explanatory, alternatives:

Attention, plugin developers!
PhpStorm 2020.3 will contain breaking changes in the plugin API. Please report any issues you encounter to YouTrack during the Early Access Program.

To be continued

Phpstorm Latest Update

Phpstorm

We plan to ship PhpStorm 2020.3 in early December. Prior to the final release, we will be publishing a fresh EAP build every week accompanied by a blog post outlining its new features and changes.

Phpstorm Update To Latest Version

The full list of tickets resolved in this build is available in the release notes.

  • ⚠️ 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.

You are very welcome to share your feedback in the comments below, by tweeting @phpstorm, or via our issue tracker.

Phpstorm Latest Version

Your JetBrains PhpStorm team
The Drive to Develop