]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blobdiff - vendor/mustangostang/spyc/php4/5to4.php
MediaWiki 1.30.2
[autoinstallsdev/mediawiki.git] / vendor / mustangostang / spyc / php4 / 5to4.php
diff --git a/vendor/mustangostang/spyc/php4/5to4.php b/vendor/mustangostang/spyc/php4/5to4.php
new file mode 100644 (file)
index 0000000..5a48694
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+
+php5to4 ("../spyc.php", 'spyc-latest.php4');
+
+function php5to4 ($src, $dest) {
+  $code = file_get_contents ($src);
+  $code = preg_replace ('#(public|private|protected)\s+\$#i', 'var \$', $code);
+  $code = preg_replace ('#(public|private|protected)\s+static\s+\$#i', 'var \$', $code);
+  $code = preg_replace ('#(public|private|protected)\s+function#i', 'function', $code);
+  $code = preg_replace ('#(public|private|protected)\s+static\s+function#i', 'function', $code);
+  $code = preg_replace ('#throw new Exception\\(([^)]*)\\)#i', 'trigger_error($1,E_USER_ERROR)', $code);
+  $code = str_replace ('self::', '$this->', $code);
+  $f = fopen ($dest, 'w');
+  fwrite($f, $code);
+  fclose ($f);
+  print "Written to $dest.\n";
+}
\ No newline at end of file