PhpStorm 2021.1 Early Access Program Is Open
Today we’re starting the Early Access Program (EAP) for PhpStorm 2021.1.
After doing such a huge feature release with 2020.3, we will be focusing on quality and performance for 2021.1. So while there won’t be many new features, you can expect a number of enhancements in various subsystems.
We plan to ship PhpStorm 2021.1 in late March. 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 EAP builds are free to use and do not require a license.
If you come across any bugs or peculiar behavior, please report them to our issue tracker so we can collect and try to fix the issues and regressions before the release.
PHP language level – disable sync with composer.json
In the previous PhpStorm release, we added a widget in the status bar that shows the PHP language level of the current project.
It could appear as disabled. This meant that there was a PHP version set in the ‘require’ section of
composer.json. In this case, to change the language level, you had to explicitly change the version constraint.
In PhpStorm 2021.1, you can set any PHP version without modifying
.json. This can be helpful, for example, for seeing how compatible the codebase is with the newer PHP version before actually switching to it.
It’s all about inspections
PhpStorm comes with a bunch of inspections. You can check the list and adjust them under Preferences | Editor | Inspections.
In the upcoming 2021.1, we’ll be adding more inspections. Here are just a few of them you can look forward to.
Unnecessary leading ‘\’ in ‘use’ statement
In some cases, the leading backslash is redundant for namespaces. If you feel like it’s adding visual noise, PhpStorm can help you determine where it can be removed.
`foreach` variable overwrites already defined variable
Because it is possible to define variables for key and value in a foreach loop, sometimes these names clash with the names of other variables or parameters.
The problem is that PHP does not have a separate scope for them, meaning that the value will be overridden, which likely is not what you might expect.
PhpStorm highlights all of the places where errors could occur.
Boolean expression can be simplified
If a boolean expression contains
false literals, PhpStorm can help you improve its readability by simplifying it.
Strict comparison of operands with incompatible types
PHP has loose comparison with the
== operator, which tries to typecast operands, for example, converting integers to strings.
On the other hand, it also has the
=== operator for strict comparisons. This will always result in false if the left operand type is not the same as the right.
PhpStorm will highlight such usages, as they can potentially be a source of bugs.
Additionally, PhpStorm will take into account all the type-inferred information and will help you find issues in less obvious cases.
Format function call with single argument
If sprintf() / vpsrintf() calls have only a single argument, meaning there are no values to replace in the template string, then they can be replaced with a simple string.
PhpStorm helps you find and remove such noisy calls.
Loop can be replaced with ‘str_repeat’ calls
To improve code readability, PhpStorm can detect when a loop with string concatenation can be replaced with a single str_repeat() function call.
Unnecessary curly braces syntax for variables
PHP will interpolate strings defined with double quotes. In some complex cases, it may be necessary to enclose a variable expression within curly braces inside a string. This is the case, for example, when you are trying to access an array element by a string key. But often, curly braces make the readability worse.
PhpStorm highlights when the curly braces can be safely removed in the context of string interpolation.
Viewing inspection results in the editor is only part of the story. Recently we’ve released an EAP version for our new product Qodana. It allows you to run all the PhpStorm inspections on your CI pipeline. Check out the blog post to learn more.
Preview HTML files in the editor
To open the preview, click the icon with the PhpStorm logo in the widget in the top-right corner of the editor with the list of web-browsers.
Please let us know what you think about this new functionality. It’s still in active development, so we’d really appreciate your feedback.
You can configure the list of browsers under Preferences | Tools | Web Browsers.
Configure pre-commit inspections
You can now choose a code inspection profile before committing changes to VCS. To do this, click the gear icon to show commit options, then tick the Analyze code checkbox, click Configure, and choose the desired profile. Profiles can be created in Preferences/Settings | Editor | Inspections. The IDE will use the selected profile when inspecting your code before the commit.
Notable bug fixes:
- Methods can now be found if a file has more than 5006 lines (WI-31569 +14)
- The self in trait now resolves to the class that uses the trait (WI-44718 +6)
- Added support for static/$this return type in __get (WI-56660 +2)
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.
Your JetBrains PhpStorm team
The Drive to Develop
Subscribe to Blog updates
Thanks, we've got you!