After upgrading a project to PHP8, I'd like to refactor my code to use the new features, eg. replacing
if (strpos($link, 'somestring') === false) {
with
if (!str_contains($link, 'somestring')) {
PhpStorm offers a context menu for this action which is great. It also means that PhpStorm can detect these constructs.
But: Is there a possibility to replace all occurrences automatically, maybe in combination with the "Replace in files" menu? Of course a regex would also do the job, but a full automatic process would be more comfortable.
Find which inspection is this. For this:
strpos
in this case)Run that particular inspection.
The "Problems" toolwindow will be activated and will list all places where this inspection is triggered. You can do the batch fix here (on a file scope, not all occurrences at once though -- not all quick fixes have "fix all found occurrences at once" option).
P.S. You can skip some steps (1.4, 2.1 & 2.2) by simply selecting Run inspection on...
on the first screenshot if you know for sure that it is the right inspection.
Another approach / option -- use Rector that can do quite a few of such upgrades in automated way. It can be integrated with PhpStorm as of 2022.2 version (and you can always run it from a command line).