Skip to content

Instantly share code, notes, and snippets.

@v6ak
Created Jun 8, 2010
Embed
What would you like to do?
@sh "%~pd0port.sh" %*
<?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;
}
};
};
#!/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