Video Lesson: Analyze & cleanup code inspections in PhpStorm

Lessons

Analyze & cleanup code inspections in PhpStorm

Learn how to analyze and cleanup code inspections in PhpStorm using project wide automated fixes.


Lesson Content

When you're writing or refactoring code, you'll notice those little suggestions from PhpStorm — like the one recommending to remove redundant arguments. You're probably used to just clicking the link to fix each one individually.

But there's a way to automate these updates across an entire file or even your whole project.

Method 1: The caution icon

See that little caution icon in the top right corner? Click it, and you'll see all the problems in your current file.

Go ahead and select one of these warnings, right-click, and choose Show Quick Fixes. You'll see the same option as before — remove the redundant argument.

Here's where it gets interesting. Click the triple dot menu, and you'll see options to fix all problems in this specific file. You can also run the inspection on your entire project by selecting Whole Project or defining a specific scope.

Click Analyze, and PhpStorm will show you all the warnings it finds across your codebase. Select one of the results, click Remove Redundant Argument, and it'll fix them across all affected files.

Method 2: Run inspections by name

There's an even more streamlined approach. First, we need to find the rule name so we can target these updates directly.

You'll see "redundant argument" mentioned in the warning, or you can copy the specific description that pops up. Head to PhpStorm → Settings and paste that description into the search bar.

Under Editor, click the Inspections tab. If you don't see results, try searching for something like "redundant" instead.

You'll find a code smell called Redundant optional argument. Click it, and you'll see the inspection ID — that's the rule name. Copy it to your clipboard.

Now go to Code → Analyze Code → Run Inspection by Name. Paste in the inspection ID, select it, and click OK.

PhpStorm will analyze your entire project for that specific inspection. Just like before, you get all the results with options to remove those redundant arguments.

Shift-click to select all the findings, then under Fix Partially, click Remove Redundant Argument. PhpStorm will apply the fix to as many as it can automatically.

For any remaining warnings that couldn't be auto-corrected, you can inspect them individually and make those updates manually.