Created
June 8, 2010 14:44
-
-
Save v6ak/430117 to your computer and use it in GitHub Desktop.
This file contains 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
@sh "%~pd0port.sh" %* |
This file contains 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
<?php | |
// This code is ASAP (as SHORT as possible), not nice | |
$tokens = token_get_all(file_get_contents('php://stdin')); | |
$write=true; | |
echo '<?php /* Ported by this scratchy tool: http://gist.github.com/430117 | |
(!) GENERATED CODE - DO NOT EDIT! | |
*/?'.'>'; | |
foreach ($tokens as $tok) { | |
$s = is_array($tok) ? $tok[1] : $tok; | |
switch ($s) { | |
case 'use': | |
case 'namespace': | |
$write = false; | |
break; | |
case ';': | |
if($write){ | |
echo ';'; | |
} | |
$write = true; | |
break; | |
case '\\': | |
break; | |
default: | |
if($write){ | |
echo $s; | |
} | |
}; | |
}; |
This file contains 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
#!/bin/bash | |
# config | |
PHP="" # should be php 5.3 | |
LINTPHP="" # should be php 5.2 | |
SCRIPT="" | |
out="../p52" | |
for f in *.php; do | |
echo "$f" | |
case "$f" in | |
. ) | |
;; | |
.. ) | |
;; | |
* ) | |
cat "$f" \ | |
| "$PHP" -f "$SCRIPT" \ | |
> "$out/$f" | |
"$LINTPHP" -l "$out/$f" | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment