From fd2a7797bd53326a16861450f1e8ec6c1f8905c8 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 5 Feb 2020 15:55:41 +0000 Subject: [PATCH] include make-release.php in phpstan analysis --- build/make-release.php | 62 +++++++++++++++++++++++++----------------- phpstan.neon.dist | 2 ++ 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/build/make-release.php b/build/make-release.php index f7be518e7..d78f9adcc 100644 --- a/build/make-release.php +++ b/build/make-release.php @@ -21,7 +21,7 @@ declare(strict_types=1); -namespace pocketmine\build_script; +namespace pocketmine\build\make_release; use pocketmine\utils\VersionString; use function dirname; @@ -37,17 +37,6 @@ use const STDIN; require_once dirname(__DIR__) . '/vendor/autoload.php'; -if(isset($argv[1])){ - $currentVer = new VersionString($argv[1]); -}else{ - $currentVer = new VersionString(BASE_VERSION); -} -$nextVer = new VersionString(sprintf( - "%u.%u.%u", - $currentVer->getMajor(), - $currentVer->getMinor(), - $currentVer->getPatch() + 1 -)); function replaceVersion(string $versionInfoPath, string $newVersion, bool $isDev) : void{ $versionInfo = file_get_contents($versionInfoPath); @@ -63,17 +52,40 @@ function replaceVersion(string $versionInfoPath, string $newVersion, bool $isDev ); file_put_contents($versionInfoPath, $versionInfo); } -$versionInfoPath = dirname(__DIR__) . '/src/pocketmine/VersionInfo.php'; -replaceVersion($versionInfoPath, $currentVer->getBaseVersion(), false); -echo "please add appropriate notes to the changelog and press enter..."; -fgets(STDIN); -system('git add "' . dirname(__DIR__) . '/changelogs"'); -system('git commit -m "Release ' . $currentVer->getBaseVersion() . '" --include "' . $versionInfoPath . '"'); -system('git tag ' . $currentVer->getBaseVersion()); -replaceVersion($versionInfoPath, $nextVer->getBaseVersion(), true); -system('git add "' . $versionInfoPath . '"'); -system('git commit -m "' . $nextVer->getBaseVersion() . ' is next" --include "' . $versionInfoPath . '"'); -echo "pushing changes in 5 seconds\n"; -sleep(5); -system('git push origin HEAD ' . $currentVer->getBaseVersion()); +/** + * @param string[] $argv + * @phpstan-param list $argv + */ +function main(array $argv) : void{ + if(isset($argv[1])){ + $currentVer = new VersionString($argv[1]); + }else{ + $currentVer = new VersionString(BASE_VERSION); + } + $nextVer = new VersionString(sprintf( + "%u.%u.%u", + $currentVer->getMajor(), + $currentVer->getMinor(), + $currentVer->getPatch() + 1 + )); + + $versionInfoPath = dirname(__DIR__) . '/src/pocketmine/VersionInfo.php'; + replaceVersion($versionInfoPath, $currentVer->getBaseVersion(), false); + + echo "please add appropriate notes to the changelog and press enter..."; + fgets(STDIN); + system('git add "' . dirname(__DIR__) . '/changelogs"'); + system('git commit -m "Release ' . $currentVer->getBaseVersion() . '" --include "' . $versionInfoPath . '"'); + system('git tag ' . $currentVer->getBaseVersion()); + replaceVersion($versionInfoPath, $nextVer->getBaseVersion(), true); + system('git add "' . $versionInfoPath . '"'); + system('git commit -m "' . $nextVer->getBaseVersion() . ' is next" --include "' . $versionInfoPath . '"'); + echo "pushing changes in 5 seconds\n"; + sleep(5); + system('git push origin HEAD ' . $currentVer->getBaseVersion()); +} + +if(!defined('pocketmine\_PHPSTAN_ANALYSIS')){ + main($argv); +} diff --git a/phpstan.neon.dist b/phpstan.neon.dist index c5db920bf..28b369554 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -11,9 +11,11 @@ parameters: autoload_files: - tests/phpstan/bootstrap.php - src/pocketmine/PocketMine.php + - build/make-release.php - build/server-phar.php paths: - src + - build/make-release.php - build/server-phar.php dynamicConstantNames: - pocketmine\IS_DEVELOPMENT_BUILD