Add "check-php-syntax" snippet

This commit is contained in:
Tom Willemsen 2013-01-11 11:13:12 +01:00
parent cef98d73fc
commit fc57f09150
2 changed files with 33 additions and 0 deletions

View file

@ -37,6 +37,7 @@
* Snippets
[[file:snippets/check-php-syntax.org][check-php-syntax]]
[[file:snippets/etcgit.org][etcgit]]
[[file:snippets/euler-problem-1.org][euler-problem-1]]
[[file:snippets/org-export.org][org-export]]

View file

@ -0,0 +1,32 @@
#+TITLE: check-php-syntax
#+OPTIONS: toc:nil
* check-php-syntax
A ~pre-commit~ script for git that checks if all php source files
have proper syntax. This catches far from all mistakes (as most are
not syntax related, of course), but it helps sometimes.
#+BEGIN_SRC sh :tangle yes
#!/bin/zsh
result=0
cd $PWD/src
for php in **/*.php
do
message=$(php -l $php)
if [ $? -ne 0 ]
then
echo "$message"
result=1
fi
done
if [ $result -eq 0 ]
then
echo "All checked out"
fi
exit $result
#+END_SRC