source: branches/testa-x/php/spyc-0.5/php4/5to4.php @ 106

Last change on this file since 106 was 23, checked in by anonymous, 6 years ago

init

  • Property svn:executable set to *
File size: 728 bytes
Line 
1<?php
2
3php5to4 ("../spyc.php", 'spyc-latest.php4');
4
5function php5to4 ($src, $dest) {
6  $code = file_get_contents ($src);
7  $code = preg_replace ('#(public|private|protected)\s+\$#i', 'var \$', $code);
8  $code = preg_replace ('#(public|private|protected)\s+static\s+\$#i', 'var \$', $code);
9  $code = preg_replace ('#(public|private|protected)\s+function#i', 'function', $code);
10  $code = preg_replace ('#(public|private|protected)\s+static\s+function#i', 'function', $code);
11  $code = preg_replace ('#throw new Exception\\(([^)]*)\\)#i', 'trigger_error($1,E_USER_ERROR)', $code);
12  $code = str_replace ('self::', '$this->', $code);
13  $f = fopen ($dest, 'w');
14  fwrite($f, $code);
15  fclose ($f);
16  print "Written to $dest.\n";
17}
Note: See TracBrowser for help on using the repository browser.