logo
podcast Podcast
get help Get Unstuck

Easily find specific code usages in PhpStorm without regex

Regexes in search logic are powerful, but this tip will supercharge your code searching without needing to get too fancy.

Joel Clermont
Joel Clermont
2023-09-18

Let's continue the theme from the previous tip about tightening up our Laravel view assertions in our tests.

So now that you know that assertViewHas isn't working the way you might expect with null values, how can you find all the locations in your tests that need refactoring?

In PHPStorm, you can use Shift-Cmd-F (or the equivalent in your OS) to "find in all files" and easily find all mentions of the assertViewHas helper, but you might think you need to do a fancy regular expression to limit results to only those that are asserting null values.

But there's an easier way! After doing your global Shift-Cmd-F, you can then click in the find results and use Cmd-F to find null just within your existing set of search results. No fancy regex needed!

Searching within PHPStorm search results

Here to help,

Joel

P.S. Laravel is pretty secure by default, but Aaron published a course to go even deeper on Laravel security.

Toss a coin in the jar if you found this helpful.
Want a tip like this in your inbox every weekday? Sign up below 👇🏼
email
No spam. Only real-world advice you can use.