Create custom Rector rule and see how it works:

Custom Rector rule
PHP snippet to change