Created
May 10, 2022 12:13
-
-
Save einenlum/064985b4d93f977b364dd33b967034b6 to your computer and use it in GitHub Desktop.
Easily add strict_types to all PHP files not having it (with ripgrep and sed)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # rg --files_without_match returns all the files that don't have "strict_types" in them | |
| # rg --type php filters only php files | |
| # '3 i' insert the following at the third line | |
| files=$(rg --type php strict_types --files-without-match) && echo $files | xargs sed -i '3 i declare(strict_types=1);\n' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment