Skip to content

Instantly share code, notes, and snippets.

@DQNEO
Last active October 25, 2021 02:33
Show Gist options
  • Select an option

  • Save DQNEO/5471032715ada025dee51be0b6568932 to your computer and use it in GitHub Desktop.

Select an option

Save DQNEO/5471032715ada025dee51be0b6568932 to your computer and use it in GitHub Desktop.
add void to setUp and tearDown to PHP test code
#!/bin/bash
#
# a tool to apply return type declarations to "setUp" and "tearDown" for PHPUnit7
# list target files by using GNU grep
grep --files-with-matches -i -w -e setup -e teardown -r tests > /tmp/files
# do substitution
cat /tmp/files | xargs perl -pi -e 's/setUp\(\)$/setUp(): void/g'
cat /tmp/files | xargs perl -pi -e 's/tearDown\(\)$/tearDown(): void/g'
cat /tmp/files | xargs perl -pi -e 's/public function runBare() *$/public function runBare(): void/g'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment