diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d44373b..befb13b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,4 +44,4 @@ jobs: run: | git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" git config --local user.name "Github Actions" - php vendor/phabel/phabel/tools/convertPhabel.php all + php tools/convertPhabel.php all diff --git a/composer.json b/composer.json index 2fd064a..a6b8ba7 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "nikic/php-parser", + "name": "phabel/php-parser", "type": "library", "description": "A PHP parser written in PHP", "keywords": [ diff --git a/tools/convertPhabel.php b/tools/convertPhabel.php new file mode 100644 index 0000000..87ccaab --- /dev/null +++ b/tools/convertPhabel.php @@ -0,0 +1,79 @@ + ['target' => $target]], $dir, $dir, $coverage); + } + + $str = (string) $target; + $packages["php"] = ">=${str[0]}.${str[1]}"; + if (!empty($packages)) { + $cmd = "composer require "; + foreach ($packages as $package => $constraint) { + $cmd .= \escapeshellarg("{$package}:{$constraint}")." "; + } + \passthru($cmd); + } + + \passthru("composer cs-fix"); + + if (!$dry) { + \passthru("git add -A"); + \passthru("git commit -m ".\escapeshellarg("phabel.io: transpile to $target")); + } + } + if (!$dry) { + \passthru("git push -f origin ".\escapeshellarg("phabel_tmp:{$branch}-{$target}")); + + \passthru("git checkout ".\escapeshellarg($branch)); + \passthru("git branch -D phabel_tmp"); + } + \passthru("git reset --hard"); +} + +\passthru("git stash pop");