From 5298ee4f971a510908026b518a532d6e6240e16f Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 5 Mar 2026 08:21:44 +0800 Subject: [PATCH] Use constant back due to config validation problem --- config/downloader.php | 32 ------------------- src/StaticPHP/Artifact/ArtifactDownloader.php | 25 ++++++++++++++- 2 files changed, 24 insertions(+), 33 deletions(-) delete mode 100644 config/downloader.php diff --git a/config/downloader.php b/config/downloader.php deleted file mode 100644 index 2d81a57e..00000000 --- a/config/downloader.php +++ /dev/null @@ -1,32 +0,0 @@ - */ -return [ - 'bitbuckettag' => BitBucketTag::class, - 'filelist' => FileList::class, - 'git' => Git::class, - 'ghrel' => GitHubRelease::class, - 'ghtar' => GitHubTarball::class, - 'ghtagtar' => GitHubTarball::class, - 'local' => LocalDir::class, - 'pie' => PIE::class, - 'pecl' => PECL::class, - 'url' => Url::class, - 'php-release' => PhpRelease::class, - 'hosted' => HostedPackageBin::class, -]; diff --git a/src/StaticPHP/Artifact/ArtifactDownloader.php b/src/StaticPHP/Artifact/ArtifactDownloader.php index b5e54078..8b64b60c 100644 --- a/src/StaticPHP/Artifact/ArtifactDownloader.php +++ b/src/StaticPHP/Artifact/ArtifactDownloader.php @@ -6,11 +6,19 @@ namespace StaticPHP\Artifact; use Psr\Log\LogLevel; use StaticPHP\Artifact\Downloader\DownloadResult; +use StaticPHP\Artifact\Downloader\Type\BitBucketTag; use StaticPHP\Artifact\Downloader\Type\CheckUpdateInterface; use StaticPHP\Artifact\Downloader\Type\CheckUpdateResult; use StaticPHP\Artifact\Downloader\Type\DownloadTypeInterface; +use StaticPHP\Artifact\Downloader\Type\FileList; use StaticPHP\Artifact\Downloader\Type\Git; +use StaticPHP\Artifact\Downloader\Type\GitHubRelease; +use StaticPHP\Artifact\Downloader\Type\GitHubTarball; +use StaticPHP\Artifact\Downloader\Type\HostedPackageBin; use StaticPHP\Artifact\Downloader\Type\LocalDir; +use StaticPHP\Artifact\Downloader\Type\PECL; +use StaticPHP\Artifact\Downloader\Type\PhpRelease; +use StaticPHP\Artifact\Downloader\Type\PIE; use StaticPHP\Artifact\Downloader\Type\Url; use StaticPHP\Artifact\Downloader\Type\ValidatorInterface; use StaticPHP\DI\ApplicationContext; @@ -31,6 +39,21 @@ use ZM\Logger\ConsoleColor; */ class ArtifactDownloader { + public const array DOWNLOADERS = [ + 'bitbuckettag' => BitBucketTag::class, + 'filelist' => FileList::class, + 'git' => Git::class, + 'ghrel' => GitHubRelease::class, + 'ghtar' => GitHubTarball::class, + 'ghtagtar' => GitHubTarball::class, + 'local' => LocalDir::class, + 'pie' => PIE::class, + 'pecl' => PECL::class, + 'url' => Url::class, + 'php-release' => PhpRelease::class, + 'hosted' => HostedPackageBin::class, + ]; + /** @var array> */ protected array $downloaders = []; @@ -198,7 +221,7 @@ class ArtifactDownloader $this->_before_files = FileSystem::scanDirFiles(DOWNLOAD_PATH, false, true, true) ?: []; // load downloaders - $this->downloaders = require ROOT_DIR . '/config/downloader.php'; + $this->downloaders = self::DOWNLOADERS; } /**