PhpStorm 2023.1 EAP #3: New Inspections

In this build, we’ve added the ability to create custom Regexp-based inspections, and there is a pack of new, built-in inspections available.

The EAP allows you to try new features from the upcoming stable release, PhpStorm 2023.1. EAP builds are free to use. You can install them side by side with a stable version of PhpStorm. If something doesn’t work correctly, you can quickly switch back to the previous version without interfering with your workflow.

Custom Regexp-based search and replace inspections

You can now use regular expressions to create your own search and replace inspections. These inspections can be especially useful for highlighting style and formatting problems or simple code-related issues.

Go to Settings/Preferences | Editor | Inspections and press the + icon. Select Add RegExp Search Inspection (or Replace) from the list, and you’ll be directed to a dialog where you can set up your new inspection. 

Select the language, use hints on the left to build a regexp, and designate the required replacement for the selected pieces of code. You can also configure the way you want the IDE to highlight them in the project.

For more advanced inspections that may involve type hierarchy checks, you can use Structural Search and Replace (SSR) inspections. Learn more about them in the docs, or check out the example in the video below:

New built-in PHP inspections

Every PhpStorm release comes with a bunch of new, ready-to-use inspections. PhpStorm 2023.1 is no exception, so here are a few inspections worth mentioning.

Overriding method/extending class marked as ‘@final’

You can mark classes with the keyword `final`, producing a fatal error in case of a violation. A more mild approach would add the PHPDoc tag `@final`. In this case, PhpStorm will highlight incorrect inheritance, but the code will not produce an error during execution.

Incompatible return types

With a new quick-fix in PhpStorm 2023.1, you will be able to either add a compatible return type for methods in child classes or change it if it’s incompatible.

Assertion can be replaced with `assertTrue`/`assertFalse`

Multiple instances of isset() of nested array access or objects can be replaced with single one

Add ‘global’ for variables accessed from other files

Please see the release notes for the complete list of changes in the EAP #3 build.

PhpStorm EAP builds have not been 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 and don’t require a license. However, they expire 30 days after the build date, after which you’ll have to download a new build.

Your JetBrains PhpStorm team

The Drive to Develop

The PhpStorm Blog : The Lightning-Smart IDE for PHP Programming | The JetBrains Blog

Read More

Generated by Feedzy