From e762715f3e7f0e9e6f861509872b1b6a5e2fa9d3 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 29 Nov 2019 16:07:39 +1300 Subject: Add phpcsff(1df) --- .gitignore | 3 +++ Makefile | 4 ++++ README.md | 3 +++ bin/phpcsff.mi5 | 15 +++++++++++++++ 4 files changed, 25 insertions(+) create mode 100755 bin/phpcsff.mi5 diff --git a/.gitignore b/.gitignore index a6b9e0e3..8dbb1aba 100644 --- a/.gitignore +++ b/.gitignore @@ -85,6 +85,9 @@ /bin/pa /bin/paz /bin/ped +/bin/phpcsff +/bin/phpcsff.m4 +/bin/phpcsff.sh /bin/pit /bin/plmu /bin/pp diff --git a/Makefile b/Makefile index 6902c146..814cd41a 100644 --- a/Makefile +++ b/Makefile @@ -170,6 +170,7 @@ BINS = bin/ap \ bin/pa \ bin/paz \ bin/ped \ + bin/phpcsff \ bin/pit \ bin/plmu \ bin/p \ @@ -234,6 +235,7 @@ BINS_M4 = bin/chn.m4 \ bin/edda.m4 \ bin/mim.m4 \ bin/oii.m4 \ + bin/phpcsff.m4 \ bin/pst.m4 \ bin/swr.m4 \ bin/tlcs.m4 \ @@ -245,6 +247,7 @@ BINS_SH = bin/chn.sh \ bin/edda.sh \ bin/mim.sh \ bin/oii.sh \ + bin/phpcsff.sh \ bin/pst.sh \ bin/swr.sh \ bin/tlcs.sh \ @@ -319,6 +322,7 @@ bin/dfv.sh: bin/dfv.m4 include/mktd.m4 bin/edda.sh: bin/edda.m4 include/mktd.m4 bin/mim.sh: bin/mim.m4 include/mktd.m4 bin/oii.sh: bin/oii.m4 include/mktd.m4 +bin/phpcsff.sh: bin/phpcsff.m4 include/mktd.m4 bin/pst.sh: bin/pst.m4 include/mktd.m4 bin/swr.sh: bin/swr.m4 include/mktd.m4 bin/tlcs.sh: bin/tlcs.m4 include/mktd.m4 diff --git a/README.md b/README.md index 6c53c211..074b08b1 100644 --- a/README.md +++ b/README.md @@ -550,6 +550,9 @@ Installed by the `install-bin` target: * `p(1df)` prints concatenated standard input; `cat(1)` as it should always have been. * `pa(1df)` prints its arguments, one per line. +* `phpcsff(1df)` wraps around + [PHP-CS-Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer) to make it + a source code filter suitable for use as an `equalprg` in Vim. * `pp(1df)` prints the full path of each argument using `$PWD`. * `pph(1df)` runs `pp(1df)` and includes a leading `$HOSTNAME:`. * `paz(1df)` print its arguments terminated by NULL chars. diff --git a/bin/phpcsff.mi5 b/bin/phpcsff.mi5 new file mode 100755 index 00000000..ea05eaaa --- /dev/null +++ b/bin/phpcsff.mi5 @@ -0,0 +1,15 @@ +# Use php-cs-fixer as a source filter. +self=phpcsff + +<% +include(`include/mktd.m4') +%> + +# Duplicate stdin into a file +if ! command -v php-cs-fixer >/dev/null 2>&1 ; then + printf >&2 'php-cs-fixer: command not found\n' + exit 1 +fi +cat -- "${@:--}" > "$td"/src.php +php-cs-fixer fix -- "$td"/src.php +cat -- "$td"/src.php -- cgit v1.2.3