Skip to content

Commit

Permalink
Create migrate_config.php
Browse files Browse the repository at this point in the history
  • Loading branch information
mevdschee authored Sep 22, 2022
1 parent fc1f33e commit 1001e14
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions migrate_config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

$config = file_get_contents('config/config.php');
if (!strpos($config, 'namespace MintyPHP\Config')) {
die("already migrated\n");
}
copy('config/config.php', 'config/config.php.old');
$lines = explode("\n", $config);
$class = '';
$result = ['<?php'];
foreach ($lines as $line) {
if (preg_match('|class (\S+)|', $line, $matches)) {
$class = "MintyPHP\\" . $matches[1];
} elseif (preg_match('|static \$|', $line, $matches)) {
$result[] = "$class::\$" . substr($line, strpos($line, '$') + 1);
} else if (!trim($line)) {
$result[] = '';
}
}
file_put_contents('config/config.php', implode("\n", $result));

0 comments on commit 1001e14

Please sign in to comment.