Skip to content

Instantly share code, notes, and snippets.

@einenlum
Created May 10, 2022 12:13
Show Gist options
  • Select an option

  • Save einenlum/064985b4d93f977b364dd33b967034b6 to your computer and use it in GitHub Desktop.

Select an option

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)
# 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