diff --git a/src/SPC/builder/BuilderProvider.php b/src/SPC/builder/BuilderProvider.php index 18636952..d9062d06 100644 --- a/src/SPC/builder/BuilderProvider.php +++ b/src/SPC/builder/BuilderProvider.php @@ -8,8 +8,6 @@ use SPC\builder\freebsd\BSDBuilder; use SPC\builder\linux\LinuxBuilder; use SPC\builder\macos\MacOSBuilder; use SPC\builder\windows\WindowsBuilder; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use Symfony\Component\Console\Input\InputInterface; @@ -20,11 +18,6 @@ class BuilderProvider { private static ?BuilderBase $builder = null; - /** - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException - */ public static function makeBuilderByInput(InputInterface $input): BuilderBase { ini_set('memory_limit', '4G'); @@ -39,9 +32,6 @@ class BuilderProvider return self::$builder; } - /** - * @throws WrongUsageException - */ public static function getBuilder(): BuilderBase { if (self::$builder === null) { diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 435582c0..dae38a5d 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -24,11 +24,6 @@ class Extension protected string $source_dir; - /** - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException - */ public function __construct(protected string $name, protected BuilderBase $builder) { $ext_type = Config::getExt($this->name, 'type'); @@ -63,9 +58,6 @@ class Extension /** * 获取开启该扩展的 PHP 编译添加的参数 - * - * @throws FileSystemException - * @throws WrongUsageException */ public function getConfigureArg(bool $shared = false): string { @@ -80,9 +72,6 @@ class Extension /** * 根据 ext 的 arg-type 获取对应开启的参数,一般都是 --enable-xxx 和 --with-xxx - * - * @throws FileSystemException - * @throws WrongUsageException */ public function getEnableArg(bool $shared = false): string { @@ -112,10 +101,6 @@ class Extension /** * 检查下依赖就行了,作用是导入依赖给 Extension 对象,今后可以对库依赖进行选择性处理 - * - * @throws RuntimeException - * @throws FileSystemException - * @throws WrongUsageException */ public function checkDependency(): static { @@ -259,8 +244,6 @@ class Extension * i.e.; pdo_pgsql would return: * * `-d "extension=pgsql" -d "extension=pdo_pgsql"` - * @throws FileSystemException - * @throws WrongUsageException */ public function getSharedExtensionLoadString(): string { @@ -300,9 +283,6 @@ class Extension return $ret; } - /** - * @throws RuntimeException - */ public function runCliCheckUnix(): void { // Run compile check if build target is cli @@ -333,9 +313,6 @@ class Extension } } - /** - * @throws RuntimeException - */ public function runCliCheckWindows(): void { // Run compile check if build target is cli @@ -368,9 +345,6 @@ class Extension /** * Build shared extension - * - * @throws WrongUsageException - * @throws RuntimeException */ public function buildShared(): void { @@ -406,12 +380,6 @@ class Extension /** * Build shared extension for Unix - * - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException - * @throws \ReflectionException - * @throws \Throwable */ public function buildUnixShared(): void { @@ -506,9 +474,6 @@ class Extension return $this->build_static; } - /** - * @throws RuntimeException - */ protected function addLibraryDependency(string $name, bool $optional = false): void { $depLib = $this->builder->getLib($name); @@ -522,9 +487,6 @@ class Extension } } - /** - * @throws RuntimeException - */ protected function addExtensionDependency(string $name, bool $optional = false): void { $depExt = $this->builder->getExt($name); diff --git a/src/SPC/builder/LibraryBase.php b/src/SPC/builder/LibraryBase.php index e1a3b03a..1e0d287e 100644 --- a/src/SPC/builder/LibraryBase.php +++ b/src/SPC/builder/LibraryBase.php @@ -27,9 +27,6 @@ abstract class LibraryBase protected bool $patched = false; - /** - * @throws RuntimeException - */ public function __construct(?string $source_dir = null) { if (static::NAME === 'unknown') { @@ -40,10 +37,7 @@ abstract class LibraryBase /** * Try to install or build this library. - * @param bool $force If true, force install or build - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException + * @param bool $force If true, force install or build */ public function setup(bool $force = false): int { @@ -107,10 +101,6 @@ abstract class LibraryBase /** * Calculate dependencies for current library. - * - * @throws RuntimeException - * @throws FileSystemException - * @throws WrongUsageException */ public function calcDependency(): void { @@ -131,9 +121,6 @@ abstract class LibraryBase /** * Get config static libs. - * - * @throws FileSystemException - * @throws WrongUsageException */ public function getStaticLibs(): array { @@ -142,9 +129,6 @@ abstract class LibraryBase /** * Get config headers. - * - * @throws FileSystemException - * @throws WrongUsageException */ public function getHeaders(): array { @@ -153,19 +137,12 @@ abstract class LibraryBase /** * Get binary files. - * - * @throws FileSystemException - * @throws WrongUsageException */ public function getBinaryFiles(): array { return Config::getLib(static::NAME, 'bin', []); } - /** - * @throws WrongUsageException - * @throws FileSystemException - */ public function tryInstall(array $lock, bool $force_install = false): int { $install_file = $lock['filename']; @@ -194,10 +171,6 @@ abstract class LibraryBase * BUILD_STATUS_OK if build success * BUILD_STATUS_ALREADY if already built * BUILD_STATUS_FAILED if build failed - * - * @throws RuntimeException - * @throws FileSystemException - * @throws WrongUsageException */ public function tryBuild(bool $force_build = false): int { @@ -319,8 +292,6 @@ abstract class LibraryBase /** * Build this library. - * - * @throws RuntimeException */ abstract protected function build(); @@ -351,8 +322,6 @@ abstract class LibraryBase /** * Add lib dependency - * - * @throws RuntimeException */ protected function addLibraryDependency(string $name, bool $optional = false): void { diff --git a/src/SPC/builder/extension/bz2.php b/src/SPC/builder/extension/bz2.php index 88f22e56..c3bacb70 100644 --- a/src/SPC/builder/extension/bz2.php +++ b/src/SPC/builder/extension/bz2.php @@ -6,18 +6,12 @@ namespace SPC\builder\extension; use SPC\builder\Extension; use SPC\builder\macos\MacOSBuilder; -use SPC\exception\FileSystemException; -use SPC\exception\WrongUsageException; use SPC\store\FileSystem; use SPC\util\CustomExt; #[CustomExt('bz2')] class bz2 extends Extension { - /** - * @throws FileSystemException - * @throws WrongUsageException - */ public function patchBeforeConfigure(): bool { $frameworks = $this->builder instanceof MacOSBuilder ? ' ' . $this->builder->getFrameworks(true) . ' ' : ''; diff --git a/src/SPC/builder/extension/curl.php b/src/SPC/builder/extension/curl.php index 17db61d3..0a9c6a1c 100644 --- a/src/SPC/builder/extension/curl.php +++ b/src/SPC/builder/extension/curl.php @@ -16,9 +16,6 @@ use SPC\util\CustomExt; #[CustomExt('curl')] class curl extends Extension { - /** - * @throws FileSystemException - */ public function patchBeforeBuildconf(): bool { logger()->info('patching before-configure for curl checks'); @@ -46,10 +43,6 @@ class curl extends Extension return true; } - /** - * @throws FileSystemException - * @throws WrongUsageException - */ public function patchBeforeConfigure(): bool { $frameworks = $this->builder instanceof MacOSBuilder ? ' ' . $this->builder->getFrameworks(true) . ' ' : ''; diff --git a/src/SPC/builder/extension/dom.php b/src/SPC/builder/extension/dom.php index 85437f62..54a497e9 100644 --- a/src/SPC/builder/extension/dom.php +++ b/src/SPC/builder/extension/dom.php @@ -5,16 +5,12 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; -use SPC\exception\RuntimeException; use SPC\store\FileSystem; use SPC\util\CustomExt; #[CustomExt('dom')] class dom extends Extension { - /** - * @throws RuntimeException - */ public function getUnixConfigureArg(bool $shared = false): string { $arg = '--enable-dom' . ($shared ? '=shared' : ''); diff --git a/src/SPC/builder/extension/ev.php b/src/SPC/builder/extension/ev.php index 1eb83a20..8e391244 100644 --- a/src/SPC/builder/extension/ev.php +++ b/src/SPC/builder/extension/ev.php @@ -5,16 +5,12 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; -use SPC\exception\FileSystemException; use SPC\store\FileSystem; use SPC\util\CustomExt; #[CustomExt('ev')] class ev extends Extension { - /** - * @throws FileSystemException - */ public function patchBeforeBuildconf(): bool { /* diff --git a/src/SPC/builder/extension/event.php b/src/SPC/builder/extension/event.php index d2d063b2..0a981f91 100644 --- a/src/SPC/builder/extension/event.php +++ b/src/SPC/builder/extension/event.php @@ -6,7 +6,6 @@ namespace SPC\builder\extension; use SPC\builder\Extension; use SPC\builder\macos\MacOSBuilder; -use SPC\exception\FileSystemException; use SPC\store\FileSystem; use SPC\util\CustomExt; @@ -27,18 +26,12 @@ class event extends Extension return $arg; } - /** - * @throws FileSystemException - */ public function patchBeforeConfigure(): bool { FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-levent_openssl/', $this->getLibFilesString()); return true; } - /** - * @throws FileSystemException - */ public function patchBeforeMake(): bool { $patched = parent::patchBeforeMake(); diff --git a/src/SPC/builder/extension/gettext.php b/src/SPC/builder/extension/gettext.php index c1176869..dc4f58aa 100644 --- a/src/SPC/builder/extension/gettext.php +++ b/src/SPC/builder/extension/gettext.php @@ -6,17 +6,12 @@ namespace SPC\builder\extension; use SPC\builder\Extension; use SPC\builder\macos\MacOSBuilder; -use SPC\exception\FileSystemException; -use SPC\exception\WrongUsageException; use SPC\store\FileSystem; use SPC\util\CustomExt; #[CustomExt('gettext')] class gettext extends Extension { - /** - * @throws FileSystemException - */ public function patchBeforeBuildconf(): bool { if ($this->builder instanceof MacOSBuilder) { @@ -25,10 +20,6 @@ class gettext extends Extension return true; } - /** - * @throws WrongUsageException - * @throws FileSystemException - */ public function patchBeforeConfigure(): bool { if ($this->builder instanceof MacOSBuilder) { diff --git a/src/SPC/builder/extension/glfw.php b/src/SPC/builder/extension/glfw.php index 3ebb5228..7cfdaaaf 100644 --- a/src/SPC/builder/extension/glfw.php +++ b/src/SPC/builder/extension/glfw.php @@ -5,16 +5,12 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; -use SPC\exception\RuntimeException; use SPC\store\FileSystem; use SPC\util\CustomExt; #[CustomExt('glfw')] class glfw extends Extension { - /** - * @throws RuntimeException - */ public function patchBeforeBuildconf(): bool { if (file_exists(SOURCE_PATH . '/php-src/ext/glfw')) { diff --git a/src/SPC/builder/extension/imap.php b/src/SPC/builder/extension/imap.php index d220bc9b..77137f0a 100644 --- a/src/SPC/builder/extension/imap.php +++ b/src/SPC/builder/extension/imap.php @@ -24,9 +24,6 @@ class imap extends Extension return false; } - /** - * @throws WrongUsageException - */ public function validate(): void { if ($this->builder->getOption('enable-zts')) { diff --git a/src/SPC/builder/extension/memcache.php b/src/SPC/builder/extension/memcache.php index 479744fd..b63fa47a 100644 --- a/src/SPC/builder/extension/memcache.php +++ b/src/SPC/builder/extension/memcache.php @@ -5,7 +5,6 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; -use SPC\exception\FileSystemException; use SPC\store\FileSystem; use SPC\util\CustomExt; @@ -17,9 +16,6 @@ class memcache extends Extension return '--enable-memcache' . ($shared ? '=shared' : '') . ' --with-zlib-dir=' . BUILD_ROOT_PATH; } - /** - * @throws FileSystemException - */ public function patchBeforeBuildconf(): bool { FileSystem::replaceFileStr( diff --git a/src/SPC/builder/extension/opcache.php b/src/SPC/builder/extension/opcache.php index b73dbbd6..58139dd1 100644 --- a/src/SPC/builder/extension/opcache.php +++ b/src/SPC/builder/extension/opcache.php @@ -5,7 +5,6 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; -use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\SourcePatcher; use SPC\util\CustomExt; @@ -13,10 +12,6 @@ use SPC\util\CustomExt; #[CustomExt('opcache')] class opcache extends Extension { - /** - * @throws WrongUsageException - * @throws RuntimeException - */ public function validate(): void { if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') { diff --git a/src/SPC/builder/extension/pdo_sqlite.php b/src/SPC/builder/extension/pdo_sqlite.php index a33dbbba..4d6f296c 100644 --- a/src/SPC/builder/extension/pdo_sqlite.php +++ b/src/SPC/builder/extension/pdo_sqlite.php @@ -5,16 +5,12 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; -use SPC\exception\FileSystemException; use SPC\store\FileSystem; use SPC\util\CustomExt; #[CustomExt('pdo_sqlite')] class pdo_sqlite extends Extension { - /** - * @throws FileSystemException - */ public function patchBeforeConfigure(): bool { FileSystem::replaceFileRegex( diff --git a/src/SPC/builder/extension/pgsql.php b/src/SPC/builder/extension/pgsql.php index e1788cfa..f22f7ba6 100644 --- a/src/SPC/builder/extension/pgsql.php +++ b/src/SPC/builder/extension/pgsql.php @@ -5,20 +5,12 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; -use SPC\exception\WrongUsageException; use SPC\store\FileSystem; use SPC\util\CustomExt; #[CustomExt('pgsql')] class pgsql extends Extension { - /** - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException - */ public function patchBeforeConfigure(): bool { FileSystem::replaceFileRegex( @@ -29,10 +21,6 @@ class pgsql extends Extension return true; } - /** - * @throws WrongUsageException - * @throws RuntimeException - */ public function getUnixConfigureArg(bool $shared = false): string { if ($this->builder->getPHPVersionID() >= 80400) { @@ -46,10 +34,6 @@ class pgsql extends Extension return '--with-pgsql=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH; } - /** - * @throws WrongUsageException - * @throws RuntimeException - */ public function getWindowsConfigureArg(bool $shared = false): string { if ($this->builder->getPHPVersionID() >= 80400) { diff --git a/src/SPC/builder/extension/rar.php b/src/SPC/builder/extension/rar.php index 5f3aaa01..6db8c03c 100644 --- a/src/SPC/builder/extension/rar.php +++ b/src/SPC/builder/extension/rar.php @@ -6,16 +6,12 @@ namespace SPC\builder\extension; use SPC\builder\Extension; use SPC\builder\macos\MacOSBuilder; -use SPC\exception\FileSystemException; use SPC\store\FileSystem; use SPC\util\CustomExt; #[CustomExt('rar')] class rar extends Extension { - /** - * @throws FileSystemException - */ public function patchBeforeBuildconf(): bool { // workaround for newer Xcode clang (>= 15.0) diff --git a/src/SPC/builder/extension/readline.php b/src/SPC/builder/extension/readline.php index 939484da..a8ee48aa 100644 --- a/src/SPC/builder/extension/readline.php +++ b/src/SPC/builder/extension/readline.php @@ -5,16 +5,12 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; -use SPC\exception\FileSystemException; use SPC\store\FileSystem; use SPC\util\CustomExt; #[CustomExt('readline')] class readline extends Extension { - /** - * @throws FileSystemException - */ public function patchBeforeConfigure(): bool { FileSystem::replaceFileRegex( diff --git a/src/SPC/builder/extension/snappy.php b/src/SPC/builder/extension/snappy.php index 896a9be2..13644edf 100644 --- a/src/SPC/builder/extension/snappy.php +++ b/src/SPC/builder/extension/snappy.php @@ -6,16 +6,12 @@ namespace SPC\builder\extension; use SPC\builder\Extension; use SPC\builder\macos\MacOSBuilder; -use SPC\exception\FileSystemException; use SPC\store\FileSystem; use SPC\util\CustomExt; #[CustomExt('snappy')] class snappy extends Extension { - /** - * @throws FileSystemException - */ public function patchBeforeConfigure(): bool { FileSystem::replaceFileRegex( diff --git a/src/SPC/builder/extension/ssh2.php b/src/SPC/builder/extension/ssh2.php index eeabaa72..aa6a439d 100644 --- a/src/SPC/builder/extension/ssh2.php +++ b/src/SPC/builder/extension/ssh2.php @@ -5,16 +5,12 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; -use SPC\exception\FileSystemException; use SPC\store\FileSystem; use SPC\util\CustomExt; #[CustomExt('ssh2')] class ssh2 extends Extension { - /** - * @throws FileSystemException - */ public function patchBeforeConfigure(): bool { FileSystem::replaceFileRegex( diff --git a/src/SPC/builder/extension/swow.php b/src/SPC/builder/extension/swow.php index 390ec27f..77f67d26 100644 --- a/src/SPC/builder/extension/swow.php +++ b/src/SPC/builder/extension/swow.php @@ -26,9 +26,6 @@ class swow extends Extension return $arg; } - /** - * @throws RuntimeException - */ public function patchBeforeBuildconf(): bool { if ($this->builder->getPHPVersionID() >= 80000 && !is_link(SOURCE_PATH . '/php-src/ext/swow')) { diff --git a/src/SPC/builder/extension/xml.php b/src/SPC/builder/extension/xml.php index bd64d346..f4b5f569 100644 --- a/src/SPC/builder/extension/xml.php +++ b/src/SPC/builder/extension/xml.php @@ -16,9 +16,6 @@ use SPC\util\CustomExt; #[CustomExt('simplexml')] class xml extends Extension { - /** - * @throws RuntimeException - */ public function getUnixConfigureArg(bool $shared = false): string { $arg = match ($this->name) { diff --git a/src/SPC/builder/freebsd/BSDBuilder.php b/src/SPC/builder/freebsd/BSDBuilder.php index ba04675c..dcaa5a2d 100644 --- a/src/SPC/builder/freebsd/BSDBuilder.php +++ b/src/SPC/builder/freebsd/BSDBuilder.php @@ -5,8 +5,6 @@ declare(strict_types=1); namespace SPC\builder\freebsd; use SPC\builder\unix\UnixBuilderBase; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\FileSystem; use SPC\store\SourcePatcher; @@ -16,11 +14,6 @@ class BSDBuilder extends UnixBuilderBase /** @var bool Micro patch phar flag */ private bool $phar_patched = false; - /** - * @throws RuntimeException - * @throws WrongUsageException - * @throws FileSystemException - */ public function __construct(array $options = []) { $this->options = $options; @@ -56,10 +49,7 @@ class BSDBuilder extends UnixBuilderBase /** * Just start to build statically linked php binary * - * @param int $build_target build target - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException + * @param int $build_target build target */ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void { @@ -148,9 +138,6 @@ class BSDBuilder extends UnixBuilderBase /** * Build cli sapi - * - * @throws RuntimeException - * @throws FileSystemException */ protected function buildCli(): void { @@ -170,10 +157,6 @@ class BSDBuilder extends UnixBuilderBase /** * Build phpmicro sapi - * - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException */ protected function buildMicro(): void { @@ -209,9 +192,6 @@ class BSDBuilder extends UnixBuilderBase /** * Build fpm sapi - * - * @throws RuntimeException - * @throws FileSystemException */ protected function buildFpm(): void { @@ -230,8 +210,6 @@ class BSDBuilder extends UnixBuilderBase /** * Build embed sapi - * - * @throws RuntimeException */ protected function buildEmbed(): void { diff --git a/src/SPC/builder/freebsd/SystemUtil.php b/src/SPC/builder/freebsd/SystemUtil.php index 13aaafcc..782586e2 100644 --- a/src/SPC/builder/freebsd/SystemUtil.php +++ b/src/SPC/builder/freebsd/SystemUtil.php @@ -15,8 +15,6 @@ class SystemUtil /** * Get Logic CPU Count for macOS - * - * @throws RuntimeException */ public static function getCpuCount(): int { @@ -31,9 +29,8 @@ class SystemUtil /** * Get Target Arch CFlags * - * @param string $arch Arch Name - * @return string return Arch CFlags string - * @throws WrongUsageException + * @param string $arch Arch Name + * @return string return Arch CFlags string */ public static function getArchCFlags(string $arch): string { diff --git a/src/SPC/builder/freebsd/library/openssl.php b/src/SPC/builder/freebsd/library/openssl.php index 1bbabf52..6c60b7d8 100644 --- a/src/SPC/builder/freebsd/library/openssl.php +++ b/src/SPC/builder/freebsd/library/openssl.php @@ -22,19 +22,11 @@ declare(strict_types=1); namespace SPC\builder\freebsd\library; use SPC\builder\macos\library\MacOSLibraryBase; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; -use SPC\exception\WrongUsageException; class openssl extends BSDLibraryBase { public const NAME = 'openssl'; - /** - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException - */ protected function build(): void { [$lib,,$destdir] = SEPARATED_PATH; diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 38990403..8eb766f2 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -5,8 +5,7 @@ declare(strict_types=1); namespace SPC\builder\linux; use SPC\builder\unix\UnixBuilderBase; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; +use SPC\exception\PatchException; use SPC\exception\WrongUsageException; use SPC\store\FileSystem; use SPC\store\SourcePatcher; @@ -19,10 +18,6 @@ class LinuxBuilder extends UnixBuilderBase /** @var bool Micro patch phar flag */ private bool $phar_patched = false; - /** - * @throws FileSystemException - * @throws WrongUsageException - */ public function __construct(array $options = []) { $this->options = $options; @@ -45,10 +40,7 @@ class LinuxBuilder extends UnixBuilderBase /** * Build PHP from source. * - * @param int $build_target Build target, use `BUILD_TARGET_*` constants - * @throws RuntimeException - * @throws FileSystemException - * @throws WrongUsageException + * @param int $build_target Build target, use `BUILD_TARGET_*` constants */ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void { @@ -168,9 +160,6 @@ class LinuxBuilder extends UnixBuilderBase /** * Build cli sapi - * - * @throws RuntimeException - * @throws FileSystemException */ protected function buildCli(): void { @@ -193,10 +182,6 @@ class LinuxBuilder extends UnixBuilderBase /** * Build phpmicro sapi - * - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException */ protected function buildMicro(): void { @@ -231,9 +216,6 @@ class LinuxBuilder extends UnixBuilderBase /** * Build fpm sapi - * - * @throws FileSystemException - * @throws RuntimeException */ protected function buildFpm(): void { @@ -255,8 +237,6 @@ class LinuxBuilder extends UnixBuilderBase /** * Build embed sapi - * - * @throws RuntimeException */ protected function buildEmbed(): void { @@ -346,12 +326,6 @@ class LinuxBuilder extends UnixBuilderBase /** * Return extra variables for php make command. - * - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException - * @throws \ReflectionException - * @throws \Throwable */ private function getMakeExtraVars(): array { @@ -370,8 +344,6 @@ class LinuxBuilder extends UnixBuilderBase * Strip micro.sfx for Linux. * The micro.sfx does not support UPX directly, but we can remove UPX-info segment to adapt. * This will also make micro.sfx with upx-packed more like a malware fore antivirus :( - * - * @throws RuntimeException */ private function processMicroUPX(): void { diff --git a/src/SPC/builder/linux/library/imap.php b/src/SPC/builder/linux/library/imap.php index 8203928d..a6500252 100644 --- a/src/SPC/builder/linux/library/imap.php +++ b/src/SPC/builder/linux/library/imap.php @@ -4,8 +4,6 @@ declare(strict_types=1); namespace SPC\builder\linux\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\store\FileSystem; use SPC\util\SPCTarget; @@ -13,9 +11,6 @@ class imap extends LinuxLibraryBase { public const NAME = 'imap'; - /** - * @throws FileSystemException - */ public function patchBeforeBuild(): bool { $cc = getenv('CC') ?: 'gcc'; diff --git a/src/SPC/builder/linux/library/libffi.php b/src/SPC/builder/linux/library/libffi.php index e47d3d23..916cb9a6 100644 --- a/src/SPC/builder/linux/library/libffi.php +++ b/src/SPC/builder/linux/library/libffi.php @@ -4,18 +4,12 @@ declare(strict_types=1); namespace SPC\builder\linux\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\util\executor\UnixAutoconfExecutor; class libffi extends LinuxLibraryBase { public const NAME = 'libffi'; - /** - * @throws RuntimeException - * @throws FileSystemException - */ public function build(): void { UnixAutoconfExecutor::create($this) diff --git a/src/SPC/builder/linux/library/libpng.php b/src/SPC/builder/linux/library/libpng.php index c25dd654..30d5a7f3 100644 --- a/src/SPC/builder/linux/library/libpng.php +++ b/src/SPC/builder/linux/library/libpng.php @@ -21,20 +21,12 @@ declare(strict_types=1); namespace SPC\builder\linux\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; -use SPC\exception\WrongUsageException; use SPC\util\executor\UnixAutoconfExecutor; class libpng extends LinuxLibraryBase { public const NAME = 'libpng'; - /** - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException - */ public function build(): void { UnixAutoconfExecutor::create($this) diff --git a/src/SPC/builder/linux/library/openssl.php b/src/SPC/builder/linux/library/openssl.php index 3da4bb95..95b6825b 100644 --- a/src/SPC/builder/linux/library/openssl.php +++ b/src/SPC/builder/linux/library/openssl.php @@ -21,9 +21,6 @@ declare(strict_types=1); namespace SPC\builder\linux\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; -use SPC\exception\WrongUsageException; use SPC\store\FileSystem; class openssl extends LinuxLibraryBase @@ -32,11 +29,6 @@ class openssl extends LinuxLibraryBase public const NAME = 'openssl'; - /** - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException - */ public function build(): void { $extra = ''; diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index 768567c8..851d7de4 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -6,8 +6,6 @@ namespace SPC\builder\macos; use SPC\builder\macos\library\MacOSLibraryBase; use SPC\builder\unix\UnixBuilderBase; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\FileSystem; use SPC\store\SourcePatcher; @@ -19,11 +17,6 @@ class MacOSBuilder extends UnixBuilderBase /** @var bool Micro patch phar flag */ private bool $phar_patched = false; - /** - * @throws RuntimeException - * @throws WrongUsageException - * @throws FileSystemException - */ public function __construct(array $options = []) { $this->options = $options; @@ -48,9 +41,7 @@ class MacOSBuilder extends UnixBuilderBase /** * Get dynamically linked macOS frameworks * - * @param bool $asString If true, return as string - * @throws FileSystemException - * @throws WrongUsageException + * @param bool $asString If true, return as string */ public function getFrameworks(bool $asString = false): array|string { @@ -83,10 +74,7 @@ class MacOSBuilder extends UnixBuilderBase /** * Just start to build statically linked php binary * - * @param int $build_target build target - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException + * @param int $build_target build target */ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void { @@ -190,9 +178,6 @@ class MacOSBuilder extends UnixBuilderBase /** * Build cli sapi - * - * @throws RuntimeException - * @throws FileSystemException */ protected function buildCli(): void { @@ -209,10 +194,6 @@ class MacOSBuilder extends UnixBuilderBase /** * Build phpmicro sapi - * - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException */ protected function buildMicro(): void { @@ -248,9 +229,6 @@ class MacOSBuilder extends UnixBuilderBase /** * Build fpm sapi - * - * @throws RuntimeException - * @throws FileSystemException */ protected function buildFpm(): void { @@ -266,8 +244,6 @@ class MacOSBuilder extends UnixBuilderBase /** * Build embed sapi - * - * @throws RuntimeException */ protected function buildEmbed(): void { diff --git a/src/SPC/builder/macos/SystemUtil.php b/src/SPC/builder/macos/SystemUtil.php index 0c2d4560..74846ecf 100644 --- a/src/SPC/builder/macos/SystemUtil.php +++ b/src/SPC/builder/macos/SystemUtil.php @@ -15,8 +15,6 @@ class SystemUtil /** * Get Logic CPU Count for macOS - * - * @throws RuntimeException */ public static function getCpuCount(): int { @@ -31,9 +29,8 @@ class SystemUtil /** * Get Target Arch CFlags * - * @param string $arch Arch Name - * @return string return Arch CFlags string - * @throws WrongUsageException + * @param string $arch Arch Name + * @return string return Arch CFlags string */ public static function getArchCFlags(string $arch): string { diff --git a/src/SPC/builder/macos/library/MacOSLibraryBase.php b/src/SPC/builder/macos/library/MacOSLibraryBase.php index 336a21b0..21bb4a33 100644 --- a/src/SPC/builder/macos/library/MacOSLibraryBase.php +++ b/src/SPC/builder/macos/library/MacOSLibraryBase.php @@ -8,8 +8,6 @@ use SPC\builder\BuilderBase; use SPC\builder\LibraryBase; use SPC\builder\macos\MacOSBuilder; use SPC\builder\traits\UnixLibraryTrait; -use SPC\exception\FileSystemException; -use SPC\exception\WrongUsageException; use SPC\store\Config; abstract class MacOSLibraryBase extends LibraryBase @@ -28,10 +26,6 @@ abstract class MacOSLibraryBase extends LibraryBase return $this->builder; } - /** - * @throws WrongUsageException - * @throws FileSystemException - */ public function getFrameworks(): array { return Config::getLib(static::NAME, 'frameworks', []); diff --git a/src/SPC/builder/macos/library/curl.php b/src/SPC/builder/macos/library/curl.php index 0555f66e..2de97f32 100644 --- a/src/SPC/builder/macos/library/curl.php +++ b/src/SPC/builder/macos/library/curl.php @@ -21,7 +21,6 @@ declare(strict_types=1); namespace SPC\builder\macos\library; -use SPC\exception\FileSystemException; use SPC\store\FileSystem; class curl extends MacOSLibraryBase @@ -30,9 +29,6 @@ class curl extends MacOSLibraryBase public const NAME = 'curl'; - /** - * @throws FileSystemException - */ public function patchBeforeBuild(): bool { FileSystem::replaceFileRegex( diff --git a/src/SPC/builder/macos/library/glfw.php b/src/SPC/builder/macos/library/glfw.php index 8bc7ca18..b38818e9 100644 --- a/src/SPC/builder/macos/library/glfw.php +++ b/src/SPC/builder/macos/library/glfw.php @@ -4,18 +4,12 @@ declare(strict_types=1); namespace SPC\builder\macos\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\util\executor\UnixCMakeExecutor; class glfw extends MacOSLibraryBase { public const NAME = 'glfw'; - /** - * @throws FileSystemException - * @throws RuntimeException - */ protected function build(): void { UnixCMakeExecutor::create($this) diff --git a/src/SPC/builder/macos/library/imap.php b/src/SPC/builder/macos/library/imap.php index 6c2fb359..6f9aa984 100644 --- a/src/SPC/builder/macos/library/imap.php +++ b/src/SPC/builder/macos/library/imap.php @@ -4,8 +4,6 @@ declare(strict_types=1); namespace SPC\builder\macos\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\store\FileSystem; use SPC\store\SourcePatcher; @@ -13,10 +11,6 @@ class imap extends MacOSLibraryBase { public const NAME = 'imap'; - /** - * @throws FileSystemException - * @throws RuntimeException - */ public function patchBeforeBuild(): bool { $cc = getenv('CC') ?: 'clang'; @@ -37,9 +31,6 @@ class imap extends MacOSLibraryBase return true; } - /** - * @throws RuntimeException - */ protected function build(): void { if ($this->builder->getLib('openssl')) { diff --git a/src/SPC/builder/macos/library/libffi.php b/src/SPC/builder/macos/library/libffi.php index 992a1b75..792c2033 100644 --- a/src/SPC/builder/macos/library/libffi.php +++ b/src/SPC/builder/macos/library/libffi.php @@ -4,18 +4,12 @@ declare(strict_types=1); namespace SPC\builder\macos\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\util\executor\UnixAutoconfExecutor; class libffi extends MacOSLibraryBase { public const NAME = 'libffi'; - /** - * @throws RuntimeException - * @throws FileSystemException - */ protected function build(): void { $arch = getenv('SPC_ARCH'); diff --git a/src/SPC/builder/macos/library/libpng.php b/src/SPC/builder/macos/library/libpng.php index 0fec806e..91873bd4 100644 --- a/src/SPC/builder/macos/library/libpng.php +++ b/src/SPC/builder/macos/library/libpng.php @@ -21,20 +21,12 @@ declare(strict_types=1); namespace SPC\builder\macos\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; -use SPC\exception\WrongUsageException; use SPC\util\executor\UnixAutoconfExecutor; class libpng extends MacOSLibraryBase { public const NAME = 'libpng'; - /** - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException - */ protected function build(): void { $arch = arch2gnu(php_uname('m')); diff --git a/src/SPC/builder/macos/library/openssl.php b/src/SPC/builder/macos/library/openssl.php index df0f4a52..9265851e 100644 --- a/src/SPC/builder/macos/library/openssl.php +++ b/src/SPC/builder/macos/library/openssl.php @@ -21,9 +21,6 @@ declare(strict_types=1); namespace SPC\builder\macos\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; -use SPC\exception\WrongUsageException; use SPC\store\FileSystem; class openssl extends MacOSLibraryBase @@ -32,11 +29,6 @@ class openssl extends MacOSLibraryBase public const NAME = 'openssl'; - /** - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException - */ protected function build(): void { // lib:zlib diff --git a/src/SPC/builder/traits/UnixLibraryTrait.php b/src/SPC/builder/traits/UnixLibraryTrait.php index c45d45b2..739d16a9 100644 --- a/src/SPC/builder/traits/UnixLibraryTrait.php +++ b/src/SPC/builder/traits/UnixLibraryTrait.php @@ -13,11 +13,6 @@ use SPC\util\SPCConfigUtil; trait UnixLibraryTrait { - /** - * @throws RuntimeException - * @throws FileSystemException - * @throws WrongUsageException - */ public function getStaticLibFiles(bool $include_self = true): string { $libs = $include_self ? [$this] : []; @@ -28,11 +23,11 @@ trait UnixLibraryTrait } /** - * Patch pkgconfig file prefix + * Patch pkgconfig file prefix, exec_prefix, libdir, includedir for correct build. * - * @param array $files file list - * @throws FileSystemException - * @throws RuntimeException + * @param array $files File list to patch, if empty, will use pkg-configs from config (e.g. ['zlib.pc', 'openssl.pc']) + * @param int $patch_option Patch options + * @param null|array $custom_replace Custom replace rules, if provided, will be used to replace in the format [regex, replacement] */ public function patchPkgconfPrefix(array $files = [], int $patch_option = PKGCONF_PATCH_ALL, ?array $custom_replace = null): void { diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index b69aba2e..73cb4e07 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -70,9 +70,7 @@ abstract class UnixBuilderBase extends BuilderBase } /** - * Sanity check after build complete - * - * @throws RuntimeException + * Sanity check after build complete. */ protected function sanityCheck(int $build_target): void { @@ -170,11 +168,9 @@ abstract class UnixBuilderBase extends BuilderBase } /** - * 将编译好的二进制文件发布到 buildroot + * Deploy the binary file to the build bin path. * - * @param int $type 发布类型 - * @throws RuntimeException - * @throws FileSystemException + * @param int $type Type integer, one of BUILD_TARGET_CLI, BUILD_TARGET_MICRO, BUILD_TARGET_FPM */ protected function deployBinary(int $type): bool { @@ -192,8 +188,6 @@ abstract class UnixBuilderBase extends BuilderBase /** * Run php clean - * - * @throws RuntimeException */ protected function cleanMake(): void { @@ -203,7 +197,6 @@ abstract class UnixBuilderBase extends BuilderBase /** * Patch phpize and php-config if needed - * @throws FileSystemException */ protected function patchPhpScripts(): void { @@ -231,10 +224,6 @@ abstract class UnixBuilderBase extends BuilderBase } } - /** - * @throws WrongUsageException - * @throws RuntimeException - */ protected function buildFrankenphp(): void { $nobrotli = $this->getLib('brotli') === null ? ',nobrotli' : ''; diff --git a/src/SPC/builder/unix/library/attr.php b/src/SPC/builder/unix/library/attr.php index 71fe2623..b33cf987 100644 --- a/src/SPC/builder/unix/library/attr.php +++ b/src/SPC/builder/unix/library/attr.php @@ -4,14 +4,10 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\RuntimeException; use SPC\util\executor\UnixAutoconfExecutor; trait attr { - /** - * @throws RuntimeException - */ protected function build(): void { UnixAutoconfExecutor::create($this) diff --git a/src/SPC/builder/unix/library/brotli.php b/src/SPC/builder/unix/library/brotli.php index 6de9c15c..64331a56 100644 --- a/src/SPC/builder/unix/library/brotli.php +++ b/src/SPC/builder/unix/library/brotli.php @@ -4,17 +4,11 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\store\FileSystem; use SPC\util\executor\UnixCMakeExecutor; trait brotli { - /** - * @throws FileSystemException - * @throws RuntimeException - */ protected function build(): void { UnixCMakeExecutor::create($this) diff --git a/src/SPC/builder/unix/library/curl.php b/src/SPC/builder/unix/library/curl.php index 6e304d60..1b5eaed1 100644 --- a/src/SPC/builder/unix/library/curl.php +++ b/src/SPC/builder/unix/library/curl.php @@ -4,16 +4,10 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\util\executor\UnixCMakeExecutor; trait curl { - /** - * @throws RuntimeException - * @throws FileSystemException - */ protected function build(): void { shell()->cd($this->source_dir)->exec('sed -i.save s@\${CMAKE_C_IMPLICIT_LINK_LIBRARIES}@@ ./CMakeLists.txt'); diff --git a/src/SPC/builder/unix/library/freetype.php b/src/SPC/builder/unix/library/freetype.php index 581a5e75..a10b7fb2 100644 --- a/src/SPC/builder/unix/library/freetype.php +++ b/src/SPC/builder/unix/library/freetype.php @@ -4,19 +4,11 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; -use SPC\exception\WrongUsageException; use SPC\store\FileSystem; use SPC\util\executor\UnixCMakeExecutor; trait freetype { - /** - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException - */ protected function build(): void { $cmake = UnixCMakeExecutor::create($this) diff --git a/src/SPC/builder/unix/library/gmp.php b/src/SPC/builder/unix/library/gmp.php index a8e4d15c..f09976d8 100644 --- a/src/SPC/builder/unix/library/gmp.php +++ b/src/SPC/builder/unix/library/gmp.php @@ -4,16 +4,10 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\util\executor\UnixAutoconfExecutor; trait gmp { - /** - * @throws FileSystemException - * @throws RuntimeException - */ protected function build(): void { UnixAutoconfExecutor::create($this)->configure()->make(); diff --git a/src/SPC/builder/unix/library/imagemagick.php b/src/SPC/builder/unix/library/imagemagick.php index 68bd88e9..2d312549 100644 --- a/src/SPC/builder/unix/library/imagemagick.php +++ b/src/SPC/builder/unix/library/imagemagick.php @@ -4,20 +4,12 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; -use SPC\exception\WrongUsageException; use SPC\store\FileSystem; use SPC\util\executor\UnixAutoconfExecutor; use SPC\util\SPCTarget; trait imagemagick { - /** - * @throws RuntimeException - * @throws FileSystemException - * @throws WrongUsageException - */ protected function build(): void { $ac = UnixAutoconfExecutor::create($this) diff --git a/src/SPC/builder/unix/library/jbig.php b/src/SPC/builder/unix/library/jbig.php index 85e24748..5b00f0d6 100644 --- a/src/SPC/builder/unix/library/jbig.php +++ b/src/SPC/builder/unix/library/jbig.php @@ -4,24 +4,16 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\store\FileSystem; trait jbig { - /** - * @throws FileSystemException - */ public function patchBeforeBuild(): bool { FileSystem::replaceFileStr($this->source_dir . '/Makefile', 'CFLAGS = -O2 -W -Wno-unused-result', 'CFLAGS = -O2 -W -Wno-unused-result -fPIC'); return true; } - /** - * @throws RuntimeException - */ protected function build(): void { shell()->cd($this->source_dir)->initializeEnv($this) diff --git a/src/SPC/builder/unix/library/lerc.php b/src/SPC/builder/unix/library/lerc.php index 290c0f61..5ad0e572 100644 --- a/src/SPC/builder/unix/library/lerc.php +++ b/src/SPC/builder/unix/library/lerc.php @@ -4,16 +4,10 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\util\executor\UnixCMakeExecutor; trait lerc { - /** - * @throws FileSystemException - * @throws RuntimeException - */ protected function build(): void { UnixCMakeExecutor::create($this) diff --git a/src/SPC/builder/unix/library/libacl.php b/src/SPC/builder/unix/library/libacl.php index c25e7336..223e09fc 100644 --- a/src/SPC/builder/unix/library/libacl.php +++ b/src/SPC/builder/unix/library/libacl.php @@ -4,16 +4,11 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\store\FileSystem; use SPC\util\executor\UnixAutoconfExecutor; trait libacl { - /** - * @throws FileSystemException - */ public function patchBeforeMake(): bool { $file_path = SOURCE_PATH . '/php-src/Makefile'; @@ -25,9 +20,6 @@ trait libacl return true; } - /** - * @throws RuntimeException - */ protected function build(): void { UnixAutoconfExecutor::create($this) diff --git a/src/SPC/builder/unix/library/libavif.php b/src/SPC/builder/unix/library/libavif.php index dea45c6e..fbd4fa18 100644 --- a/src/SPC/builder/unix/library/libavif.php +++ b/src/SPC/builder/unix/library/libavif.php @@ -4,18 +4,10 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; -use SPC\exception\WrongUsageException; use SPC\util\executor\UnixCMakeExecutor; trait libavif { - /** - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException - */ protected function build(): void { UnixCMakeExecutor::create($this) diff --git a/src/SPC/builder/unix/library/libcares.php b/src/SPC/builder/unix/library/libcares.php index 59d9852e..90fd9d76 100644 --- a/src/SPC/builder/unix/library/libcares.php +++ b/src/SPC/builder/unix/library/libcares.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\RuntimeException; use SPC\store\FileSystem; use SPC\util\executor\UnixAutoconfExecutor; @@ -20,9 +19,6 @@ trait libcares return false; } - /** - * @throws RuntimeException - */ protected function build(): void { UnixAutoconfExecutor::create($this)->configure('--disable-tests')->make(); diff --git a/src/SPC/builder/unix/library/libde265.php b/src/SPC/builder/unix/library/libde265.php index eaba0cfc..9549a2ec 100644 --- a/src/SPC/builder/unix/library/libde265.php +++ b/src/SPC/builder/unix/library/libde265.php @@ -4,16 +4,10 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\util\executor\UnixCMakeExecutor; trait libde265 { - /** - * @throws RuntimeException - * @throws FileSystemException - */ protected function build(): void { UnixCMakeExecutor::create($this) diff --git a/src/SPC/builder/unix/library/libevent.php b/src/SPC/builder/unix/library/libevent.php index ab4838e3..c2474d54 100644 --- a/src/SPC/builder/unix/library/libevent.php +++ b/src/SPC/builder/unix/library/libevent.php @@ -4,8 +4,6 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\store\FileSystem; use SPC\util\executor\UnixCMakeExecutor; @@ -34,10 +32,6 @@ trait libevent } } - /** - * @throws RuntimeException - * @throws FileSystemException - */ protected function build(): void { $cmake = UnixCMakeExecutor::create($this) diff --git a/src/SPC/builder/unix/library/libheif.php b/src/SPC/builder/unix/library/libheif.php index 680f3321..095a1f82 100644 --- a/src/SPC/builder/unix/library/libheif.php +++ b/src/SPC/builder/unix/library/libheif.php @@ -4,8 +4,6 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\store\FileSystem; use SPC\util\executor\UnixCMakeExecutor; @@ -24,10 +22,6 @@ trait libheif return false; } - /** - * @throws RuntimeException - * @throws FileSystemException - */ protected function build(): void { UnixCMakeExecutor::create($this) diff --git a/src/SPC/builder/unix/library/libjpeg.php b/src/SPC/builder/unix/library/libjpeg.php index 6196f8af..862c1e88 100644 --- a/src/SPC/builder/unix/library/libjpeg.php +++ b/src/SPC/builder/unix/library/libjpeg.php @@ -4,18 +4,10 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; -use SPC\exception\WrongUsageException; use SPC\util\executor\UnixCMakeExecutor; trait libjpeg { - /** - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException - */ protected function build(): void { UnixCMakeExecutor::create($this) diff --git a/src/SPC/builder/unix/library/librabbitmq.php b/src/SPC/builder/unix/library/librabbitmq.php index 1e1e64d1..ca67b689 100644 --- a/src/SPC/builder/unix/library/librabbitmq.php +++ b/src/SPC/builder/unix/library/librabbitmq.php @@ -4,16 +4,10 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\util\executor\UnixCMakeExecutor; trait librabbitmq { - /** - * @throws RuntimeException - * @throws FileSystemException - */ protected function build(): void { UnixCMakeExecutor::create($this)->addConfigureArgs('-DBUILD_STATIC_LIBS=ON')->build(); diff --git a/src/SPC/builder/unix/library/librdkafka.php b/src/SPC/builder/unix/library/librdkafka.php index e2c3b46e..f2bea09f 100644 --- a/src/SPC/builder/unix/library/librdkafka.php +++ b/src/SPC/builder/unix/library/librdkafka.php @@ -4,8 +4,6 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\store\FileSystem; use SPC\util\executor\UnixAutoconfExecutor; @@ -26,10 +24,6 @@ trait librdkafka return true; } - /** - * @throws FileSystemException - * @throws RuntimeException - */ protected function build(): void { UnixAutoconfExecutor::create($this) diff --git a/src/SPC/builder/unix/library/libssh2.php b/src/SPC/builder/unix/library/libssh2.php index 26337ee4..91fed1a7 100644 --- a/src/SPC/builder/unix/library/libssh2.php +++ b/src/SPC/builder/unix/library/libssh2.php @@ -4,16 +4,10 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\util\executor\UnixCMakeExecutor; trait libssh2 { - /** - * @throws RuntimeException - * @throws FileSystemException - */ protected function build(): void { UnixCMakeExecutor::create($this) diff --git a/src/SPC/builder/unix/library/libtiff.php b/src/SPC/builder/unix/library/libtiff.php index b4afdd7f..ed14f426 100644 --- a/src/SPC/builder/unix/library/libtiff.php +++ b/src/SPC/builder/unix/library/libtiff.php @@ -4,18 +4,12 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\store\FileSystem; use SPC\util\executor\UnixAutoconfExecutor; use SPC\util\SPCTarget; trait libtiff { - /** - * @throws FileSystemException - * @throws RuntimeException - */ protected function build(): void { $libcpp = SPCTarget::getTargetOS() === 'Linux' ? '-lstdc++' : '-lc++'; diff --git a/src/SPC/builder/unix/library/libuuid.php b/src/SPC/builder/unix/library/libuuid.php index 197e0f80..2463ac78 100644 --- a/src/SPC/builder/unix/library/libuuid.php +++ b/src/SPC/builder/unix/library/libuuid.php @@ -4,15 +4,11 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; use SPC\store\FileSystem; use SPC\util\executor\UnixCMakeExecutor; trait libuuid { - /** - * @throws FileSystemException - */ protected function build(): void { UnixCMakeExecutor::create($this)->toStep(2)->build(); diff --git a/src/SPC/builder/unix/library/libuv.php b/src/SPC/builder/unix/library/libuv.php index b4b5e01c..52e4c819 100644 --- a/src/SPC/builder/unix/library/libuv.php +++ b/src/SPC/builder/unix/library/libuv.php @@ -4,16 +4,10 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\util\executor\UnixCMakeExecutor; trait libuv { - /** - * @throws FileSystemException - * @throws RuntimeException - */ protected function build(): void { UnixCMakeExecutor::create($this) diff --git a/src/SPC/builder/unix/library/libwebp.php b/src/SPC/builder/unix/library/libwebp.php index a7651dd5..46a88af4 100644 --- a/src/SPC/builder/unix/library/libwebp.php +++ b/src/SPC/builder/unix/library/libwebp.php @@ -4,18 +4,10 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; -use SPC\exception\WrongUsageException; use SPC\util\executor\UnixCMakeExecutor; trait libwebp { - /** - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException - */ protected function build(): void { UnixCMakeExecutor::create($this) diff --git a/src/SPC/builder/unix/library/libxml2.php b/src/SPC/builder/unix/library/libxml2.php index 85a6e8b6..87fbab10 100644 --- a/src/SPC/builder/unix/library/libxml2.php +++ b/src/SPC/builder/unix/library/libxml2.php @@ -5,15 +5,11 @@ declare(strict_types=1); namespace SPC\builder\unix\library; use SPC\builder\linux\library\LinuxLibraryBase; -use SPC\exception\FileSystemException; use SPC\store\FileSystem; use SPC\util\executor\UnixCMakeExecutor; trait libxml2 { - /** - * @throws FileSystemException - */ public function build(): void { $cmake = UnixCMakeExecutor::create($this) diff --git a/src/SPC/builder/unix/library/libxslt.php b/src/SPC/builder/unix/library/libxslt.php index 1c584be2..f0e7d512 100644 --- a/src/SPC/builder/unix/library/libxslt.php +++ b/src/SPC/builder/unix/library/libxslt.php @@ -6,18 +6,10 @@ namespace SPC\builder\unix\library; use SPC\builder\linux\library\LinuxLibraryBase; use SPC\builder\macos\library\MacOSLibraryBase; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; -use SPC\exception\WrongUsageException; use SPC\util\executor\UnixAutoconfExecutor; trait libxslt { - /** - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException - */ protected function build(): void { $static_libs = $this instanceof LinuxLibraryBase ? $this->getStaticLibFiles(include_self: false) : ''; diff --git a/src/SPC/builder/unix/library/libzip.php b/src/SPC/builder/unix/library/libzip.php index a442129f..931bfcc3 100644 --- a/src/SPC/builder/unix/library/libzip.php +++ b/src/SPC/builder/unix/library/libzip.php @@ -4,16 +4,10 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\util\executor\UnixCMakeExecutor; trait libzip { - /** - * @throws RuntimeException - * @throws FileSystemException - */ protected function build(): void { UnixCMakeExecutor::create($this) diff --git a/src/SPC/builder/unix/library/nghttp2.php b/src/SPC/builder/unix/library/nghttp2.php index d54a47da..249472f7 100644 --- a/src/SPC/builder/unix/library/nghttp2.php +++ b/src/SPC/builder/unix/library/nghttp2.php @@ -4,18 +4,10 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; -use SPC\exception\WrongUsageException; use SPC\util\executor\UnixAutoconfExecutor; trait nghttp2 { - /** - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException - */ protected function build(): void { UnixAutoconfExecutor::create($this) diff --git a/src/SPC/builder/unix/library/nghttp3.php b/src/SPC/builder/unix/library/nghttp3.php index 6d9d577c..35368f79 100644 --- a/src/SPC/builder/unix/library/nghttp3.php +++ b/src/SPC/builder/unix/library/nghttp3.php @@ -4,16 +4,10 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\util\executor\UnixAutoconfExecutor; trait nghttp3 { - /** - * @throws FileSystemException - * @throws RuntimeException - */ protected function build(): void { UnixAutoconfExecutor::create($this)->configure('--enable-lib-only')->make(); diff --git a/src/SPC/builder/unix/library/ngtcp2.php b/src/SPC/builder/unix/library/ngtcp2.php index e2c4ed09..8b97e8b8 100644 --- a/src/SPC/builder/unix/library/ngtcp2.php +++ b/src/SPC/builder/unix/library/ngtcp2.php @@ -6,18 +6,10 @@ namespace SPC\builder\unix\library; use SPC\builder\linux\library\LinuxLibraryBase; use SPC\builder\macos\library\MacOSLibraryBase; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; -use SPC\exception\WrongUsageException; use SPC\util\executor\UnixAutoconfExecutor; trait ngtcp2 { - /** - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException - */ protected function build(): void { UnixAutoconfExecutor::create($this) diff --git a/src/SPC/builder/unix/library/onig.php b/src/SPC/builder/unix/library/onig.php index 368c852b..0bd04317 100644 --- a/src/SPC/builder/unix/library/onig.php +++ b/src/SPC/builder/unix/library/onig.php @@ -4,16 +4,10 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\util\executor\UnixAutoconfExecutor; trait onig { - /** - * @throws FileSystemException - * @throws RuntimeException - */ protected function build(): void { UnixAutoconfExecutor::create($this)->configure()->make(); diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index c2cc7165..80564284 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -12,10 +12,6 @@ use SPC\util\SPCTarget; trait postgresql { - /** - * @throws RuntimeException - * @throws FileSystemException - */ protected function build(): void { $builddir = BUILD_ROOT_PATH; diff --git a/src/SPC/builder/unix/library/qdbm.php b/src/SPC/builder/unix/library/qdbm.php index b7a43cdf..640e6c4d 100644 --- a/src/SPC/builder/unix/library/qdbm.php +++ b/src/SPC/builder/unix/library/qdbm.php @@ -5,17 +5,11 @@ declare(strict_types=1); namespace SPC\builder\unix\library; use SPC\builder\macos\library\MacOSLibraryBase; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\store\FileSystem; use SPC\util\executor\UnixAutoconfExecutor; trait qdbm { - /** - * @throws FileSystemException - * @throws RuntimeException - */ protected function build(): void { $ac = UnixAutoconfExecutor::create($this)->configure(); diff --git a/src/SPC/builder/unix/library/readline.php b/src/SPC/builder/unix/library/readline.php index 8cfca0ab..758cc03f 100644 --- a/src/SPC/builder/unix/library/readline.php +++ b/src/SPC/builder/unix/library/readline.php @@ -4,16 +4,10 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\util\executor\UnixAutoconfExecutor; trait readline { - /** - * @throws RuntimeException - * @throws FileSystemException - */ protected function build(): void { UnixAutoconfExecutor::create($this) diff --git a/src/SPC/builder/unix/library/snappy.php b/src/SPC/builder/unix/library/snappy.php index d2bce8fc..060bb0f4 100644 --- a/src/SPC/builder/unix/library/snappy.php +++ b/src/SPC/builder/unix/library/snappy.php @@ -4,16 +4,10 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\util\executor\UnixCMakeExecutor; trait snappy { - /** - * @throws RuntimeException - * @throws FileSystemException - */ protected function build(): void { UnixCMakeExecutor::create($this) diff --git a/src/SPC/builder/unix/library/tidy.php b/src/SPC/builder/unix/library/tidy.php index 33405a47..6afaa94f 100644 --- a/src/SPC/builder/unix/library/tidy.php +++ b/src/SPC/builder/unix/library/tidy.php @@ -4,16 +4,10 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\util\executor\UnixCMakeExecutor; trait tidy { - /** - * @throws RuntimeException - * @throws FileSystemException - */ protected function build(): void { $cmake = UnixCMakeExecutor::create($this) diff --git a/src/SPC/builder/unix/library/unixodbc.php b/src/SPC/builder/unix/library/unixodbc.php index a795d244..d7524bda 100644 --- a/src/SPC/builder/unix/library/unixodbc.php +++ b/src/SPC/builder/unix/library/unixodbc.php @@ -4,16 +4,10 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\util\executor\UnixAutoconfExecutor; trait unixodbc { - /** - * @throws FileSystemException - * @throws RuntimeException - */ protected function build(): void { UnixAutoconfExecutor::create($this) diff --git a/src/SPC/builder/unix/library/watcher.php b/src/SPC/builder/unix/library/watcher.php index 84f8140e..359fedd2 100644 --- a/src/SPC/builder/unix/library/watcher.php +++ b/src/SPC/builder/unix/library/watcher.php @@ -4,16 +4,10 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\store\FileSystem; trait watcher { - /** - * @throws RuntimeException - * @throws FileSystemException - */ protected function build(): void { $cflags = $this->getLibExtraCXXFlags(); diff --git a/src/SPC/builder/unix/library/xz.php b/src/SPC/builder/unix/library/xz.php index 98f33bea..e17f92b1 100644 --- a/src/SPC/builder/unix/library/xz.php +++ b/src/SPC/builder/unix/library/xz.php @@ -4,16 +4,10 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\util\executor\UnixAutoconfExecutor; trait xz { - /** - * @throws RuntimeException - * @throws FileSystemException - */ public function build(): void { UnixAutoconfExecutor::create($this) diff --git a/src/SPC/builder/unix/library/zlib.php b/src/SPC/builder/unix/library/zlib.php index 717ec3fb..394e4a4f 100644 --- a/src/SPC/builder/unix/library/zlib.php +++ b/src/SPC/builder/unix/library/zlib.php @@ -4,16 +4,10 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\util\executor\UnixAutoconfExecutor; trait zlib { - /** - * @throws RuntimeException - * @throws FileSystemException - */ protected function build(): void { UnixAutoconfExecutor::create($this)->exec("./configure --static --prefix={$this->getBuildRootPath()}")->make(); diff --git a/src/SPC/builder/unix/library/zstd.php b/src/SPC/builder/unix/library/zstd.php index 4bb99c7e..59b26701 100644 --- a/src/SPC/builder/unix/library/zstd.php +++ b/src/SPC/builder/unix/library/zstd.php @@ -4,16 +4,10 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\util\executor\UnixCMakeExecutor; trait zstd { - /** - * @throws RuntimeException - * @throws FileSystemException - */ protected function build(): void { UnixCMakeExecutor::create($this) diff --git a/src/SPC/builder/windows/SystemUtil.php b/src/SPC/builder/windows/SystemUtil.php index 01dc33a2..c95697bd 100644 --- a/src/SPC/builder/windows/SystemUtil.php +++ b/src/SPC/builder/windows/SystemUtil.php @@ -75,9 +75,8 @@ class SystemUtil /** * Create CMake toolchain file. * - * @param null|string $cflags CFLAGS for cmake, default use '/MT /Os /Ob1 /DNDEBUG /D_ACRTIMP= /D_CRTIMP=' - * @param null|string $ldflags LDFLAGS for cmake, default use '/nodefaultlib:msvcrt /nodefaultlib:msvcrtd /defaultlib:libcmt' - * @throws FileSystemException + * @param null|string $cflags CFLAGS for cmake, default use '/MT /Os /Ob1 /DNDEBUG /D_ACRTIMP= /D_CRTIMP=' + * @param null|string $ldflags LDFLAGS for cmake, default use '/nodefaultlib:msvcrt /nodefaultlib:msvcrtd /defaultlib:libcmt' */ public static function makeCmakeToolchainFile(?string $cflags = null, ?string $ldflags = null): string { diff --git a/src/SPC/builder/windows/WindowsBuilder.php b/src/SPC/builder/windows/WindowsBuilder.php index ac29ae3a..2e7c1154 100644 --- a/src/SPC/builder/windows/WindowsBuilder.php +++ b/src/SPC/builder/windows/WindowsBuilder.php @@ -26,9 +26,6 @@ class WindowsBuilder extends BuilderBase /** @var bool Micro patch phar flag */ private bool $phar_patched = false; - /** - * @throws FileSystemException - */ public function __construct(array $options = []) { $this->options = $options; @@ -54,11 +51,6 @@ class WindowsBuilder extends BuilderBase f_mkdir(BUILD_LIB_PATH, recursive: true); } - /** - * @throws RuntimeException - * @throws WrongUsageException - * @throws FileSystemException - */ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void { $enableCli = ($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI; @@ -153,10 +145,6 @@ class WindowsBuilder extends BuilderBase $this->sanityCheck($build_target); } - /** - * @throws FileSystemException - * @throws RuntimeException - */ public function buildCli(): void { SourcePatcher::patchWindowsCLITarget(); @@ -182,11 +170,6 @@ class WindowsBuilder extends BuilderBase */ } - /** - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException - */ public function buildMicro(): void { // workaround for fiber (originally from https://github.com/dixyes/lwmbs/blob/master/windows/MicroBuild.php) @@ -262,10 +245,6 @@ class WindowsBuilder extends BuilderBase $this->lib_list = $sorted_libraries; } - /** - * @throws FileSystemException - * @throws RuntimeException - */ public function cleanMake(): void { FileSystem::writeFile(SOURCE_PATH . '\php-src\nmake_clean_wrapper.bat', 'nmake /nologo %*'); @@ -274,8 +253,6 @@ class WindowsBuilder extends BuilderBase /** * Run extension and PHP cli and micro check - * - * @throws RuntimeException */ public function sanityCheck(mixed $build_target): void { @@ -321,11 +298,9 @@ class WindowsBuilder extends BuilderBase } /** - * 将编译好的二进制文件发布到 buildroot + * Deploy the binary file to buildroot/bin/ * - * @param int $type 发布类型 - * @throws RuntimeException - * @throws FileSystemException + * @param int $type Deploy type */ public function deployBinary(int $type): bool { @@ -350,34 +325,6 @@ class WindowsBuilder extends BuilderBase return true; } - /** - * @throws WrongUsageException - * @throws FileSystemException - */ - public function getAllStaticLibFiles(): array - { - $libs = []; - - // reorder libs - foreach ($this->libs as $lib) { - foreach ($lib->getDependencies() as $dep) { - $libs[] = $dep; - } - $libs[] = $lib; - } - - $libFiles = []; - $libNames = []; - // merge libs - foreach ($libs as $lib) { - if (!in_array($lib::NAME, $libNames, true)) { - $libNames[] = $lib::NAME; - array_unshift($libFiles, ...$lib->getStaticLibs()); - } - } - return $libFiles; - } - /** * Generate command wrapper prefix for php-sdk internal commands. * diff --git a/src/SPC/command/BuildLibsCommand.php b/src/SPC/command/BuildLibsCommand.php index 8e87d1b9..d9071267 100644 --- a/src/SPC/command/BuildLibsCommand.php +++ b/src/SPC/command/BuildLibsCommand.php @@ -5,8 +5,6 @@ declare(strict_types=1); namespace SPC\command; use SPC\builder\BuilderProvider; -use SPC\exception\ExceptionHandler; -use SPC\exception\RuntimeException; use SPC\store\Config; use SPC\util\DependencyUtil; use Symfony\Component\Console\Attribute\AsCommand; @@ -33,9 +31,6 @@ class BuildLibsCommand extends BuildCommand parent::initialize($input, $output); } - /** - * @throws RuntimeException - */ public function handle(): int { // 从参数中获取要编译的 libraries,并转换为数组 diff --git a/src/SPC/command/DeleteDownloadCommand.php b/src/SPC/command/DeleteDownloadCommand.php index 1eeddf7e..3cda4a1d 100644 --- a/src/SPC/command/DeleteDownloadCommand.php +++ b/src/SPC/command/DeleteDownloadCommand.php @@ -34,9 +34,6 @@ class DeleteDownloadCommand extends BaseCommand parent::initialize($input, $output); } - /** - * @throws FileSystemException - */ public function handle(): int { try { diff --git a/src/SPC/command/DownloadCommand.php b/src/SPC/command/DownloadCommand.php index ddcb50ae..417409d6 100644 --- a/src/SPC/command/DownloadCommand.php +++ b/src/SPC/command/DownloadCommand.php @@ -47,10 +47,6 @@ class DownloadCommand extends BaseCommand $this->addOption('no-alt', null, null, 'Do not download alternative sources'); } - /** - * @throws FileSystemException - * @throws WrongUsageException - */ public function initialize(InputInterface $input, OutputInterface $output): void { // mode: --all @@ -89,10 +85,6 @@ class DownloadCommand extends BaseCommand parent::initialize($input, $output); } - /** - * @throws FileSystemException - * @throws RuntimeException - */ public function handle(): int { try { @@ -268,10 +260,6 @@ class DownloadCommand extends BaseCommand } } - /** - * @throws RuntimeException - * @throws WrongUsageException - */ private function downloadFromZip(string $path): int { if (!file_exists($path)) { @@ -316,10 +304,8 @@ class DownloadCommand extends BaseCommand /** * Calculate the sources by extensions * - * @param array $extensions extension list - * @param bool $include_suggests include suggested libs and extensions (default: true) - * @throws FileSystemException - * @throws WrongUsageException + * @param array $extensions extension list + * @param bool $include_suggests include suggested libs and extensions (default: true) */ private function calculateSourcesByExt(array $extensions, bool $include_suggests = true): array { @@ -342,10 +328,8 @@ class DownloadCommand extends BaseCommand /** * Calculate the sources by libraries * - * @param array $libs library list - * @param bool $include_suggests include suggested libs (default: true) - * @throws FileSystemException - * @throws WrongUsageException + * @param array $libs library list + * @param bool $include_suggests include suggested libs (default: true) */ private function calculateSourcesByLib(array $libs, bool $include_suggests = true): array { @@ -373,9 +357,6 @@ class DownloadCommand extends BaseCommand return null; } - /** - * @throws RuntimeException - */ private function _clean(): int { logger()->warning('You are doing some operations that not recoverable: removing directories below'); diff --git a/src/SPC/command/DumpLicenseCommand.php b/src/SPC/command/DumpLicenseCommand.php index 0e9147da..e441fd9e 100644 --- a/src/SPC/command/DumpLicenseCommand.php +++ b/src/SPC/command/DumpLicenseCommand.php @@ -4,9 +4,6 @@ declare(strict_types=1); namespace SPC\command; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; -use SPC\exception\WrongUsageException; use SPC\util\DependencyUtil; use SPC\util\LicenseDumper; use Symfony\Component\Console\Attribute\AsCommand; @@ -27,11 +24,6 @@ class DumpLicenseCommand extends BaseCommand $this->addOption('dump-dir', null, InputOption::VALUE_REQUIRED, 'Change dump directory', BUILD_ROOT_PATH . '/license'); } - /** - * @throws WrongUsageException - * @throws FileSystemException - * @throws RuntimeException - */ public function handle(): int { $dumper = new LicenseDumper(); diff --git a/src/SPC/command/ExtractCommand.php b/src/SPC/command/ExtractCommand.php index e532880d..c189e0ce 100644 --- a/src/SPC/command/ExtractCommand.php +++ b/src/SPC/command/ExtractCommand.php @@ -5,9 +5,6 @@ declare(strict_types=1); namespace SPC\command; use SPC\builder\traits\UnixSystemUtilTrait; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; -use SPC\exception\WrongUsageException; use SPC\store\SourceManager; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; @@ -23,11 +20,6 @@ class ExtractCommand extends BaseCommand $this->addOption('source-only', null, null, 'Only check the source exist, do not check the lib and ext'); } - /** - * @throws WrongUsageException - * @throws FileSystemException - * @throws RuntimeException - */ public function handle(): int { $sources = array_map('trim', array_filter(explode(',', $this->getArgument('sources')))); diff --git a/src/SPC/command/InstallPkgCommand.php b/src/SPC/command/InstallPkgCommand.php index 19d1532b..c4f60981 100644 --- a/src/SPC/command/InstallPkgCommand.php +++ b/src/SPC/command/InstallPkgCommand.php @@ -28,9 +28,6 @@ class InstallPkgCommand extends BaseCommand $this->addOption('skip-extract', null, null, 'Skip package extraction, just download the package archive'); } - /** - * @throws FileSystemException - */ public function handle(): int { try { diff --git a/src/SPC/command/SPCConfigCommand.php b/src/SPC/command/SPCConfigCommand.php index 4b6d1bc4..5e21c9a1 100644 --- a/src/SPC/command/SPCConfigCommand.php +++ b/src/SPC/command/SPCConfigCommand.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace SPC\command; -use SPC\exception\RuntimeException; use SPC\util\SPCConfigUtil; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; @@ -28,9 +27,6 @@ class SPCConfigCommand extends BaseCommand $this->addOption('no-php', null, null, 'Do not link to PHP library'); } - /** - * @throws RuntimeException - */ public function handle(): int { // transform string to array diff --git a/src/SPC/command/dev/AllExtCommand.php b/src/SPC/command/dev/AllExtCommand.php index 90675eb5..04085778 100644 --- a/src/SPC/command/dev/AllExtCommand.php +++ b/src/SPC/command/dev/AllExtCommand.php @@ -5,8 +5,6 @@ declare(strict_types=1); namespace SPC\command\dev; use SPC\command\BaseCommand; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\Config; use SPC\util\DependencyUtil; @@ -30,11 +28,6 @@ class AllExtCommand extends BaseCommand ); } - /** - * @throws FileSystemException - * @throws WrongUsageException - * @throws RuntimeException - */ public function handle(): int { $extensions = array_map('trim', array_filter(explode(',', $this->getArgument('extensions') ?? ''))); diff --git a/src/SPC/command/dev/PackLibCommand.php b/src/SPC/command/dev/PackLibCommand.php index 366ef71e..4bac73d7 100644 --- a/src/SPC/command/dev/PackLibCommand.php +++ b/src/SPC/command/dev/PackLibCommand.php @@ -146,11 +146,6 @@ class PackLibCommand extends BuildCommand } } - /** - * @throws WrongUsageException - * @throws RuntimeException - * @throws FileSystemException - */ private function sanityCheckLib(LibraryBase $lib): void { logger()->info('Sanity check for library ' . $lib->getName()); diff --git a/src/SPC/command/dev/SortConfigCommand.php b/src/SPC/command/dev/SortConfigCommand.php index dcac4c34..7c897cd9 100644 --- a/src/SPC/command/dev/SortConfigCommand.php +++ b/src/SPC/command/dev/SortConfigCommand.php @@ -5,8 +5,6 @@ declare(strict_types=1); namespace SPC\command\dev; use SPC\command\BaseCommand; -use SPC\exception\FileSystemException; -use SPC\exception\ValidationException; use SPC\store\FileSystem; use SPC\util\ConfigValidator; use Symfony\Component\Console\Attribute\AsCommand; @@ -23,10 +21,6 @@ class SortConfigCommand extends BaseCommand $this->addArgument('config-name', InputArgument::REQUIRED, 'Your config to be sorted, you can sort "lib", "source" and "ext".'); } - /** - * @throws ValidationException - * @throws FileSystemException - */ public function handle(): int { switch ($name = $this->getArgument('config-name')) { diff --git a/src/SPC/doctor/item/LinuxMuslCheck.php b/src/SPC/doctor/item/LinuxMuslCheck.php index 48b33fed..a52b32fd 100644 --- a/src/SPC/doctor/item/LinuxMuslCheck.php +++ b/src/SPC/doctor/item/LinuxMuslCheck.php @@ -55,11 +55,6 @@ class LinuxMuslCheck return CheckResult::fail('musl-cross-make is not installed on your system', 'fix-musl-cross-make'); } - /** @noinspection PhpUnused */ - /** - * @throws DownloaderException - * @throws FileSystemException - */ #[AsFixItem('fix-musl-wrapper')] public function fixMusl(): bool { @@ -94,11 +89,6 @@ class LinuxMuslCheck } } - /** @noinspection PhpUnused */ - /** - * @throws FileSystemException - * @throws WrongUsageException - */ #[AsFixItem('fix-musl-cross-make')] public function fixMuslCrossMake(): bool { diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index 58ad8a31..5db566fa 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -114,10 +114,6 @@ class LinuxToolCheckList return CheckResult::ok(); } - /** - * @throws RuntimeException - * @noinspection PhpUnused - */ #[AsFixItem('install-linux-tools')] public function fixBuildTools(array $distro, array $missing): bool { diff --git a/src/SPC/doctor/item/ZigCheck.php b/src/SPC/doctor/item/ZigCheck.php index 186f43b7..b201e027 100644 --- a/src/SPC/doctor/item/ZigCheck.php +++ b/src/SPC/doctor/item/ZigCheck.php @@ -8,8 +8,6 @@ use SPC\doctor\AsCheckItem; use SPC\doctor\AsFixItem; use SPC\doctor\CheckResult; use SPC\doctor\OptionalCheck; -use SPC\exception\FileSystemException; -use SPC\exception\WrongUsageException; use SPC\store\PackageManager; use SPC\store\pkg\Zig; use SPC\toolchain\ZigToolchain; @@ -32,11 +30,6 @@ class ZigCheck return CheckResult::fail('zig is not installed', 'install-zig'); } - /** @noinspection PhpUnused */ - /** - * @throws FileSystemException - * @throws WrongUsageException - */ #[AsFixItem('install-zig')] public function installZig(): bool { diff --git a/src/SPC/store/Config.php b/src/SPC/store/Config.php index 3ac6abb2..1d8c53ad 100644 --- a/src/SPC/store/Config.php +++ b/src/SPC/store/Config.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace SPC\store; -use SPC\exception\FileSystemException; use SPC\exception\WrongUsageException; class Config @@ -22,10 +21,8 @@ class Config /** * Get pre-built configuration by name * - * @param string $name The name of the pre-built configuration - * @return mixed The pre-built configuration or null if not found - * @throws WrongUsageException - * @throws FileSystemException + * @param string $name The name of the pre-built configuration + * @return mixed The pre-built configuration or null if not found */ public static function getPreBuilt(string $name): mixed { @@ -53,9 +50,8 @@ class Config /** * Get source configuration by name * - * @param string $name The name of the source - * @return null|array The source configuration or null if not found - * @throws FileSystemException + * @param string $name The name of the source + * @return null|array The source configuration or null if not found */ public static function getSource(string $name): ?array { @@ -68,9 +64,8 @@ class Config /** * Get package configuration by name * - * @param string $name The name of the package - * @return null|array The package configuration or null if not found - * @throws FileSystemException + * @param string $name The name of the package + * @return null|array The package configuration or null if not found */ public static function getPkg(string $name): ?array { @@ -84,12 +79,10 @@ class Config * Get library configuration by name and optional key * Supports platform-specific configurations for different operating systems * - * @param string $name The name of the library - * @param null|string $key The configuration key (static-libs, headers, lib-depends, lib-suggests, frameworks, bin) - * @param mixed $default Default value if key not found - * @return mixed The library configuration or default value - * @throws FileSystemException - * @throws WrongUsageException + * @param string $name The name of the library + * @param null|string $key The configuration key (static-libs, headers, lib-depends, lib-suggests, frameworks, bin) + * @param mixed $default Default value if key not found + * @return mixed The library configuration or default value */ public static function getLib(string $name, ?string $key = null, mixed $default = null) { @@ -124,8 +117,7 @@ class Config /** * Get all library configurations * - * @return array All library configurations - * @throws FileSystemException + * @return array All library configurations */ public static function getLibs(): array { @@ -138,10 +130,8 @@ class Config /** * Get extension target configuration by name * - * @param string $name The name of the extension - * @return null|array The extension target configuration or default ['static', 'shared'] - * @throws WrongUsageException - * @throws FileSystemException + * @param string $name The name of the extension + * @return null|array The extension target configuration or default ['static', 'shared'] */ public static function getExtTarget(string $name): ?array { @@ -158,12 +148,10 @@ class Config * Get extension configuration by name and optional key * Supports platform-specific configurations for different operating systems * - * @param string $name The name of the extension - * @param null|string $key The configuration key (lib-depends, lib-suggests, ext-depends, ext-suggests, arg-type) - * @param mixed $default Default value if key not found - * @return mixed The extension configuration or default value - * @throws FileSystemException - * @throws WrongUsageException + * @param string $name The name of the extension + * @param null|string $key The configuration key (lib-depends, lib-suggests, ext-depends, ext-suggests, arg-type) + * @param mixed $default Default value if key not found + * @return mixed The extension configuration or default value */ public static function getExt(string $name, ?string $key = null, mixed $default = null) { @@ -198,8 +186,7 @@ class Config /** * Get all extension configurations * - * @return array All extension configurations - * @throws FileSystemException + * @return array All extension configurations */ public static function getExts(): array { @@ -212,8 +199,7 @@ class Config /** * Get all source configurations * - * @return array All source configurations - * @throws FileSystemException + * @return array All source configurations */ public static function getSources(): array { diff --git a/src/SPC/store/Downloader.php b/src/SPC/store/Downloader.php index 6d6c9f22..91c17df5 100644 --- a/src/SPC/store/Downloader.php +++ b/src/SPC/store/Downloader.php @@ -20,11 +20,9 @@ class Downloader /** * Get latest version from BitBucket tag * - * @param string $name Source name - * @param array $source Source meta info: [repo] - * @return array [url, filename] - * @throws DownloaderException - * @throws RuntimeException + * @param string $name Source name + * @param array $source Source meta info: [repo] + * @return array [url, filename] */ public static function getLatestBitbucketTag(string $name, array $source): array { @@ -56,11 +54,10 @@ class Downloader /** * Get latest version from GitHub tarball * - * @param string $name Source name - * @param array $source Source meta info: [repo] - * @param string $type Type of tarball, default is 'releases' - * @return array [url, filename] - * @throws DownloaderException + * @param string $name Source name + * @param array $source Source meta info: [repo] + * @param string $type Type of tarball, default is 'releases' + * @return array [url, filename] */ public static function getLatestGithubTarball(string $name, array $source, string $type = 'releases'): array { @@ -107,11 +104,10 @@ class Downloader /** * Get latest version from GitHub release (uploaded archive) * - * @param string $name Source name - * @param array $source Source meta info: [repo, match] - * @param bool $match_result Whether to return matched result by `match` param (default: true) - * @return array When $match_result = true, and we matched, [url, filename]. Otherwise, [{asset object}. ...] - * @throws DownloaderException + * @param string $name Source name + * @param array $source Source meta info: [repo, match] + * @param bool $match_result Whether to return matched result by `match` param (default: true) + * @return array When $match_result = true, and we matched, [url, filename]. Otherwise, [{asset object}. ...] */ public static function getLatestGithubRelease(string $name, array $source, bool $match_result = true): array { @@ -150,10 +146,9 @@ class Downloader /** * Get latest version from file list (regex based crawler) * - * @param string $name Source name - * @param array $source Source meta info: [filelist] - * @return array [url, filename] - * @throws DownloaderException + * @param string $name Source name + * @param array $source Source meta info: [filelist] + * @return array [url, filename] */ public static function getFromFileList(string $name, array $source): array { @@ -189,15 +184,13 @@ class Downloader /** * Download file from URL * - * @param string $name Download name - * @param string $url Download URL - * @param string $filename Target filename - * @param null|string $move_path Optional move path after download - * @param int $download_as Download type constant - * @param array $headers Optional HTTP headers - * @param array $hooks Optional curl hooks - * @throws DownloaderException - * @throws RuntimeException + * @param string $name Download name + * @param string $url Download URL + * @param string $filename Target filename + * @param null|string $move_path Optional move path after download + * @param int $download_as Download type constant + * @param array $headers Optional HTTP headers + * @param array $hooks Optional curl hooks */ public static function downloadFile(string $name, string $url, string $filename, ?string $move_path = null, int $download_as = SPC_DOWNLOAD_SOURCE, array $headers = [], array $hooks = []): void { @@ -221,15 +214,13 @@ class Downloader /** * Download Git repository * - * @param string $name Repository name - * @param string $url Git repository URL - * @param string $branch Branch to checkout - * @param null|array $submodules Optional submodules to initialize - * @param null|string $move_path Optional move path after download - * @param int $retries Number of retry attempts - * @param int $lock_as Lock type constant - * @throws DownloaderException - * @throws RuntimeException + * @param string $name Repository name + * @param string $url Git repository URL + * @param string $branch Branch to checkout + * @param null|array $submodules Optional submodules to initialize + * @param null|string $move_path Optional move path after download + * @param int $retries Number of retry attempts + * @param int $lock_as Lock type constant */ public static function downloadGit(string $name, string $url, string $branch, ?array $submodules = null, ?string $move_path = null, int $retries = 0, int $lock_as = SPC_DOWNLOAD_SOURCE): void { @@ -306,10 +297,7 @@ class Downloader * prefer-stable: ?bool, * extract-files: ?array * } $pkg Package config - * @param bool $force Download all the time even if it exists - * @throws DownloaderException - * @throws FileSystemException - * @throws WrongUsageException + * @param bool $force Download all the time even if it exists */ public static function downloadPackage(string $name, ?array $pkg = null, bool $force = false): void { @@ -428,11 +416,8 @@ class Downloader * text: ?string * } * } $source source meta info: [type, path, rev, url, filename, regex, license] - * @param bool $force Whether to force download (default: false) - * @param int $download_as Lock source type (default: SPC_LOCK_SOURCE) - * @throws DownloaderException - * @throws FileSystemException - * @throws WrongUsageException + * @param bool $force Whether to force download (default: false) + * @param int $download_as Lock source type (default: SPC_LOCK_SOURCE) */ public static function downloadSource(string $name, ?array $source = null, bool $force = false, int $download_as = SPC_DOWNLOAD_SOURCE): void { @@ -532,14 +517,12 @@ class Downloader /** * Use curl command to get http response * - * @param string $url Target URL - * @param string $method HTTP method (GET, POST, etc.) - * @param array $headers HTTP headers - * @param array $hooks Curl hooks - * @param int $retries Number of retry attempts - * @return string Response body - * @throws DownloaderException - * @throws RuntimeException + * @param string $url Target URL + * @param string $method HTTP method (GET, POST, etc.) + * @param array $headers HTTP headers + * @param array $hooks Curl hooks + * @param int $retries Number of retry attempts + * @return string Response body */ public static function curlExec(string $url, string $method = 'GET', array $headers = [], array $hooks = [], int $retries = 0): string { @@ -591,15 +574,12 @@ class Downloader /** * Use curl to download sources from url * - * @param string $url Download URL - * @param string $path Target file path - * @param string $method HTTP method - * @param array $headers HTTP headers - * @param array $hooks Curl hooks - * @param int $retries Number of retry attempts - * @throws DownloaderException - * @throws RuntimeException - * @throws WrongUsageException + * @param string $url Download URL + * @param string $path Target file path + * @param string $method HTTP method + * @param array $headers HTTP headers + * @param array $hooks Curl hooks + * @param int $retries Number of retry attempts */ public static function curlDown(string $url, string $path, string $method = 'GET', array $headers = [], array $hooks = [], int $retries = 0): void { @@ -705,10 +685,6 @@ class Downloader return intval(getenv('SPC_DOWNLOAD_RETRIES') ?: 0); } - /** - * @throws FileSystemException - * @throws WrongUsageException - */ private static function isAlreadyDownloaded(string $name, bool $force, int $download_as = SPC_DOWNLOAD_SOURCE): bool { // If the lock file exists, skip downloading for source mode diff --git a/src/SPC/store/FileSystem.php b/src/SPC/store/FileSystem.php index f0d54a54..1849fb4b 100644 --- a/src/SPC/store/FileSystem.php +++ b/src/SPC/store/FileSystem.php @@ -14,10 +14,9 @@ class FileSystem /** * Load configuration array from JSON file * - * @param string $config The configuration name (ext, lib, source, pkg, pre-built) - * @param null|string $config_dir Optional custom config directory - * @return array The loaded configuration array - * @throws FileSystemException + * @param string $config The configuration name (ext, lib, source, pkg, pre-built) + * @param null|string $config_dir Optional custom config directory + * @return array The loaded configuration array */ public static function loadConfigArray(string $config, ?string $config_dir = null): array { @@ -44,9 +43,8 @@ class FileSystem /** * Read file contents and throw exception on failure * - * @param string $filename The file path to read - * @return string The file contents - * @throws FileSystemException + * @param string $filename The file path to read + * @return string The file contents */ public static function readFile(string $filename): string { @@ -61,11 +59,10 @@ class FileSystem /** * Replace string content in file * - * @param string $filename The file path - * @param mixed $search The search string - * @param mixed $replace The replacement string - * @return false|int Number of replacements or false on failure - * @throws FileSystemException + * @param string $filename The file path + * @param mixed $search The search string + * @param mixed $replace The replacement string + * @return false|int Number of replacements or false on failure */ public static function replaceFileStr(string $filename, mixed $search = null, mixed $replace = null): false|int { @@ -75,11 +72,10 @@ class FileSystem /** * Replace content in file using regex * - * @param string $filename The file path - * @param mixed $search The regex pattern - * @param mixed $replace The replacement string - * @return false|int Number of replacements or false on failure - * @throws FileSystemException + * @param string $filename The file path + * @param mixed $search The regex pattern + * @param mixed $replace The replacement string + * @return false|int Number of replacements or false on failure */ public static function replaceFileRegex(string $filename, mixed $search = null, mixed $replace = null): false|int { @@ -89,10 +85,9 @@ class FileSystem /** * Replace content in file using custom callback * - * @param string $filename The file path - * @param mixed $callback The callback function - * @return false|int Number of replacements or false on failure - * @throws FileSystemException + * @param string $filename The file path + * @param mixed $callback The callback function + * @return false|int Number of replacements or false on failure */ public static function replaceFileUser(string $filename, mixed $callback = null): false|int { @@ -147,9 +142,8 @@ class FileSystem /** * Copy directory recursively * - * @param string $from Source directory path - * @param string $to Destination directory path - * @throws RuntimeException + * @param string $from Source directory path + * @param string $to Destination directory path */ public static function copyDir(string $from, string $to): void { @@ -170,12 +164,10 @@ class FileSystem /** * Extract package archive to specified directory * - * @param string $name Package name - * @param string $source_type Archive type (tar.gz, zip, etc.) - * @param string $filename Archive filename - * @param null|string $extract_path Optional extraction path - * @throws RuntimeException - * @throws FileSystemException + * @param string $name Package name + * @param string $source_type Archive type (tar.gz, zip, etc.) + * @param string $filename Archive filename + * @param null|string $extract_path Optional extraction path */ public static function extractPackage(string $name, string $source_type, string $filename, ?string $extract_path = null): void { @@ -208,12 +200,10 @@ class FileSystem /** * Extract source archive to source directory * - * @param string $name Source name - * @param string $source_type Archive type (tar.gz, zip, etc.) - * @param string $filename Archive filename - * @param null|string $move_path Optional move path - * @throws FileSystemException - * @throws RuntimeException + * @param string $name Source name + * @param string $source_type Archive type (tar.gz, zip, etc.) + * @param string $filename Archive filename + * @param null|string $move_path Optional move path */ public static function extractSource(string $name, string $source_type, string $filename, ?string $move_path = null): void { @@ -412,8 +402,7 @@ class FileSystem /** * Create directory recursively * - * @param string $path Directory path to create - * @throws FileSystemException + * @param string $path Directory path to create */ public static function createDir(string $path): void { @@ -425,11 +414,10 @@ class FileSystem /** * Write content to file * - * @param string $path File path - * @param mixed $content Content to write - * @param mixed ...$args Additional arguments passed to file_put_contents - * @return bool|int|string Result of file writing operation - * @throws FileSystemException + * @param string $path File path + * @param mixed $content Content to write + * @param mixed ...$args Additional arguments passed to file_put_contents + * @return bool|int|string Result of file writing operation */ public static function writeFile(string $path, mixed $content, ...$args): bool|int|string { @@ -443,8 +431,7 @@ class FileSystem /** * Reset directory by removing and recreating it * - * @param string $dir_name Directory name - * @throws FileSystemException + * @param string $dir_name Directory name */ public static function resetDir(string $dir_name): void { @@ -540,11 +527,10 @@ class FileSystem /** * Replace line in file that contains specific string * - * @param string $file File path - * @param string $find String to find in line - * @param string $line New line content - * @return false|int Number of replacements or false on failure - * @throws FileSystemException + * @param string $file File path + * @param string $find String to find in line + * @param string $line New line content + * @return false|int Number of replacements or false on failure */ public static function replaceFileLineContainsString(string $file, string $find, string $line): false|int { @@ -560,10 +546,6 @@ class FileSystem return file_put_contents($file, implode('', $lines)); } - /** - * @throws RuntimeException - * @throws FileSystemException - */ private static function extractArchive(string $filename, string $target): void { // Create base dir @@ -600,9 +582,6 @@ class FileSystem } } - /** - * @throws FileSystemException - */ private static function replaceFile(string $filename, int $replace_type = REPLACE_FILE_STR, mixed $callback_or_search = null, mixed $to_replace = null): false|int { logger()->debug('Replacing file with type[' . $replace_type . ']: ' . $filename); diff --git a/src/SPC/store/LockFile.php b/src/SPC/store/LockFile.php index 999f91b4..b81bafdf 100644 --- a/src/SPC/store/LockFile.php +++ b/src/SPC/store/LockFile.php @@ -60,10 +60,8 @@ class LockFile /** * Put a lock entry into the lock file. * - * @param string $lock_name Lock name to set or remove - * @param null|array $lock_content lock content to set, or null to remove the lock entry - * @throws FileSystemException - * @throws WrongUsageException + * @param string $lock_name Lock name to set or remove + * @param null|array $lock_content lock content to set, or null to remove the lock entry */ public static function put(string $lock_name, ?array $lock_content): void { @@ -84,9 +82,8 @@ class LockFile /** * Get the full path of a lock file or directory based on the lock options. * - * @param array $lock_options lock item options, must contain 'source_type', 'filename' or 'dirname' - * @return string the absolute path to the lock file or directory - * @throws WrongUsageException + * @param array $lock_options lock item options, must contain 'source_type', 'filename' or 'dirname' + * @return string the absolute path to the lock file or directory */ public static function getLockFullPath(array $lock_options): string { @@ -122,9 +119,8 @@ class LockFile /** * Get the hash of the lock source based on the lock options. * - * @param array $lock_options Lock options - * @return string Hash of the lock source - * @throws RuntimeException + * @param array $lock_options Lock options + * @return string Hash of the lock source */ public static function getLockSourceHash(array $lock_options): string { @@ -141,10 +137,8 @@ class LockFile } /** - * @param array $lock_options Lock options - * @param string $destination Target directory - * @throws FileSystemException - * @throws RuntimeException + * @param array $lock_options Lock options + * @param string $destination Target directory */ public static function putLockSourceHash(array $lock_options, string $destination): void { @@ -167,9 +161,6 @@ class LockFile * move_path: ?string, * lock_as: int * } $data Source data - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException */ public static function lockSource(string $name, array $data): void { @@ -200,9 +191,7 @@ class LockFile /** * Remove the lock file or directory if it exists. * - * @param array $lock_options lock item options, must contain 'source_type', 'filename' or 'dirname' - * @throws WrongUsageException - * @throws FileSystemException + * @param array $lock_options lock item options, must contain 'source_type', 'filename' or 'dirname' */ private static function removeLockFileIfExists(array $lock_options): void { diff --git a/src/SPC/store/SourceManager.php b/src/SPC/store/SourceManager.php index 251e2fa1..35728e22 100644 --- a/src/SPC/store/SourceManager.php +++ b/src/SPC/store/SourceManager.php @@ -4,17 +4,10 @@ declare(strict_types=1); namespace SPC\store; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; class SourceManager { - /** - * @throws WrongUsageException - * @throws FileSystemException - * @throws RuntimeException - */ public static function initSource(?array $sources = null, ?array $libs = null, ?array $exts = null, bool $source_only = false): void { $sources_extracted = []; diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 85b7ddf1..a51ab0a9 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -34,14 +34,6 @@ class SourcePatcher FileSystem::addSourceExtractHook('gmssl', [__CLASS__, 'patchGMSSL']); } - /** - * Source patcher runner before buildconf - * - * @param BuilderBase $builder Builder - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException - */ public static function patchBeforeBuildconf(BuilderBase $builder): void { foreach ($builder->getExts() as $ext) { @@ -111,8 +103,7 @@ class SourcePatcher /** * Source patcher runner before configure * - * @param BuilderBase $builder Builder - * @throws FileSystemException + * @param BuilderBase $builder Builder */ public static function patchBeforeConfigure(BuilderBase $builder): void { @@ -138,10 +129,6 @@ class SourcePatcher } } - /** - * @throws RuntimeException - * @throws FileSystemException - */ public static function patchMicro(?array $items = null): bool { if (!file_exists(SOURCE_PATH . '/php-src/sapi/micro/php_micro.c')) { @@ -198,10 +185,9 @@ class SourcePatcher /** * Use existing patch file for patching * - * @param string $patch_name Patch file name in src/globals/patch/ or absolute path - * @param string $cwd Working directory for patch command - * @param bool $reverse Reverse patches (default: False) - * @throws RuntimeException + * @param string $patch_name Patch file name in src/globals/patch/ or absolute path + * @param string $cwd Working directory for patch command + * @param bool $reverse Reverse patches (default: False) */ public static function patchFile(string $patch_name, string $cwd, bool $reverse = false): bool { @@ -247,9 +233,6 @@ class SourcePatcher return true; } - /** - * @throws FileSystemException - */ public static function patchOpenssl11Darwin(): bool { if (PHP_OS_FAMILY === 'Darwin' && !file_exists(SOURCE_PATH . '/openssl/VERSION.dat') && file_exists(SOURCE_PATH . '/openssl/test/v3ext.c')) { @@ -259,9 +242,6 @@ class SourcePatcher return false; } - /** - * @throws FileSystemException - */ public static function patchSwoole(): bool { // swoole hook needs pdo/pdo.h @@ -288,9 +268,6 @@ class SourcePatcher return true; } - /** - * @throws FileSystemException - */ public static function patchBeforeMake(BuilderBase $builder): void { if ($builder instanceof UnixBuilderBase) { @@ -343,9 +320,6 @@ class SourcePatcher } } - /** - * @throws FileSystemException - */ public static function patchHardcodedINI(array $ini = []): bool { $cli_c = SOURCE_PATH . '/php-src/sapi/cli/php_cli.c'; @@ -403,9 +377,6 @@ class SourcePatcher return $result; } - /** - * @throws FileSystemException - */ public static function patchMicroPhar(int $version_id): void { FileSystem::backupFile(SOURCE_PATH . '/php-src/ext/phar/phar.c'); @@ -431,9 +402,6 @@ class SourcePatcher } } - /** - * @throws RuntimeException - */ public static function unpatchMicroPhar(): void { FileSystem::restoreBackupFile(SOURCE_PATH . '/php-src/ext/phar/phar.c'); @@ -441,8 +409,6 @@ class SourcePatcher /** * Fix the compilation issue of sqlsrv and pdo_sqlsrv on Windows (/sdl check is too strict and will cause Zend compilation to fail) - * - * @throws FileSystemException */ public static function patchSQLSRVWin32(string $source_name): bool { @@ -542,9 +508,6 @@ class SourcePatcher /** * Patch cli SAPI Makefile for Windows. - * - * @throws FileSystemException - * @throws RuntimeException */ public static function patchWindowsCLITarget(): void { @@ -568,9 +531,6 @@ class SourcePatcher FileSystem::writeFile(SOURCE_PATH . '/php-src/Makefile', implode("\r\n", $lines)); } - /** - * @throws RuntimeException - */ public static function patchPhpLibxml212(): bool { $file = file_get_contents(SOURCE_PATH . '/php-src/main/php_version.h'); @@ -595,9 +555,6 @@ class SourcePatcher return false; } - /** - * @throws FileSystemException - */ public static function patchGDWin32(): bool { $file = file_get_contents(SOURCE_PATH . '/php-src/main/php_version.h'); @@ -617,8 +574,6 @@ class SourcePatcher /** * Add additional `static-php-cli.version` ini value for PHP source. - * - * @throws FileSystemException */ public static function patchSPCVersionToPHP(string $version = 'unknown'): void { @@ -631,9 +586,6 @@ class SourcePatcher } } - /** - * @throws FileSystemException - */ public static function patchMicroWin32(): void { // patch micro win32 diff --git a/src/SPC/store/pkg/Zig.php b/src/SPC/store/pkg/Zig.php index a2846089..7089f87f 100644 --- a/src/SPC/store/pkg/Zig.php +++ b/src/SPC/store/pkg/Zig.php @@ -145,9 +145,6 @@ class Zig extends CustomPackage ]; } - /** - * @throws WrongUsageException - */ private static function getPath(): string { $arch = arch2gnu(php_uname('m')); diff --git a/src/SPC/store/source/PhpSource.php b/src/SPC/store/source/PhpSource.php index 72a16849..242d186a 100644 --- a/src/SPC/store/source/PhpSource.php +++ b/src/SPC/store/source/PhpSource.php @@ -6,19 +6,12 @@ namespace SPC\store\source; use JetBrains\PhpStorm\ArrayShape; use SPC\exception\DownloaderException; -use SPC\exception\FileSystemException; -use SPC\exception\WrongUsageException; use SPC\store\Downloader; class PhpSource extends CustomSourceBase { public const NAME = 'php-src'; - /** - * @throws DownloaderException - * @throws FileSystemException - * @throws WrongUsageException - */ public function fetch(bool $force = false, ?array $config = null, int $lock_as = SPC_DOWNLOAD_SOURCE): void { $major = defined('SPC_BUILD_PHP_VERSION') ? SPC_BUILD_PHP_VERSION : '8.4'; @@ -33,8 +26,6 @@ class PhpSource extends CustomSourceBase /** * 获取 PHP x.y 的具体版本号,例如通过 8.1 来获取 8.1.10 - * - * @throws DownloaderException */ #[ArrayShape(['type' => 'string', 'path' => 'string', 'rev' => 'string', 'url' => 'string'])] public function getLatestPHPInfo(string $major_version): array diff --git a/src/SPC/store/source/PostgreSQLSource.php b/src/SPC/store/source/PostgreSQLSource.php index 7c85a8d4..ec1d3357 100644 --- a/src/SPC/store/source/PostgreSQLSource.php +++ b/src/SPC/store/source/PostgreSQLSource.php @@ -4,26 +4,17 @@ declare(strict_types=1); namespace SPC\store\source; -use SPC\exception\DownloaderException; -use SPC\exception\FileSystemException; use SPC\store\Downloader; class PostgreSQLSource extends CustomSourceBase { public const NAME = 'postgresql'; - /** - * @throws DownloaderException - * @throws FileSystemException - */ public function fetch(bool $force = false, ?array $config = null, int $lock_as = SPC_DOWNLOAD_SOURCE): void { Downloader::downloadSource('postgresql', self::getLatestInfo(), $force); } - /** - * @throws DownloaderException - */ public function getLatestInfo(): array { [, $filename, $version] = Downloader::getFromFileList('postgresql', [ diff --git a/src/SPC/toolchain/ClangNativeToolchain.php b/src/SPC/toolchain/ClangNativeToolchain.php index 6cccb4af..86e1b63d 100644 --- a/src/SPC/toolchain/ClangNativeToolchain.php +++ b/src/SPC/toolchain/ClangNativeToolchain.php @@ -24,9 +24,6 @@ class ClangNativeToolchain implements ToolchainInterface GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_LD=ld'); } - /** - * @throws WrongUsageException - */ public function afterInit(): void { foreach (['CC', 'CXX', 'AR', 'LD'] as $env) { diff --git a/src/SPC/toolchain/ToolchainManager.php b/src/SPC/toolchain/ToolchainManager.php index 9672977d..3fe48ae1 100644 --- a/src/SPC/toolchain/ToolchainManager.php +++ b/src/SPC/toolchain/ToolchainManager.php @@ -36,9 +36,6 @@ class ToolchainManager return self::OS_DEFAULT_TOOLCHAIN[PHP_OS_FAMILY]; } - /** - * @throws WrongUsageException - */ public static function initToolchain(): void { $toolchainClass = self::getToolchainClass(); diff --git a/src/SPC/toolchain/ZigToolchain.php b/src/SPC/toolchain/ZigToolchain.php index 93d004a5..5d859e41 100644 --- a/src/SPC/toolchain/ZigToolchain.php +++ b/src/SPC/toolchain/ZigToolchain.php @@ -40,9 +40,6 @@ class ZigToolchain implements ToolchainInterface GlobalEnvManager::putenv('SPC_EXTRA_RUNTIME_OBJECTS=' . implode(' ', $found)); } - /** - * @throws WrongUsageException - */ public function afterInit(): void { if (!is_dir(Zig::getEnvironment()['PATH'])) { diff --git a/src/SPC/util/ConfigValidator.php b/src/SPC/util/ConfigValidator.php index baa42b59..58dedea6 100644 --- a/src/SPC/util/ConfigValidator.php +++ b/src/SPC/util/ConfigValidator.php @@ -12,10 +12,9 @@ use Symfony\Component\Yaml\Yaml; class ConfigValidator { /** - * 验证 source.json + * Validate source.json * - * @param array $data source.json 加载后的数据 - * @throws ValidationException + * @param array $data source.json data array */ public static function validateSource(array $data): void { @@ -66,9 +65,6 @@ class ConfigValidator } } - /** - * @throws ValidationException - */ public static function validateLibs(mixed $data, array $source_data = []): void { // check if it is an array @@ -126,9 +122,6 @@ class ConfigValidator } } - /** - * @throws ValidationException - */ public static function validateExts(mixed $data): void { if (!is_array($data)) { @@ -192,9 +185,6 @@ class ConfigValidator } } - /** - * @throws ValidationException - */ public static function validatePkgs(mixed $data): void { if (!is_array($data)) { @@ -229,8 +219,7 @@ class ConfigValidator /** * Validate pre-built.json configuration * - * @param mixed $data pre-built.json loaded data - * @throws ValidationException + * @param mixed $data pre-built.json loaded data */ public static function validatePreBuilt(mixed $data): void { @@ -309,7 +298,6 @@ class ConfigValidator * build?: bool * } * } - * @throws ValidationException */ public static function validateAndParseCraftFile(mixed $craft_file, Command $command): array { @@ -415,9 +403,6 @@ class ConfigValidator return $craft; } - /** - * @throws ValidationException - */ private static function checkSingleLicense(array $license, string $name): void { if (!is_assoc_array($license)) { @@ -443,10 +428,9 @@ class ConfigValidator /** * Validate source type configuration (shared between source.json and pkg.json) * - * @param array $item The source/package item to validate - * @param string $name The name of the item for error messages - * @param string $config_type The type of config file ("source" or "pkg") - * @throws ValidationException + * @param array $item The source/package item to validate + * @param string $name The name of the item for error messages + * @param string $config_type The type of config file ("source" or "pkg") */ private static function validateSourceTypeConfig(array $item, string $name, string $config_type): void { diff --git a/src/SPC/util/DependencyUtil.php b/src/SPC/util/DependencyUtil.php index 6a1c572d..83123f65 100644 --- a/src/SPC/util/DependencyUtil.php +++ b/src/SPC/util/DependencyUtil.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace SPC\util; -use SPC\exception\FileSystemException; use SPC\exception\WrongUsageException; use SPC\store\Config; @@ -28,8 +27,6 @@ class DependencyUtil * - 'suggests': array of suggested dependency names (string) * * @return array, suggests: array}> - * @throws WrongUsageException - * @throws FileSystemException */ public static function platExtToLibs(): array { @@ -67,10 +64,8 @@ class DependencyUtil /** * Get library dependencies in correct order * - * @param array $libs Array of library names - * @return array Ordered array of library names - * @throws WrongUsageException - * @throws FileSystemException + * @param array $libs Array of library names + * @return array Ordered array of library names */ public static function getLibs(array $libs, bool $include_suggested_libs = false): array { @@ -106,11 +101,9 @@ class DependencyUtil /** * Get extension dependencies in correct order * - * @param array $exts Array of extension names - * @param array $additional_libs Array of additional libraries - * @return array Ordered array of extension names - * @throws WrongUsageException - * @throws FileSystemException + * @param array $exts Array of extension names + * @param array $additional_libs Array of additional libraries + * @return array Ordered array of extension names */ public static function getExtsAndLibs(array $exts, array $additional_libs = [], bool $include_suggested_exts = false, bool $include_suggested_libs = false): array { diff --git a/src/SPC/util/GlobalEnvManager.php b/src/SPC/util/GlobalEnvManager.php index 9d756d7e..f2689472 100644 --- a/src/SPC/util/GlobalEnvManager.php +++ b/src/SPC/util/GlobalEnvManager.php @@ -24,10 +24,7 @@ class GlobalEnvManager } /** - * Initialize the environment variables - * - * @throws RuntimeException - * @throws WrongUsageException + * Initialize the environment variables. */ public static function init(): void { @@ -110,8 +107,6 @@ class GlobalEnvManager /** * Initialize the toolchain after the environment variables are set. * The toolchain or environment availability check is done here. - * - * @throws WrongUsageException */ public static function afterInit(): void { @@ -129,9 +124,6 @@ class GlobalEnvManager } } - /** - * @throws WrongUsageException - */ private static function readIniFile(): array { // Init env.ini file, read order: diff --git a/src/SPC/util/LicenseDumper.php b/src/SPC/util/LicenseDumper.php index bc1c6293..a6d6c998 100644 --- a/src/SPC/util/LicenseDumper.php +++ b/src/SPC/util/LicenseDumper.php @@ -42,11 +42,8 @@ class LicenseDumper /** * Dump source licenses to target directory * - * @param string $target_dir Target directory - * @return bool Success or not - * @throws WrongUsageException - * @throws FileSystemException - * @throws RuntimeException + * @param string $target_dir Target directory + * @return bool Success or not */ public function dump(string $target_dir): bool { @@ -94,9 +91,10 @@ class LicenseDumper } /** - * @return string[] - * @throws FileSystemException - * @throws RuntimeException + * Returns an iterable of source licenses for a given source name. + * + * @param string $source_name Source name + * @return string[] String iterable of source licenses */ private function getSourceLicenses(string $source_name): iterable { @@ -119,7 +117,7 @@ class LicenseDumper } /** - * @throws RuntimeException + * Loads a source license file from the specified path. */ private function loadSourceFile(string $source_name, int $index, null|array|string $in_path, ?string $custom_base_path = null): string { diff --git a/src/SPC/util/PkgConfigUtil.php b/src/SPC/util/PkgConfigUtil.php index 8bb7e985..6b7cd01d 100644 --- a/src/SPC/util/PkgConfigUtil.php +++ b/src/SPC/util/PkgConfigUtil.php @@ -17,11 +17,9 @@ class PkgConfigUtil /** * Returns the version of a module. * This method uses `pkg-config --modversion` to get the version of the specified module. - * If the module is not found, it will throw a RuntimeException. * - * @param string $pkg_config_str .pc file str, accepts multiple files - * @return string version string, e.g. "1.2.3" - * @throws RuntimeException + * @param string $pkg_config_str .pc file str, accepts multiple files + * @return string version string, e.g. "1.2.3" */ public static function getModuleVersion(string $pkg_config_str): string { @@ -36,9 +34,8 @@ class PkgConfigUtil * The reason we return the string is we cannot use array_unique() on cflags, * some cflags may contains spaces. * - * @param string $pkg_config_str .pc file string, accepts multiple files - * @return string CFLAGS string, e.g. "-Wno-implicit-int-float-conversion ..." - * @throws RuntimeException + * @param string $pkg_config_str .pc file string, accepts multiple files + * @return string CFLAGS string, e.g. "-Wno-implicit-int-float-conversion ..." */ public static function getCflags(string $pkg_config_str): string { @@ -53,9 +50,8 @@ class PkgConfigUtil * Returns --libs-only-l and --libs-only-other output. * The reason we return the array is to avoid duplicate lib defines. * - * @param string $pkg_config_str .pc file string, accepts multiple files - * @return array Unique libs array, e.g. [-lz, -lxml, ...] - * @throws RuntimeException + * @param string $pkg_config_str .pc file string, accepts multiple files + * @return array Unique libs array, e.g. [-lz, -lxml, ...] */ public static function getLibsArray(string $pkg_config_str): array { @@ -92,9 +88,8 @@ class PkgConfigUtil /** * Execute pkg-config command and return result * - * @param string $cmd The pkg-config command to execute - * @return string The command output - * @throws RuntimeException If command fails + * @param string $cmd The pkg-config command to execute + * @return string The command output */ private static function execWithResult(string $cmd): string { diff --git a/src/SPC/util/SPCConfigUtil.php b/src/SPC/util/SPCConfigUtil.php index 08570008..17c5c500 100644 --- a/src/SPC/util/SPCConfigUtil.php +++ b/src/SPC/util/SPCConfigUtil.php @@ -6,8 +6,6 @@ namespace SPC\util; use SPC\builder\BuilderBase; use SPC\builder\BuilderProvider; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\Config; use Symfony\Component\Console\Input\ArgvInput; @@ -51,11 +49,6 @@ class SPCConfigUtil * ldflags: string, * libs: string * } - * @throws \ReflectionException - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException - * @throws \Throwable */ public function config(array $extensions = [], array $libraries = [], bool $include_suggest_ext = false, bool $include_suggest_lib = false): array { diff --git a/src/SPC/util/executor/UnixAutoconfExecutor.php b/src/SPC/util/executor/UnixAutoconfExecutor.php index 4543bd7b..aed9b85f 100644 --- a/src/SPC/util/executor/UnixAutoconfExecutor.php +++ b/src/SPC/util/executor/UnixAutoconfExecutor.php @@ -46,8 +46,10 @@ class UnixAutoconfExecutor extends Executor /** * Run make * - * @param string $target Build target - * @throws RuntimeException + * @param string $target Build target + * @param false|string $with_install Run `make install` after building, or false to skip + * @param bool $with_clean Whether to clean before building + * @param array $after_env_vars Environment variables postfix */ public function make(string $target = '', false|string $with_install = 'install', bool $with_clean = true, array $after_env_vars = []): static { diff --git a/src/SPC/util/executor/UnixCMakeExecutor.php b/src/SPC/util/executor/UnixCMakeExecutor.php index 71a81951..cc4263d2 100644 --- a/src/SPC/util/executor/UnixCMakeExecutor.php +++ b/src/SPC/util/executor/UnixCMakeExecutor.php @@ -4,12 +4,9 @@ declare(strict_types=1); namespace SPC\util\executor; -use Closure; use SPC\builder\freebsd\library\BSDLibraryBase; use SPC\builder\linux\library\LinuxLibraryBase; use SPC\builder\macos\library\MacOSLibraryBase; -use SPC\exception\FileSystemException; -use SPC\exception\WrongUsageException; use SPC\store\FileSystem; use SPC\util\UnixShell; @@ -144,10 +141,6 @@ class UnixCMakeExecutor extends Executor return implode(' ', $this->configure_args); } - /** - * @throws WrongUsageException - * @throws FileSystemException - */ private function getDefaultCMakeArgs(): string { return implode(' ', $this->custom_default_args ?? [ @@ -176,9 +169,7 @@ class UnixCMakeExecutor extends Executor /** * Generate cmake toolchain file for current spc instance, and return the file path. * - * @return string CMake toolchain file path - * @throws FileSystemException - * @throws WrongUsageException + * @return string CMake toolchain file path */ private function makeCmakeToolchainFile(): string { diff --git a/src/globals/functions.php b/src/globals/functions.php index 2fef0d7f..ea3db9d9 100644 --- a/src/globals/functions.php +++ b/src/globals/functions.php @@ -47,8 +47,6 @@ function is_unix(): bool /** * Transfer architecture name to gnu triplet - * - * @throws WrongUsageException */ function arch2gnu(string $arch): string { @@ -87,8 +85,7 @@ function quote(string $str, string $quote = '"'): string } /** - * Get Family name of current OS - * @throws WrongUsageException + * Get Family name of current OS. */ function osfamily2dir(): string { @@ -127,8 +124,6 @@ function cmd(?bool $debug = null): WindowsCmd /** * Get current builder. - * - * @throws WrongUsageException */ function builder(): BuilderBase { @@ -137,8 +132,6 @@ function builder(): BuilderBase /** * Get current patch point. - * - * @throws WrongUsageException */ function patch_point(): string { @@ -155,8 +148,6 @@ function patch_point_interrupt(int $retcode, string $msg = ''): InterruptExcepti /** * Execute the shell command, and the output will be directly printed in the terminal. If there is an error, an exception will be thrown - * - * @throws RuntimeException */ function f_passthru(string $cmd): ?bool { diff --git a/tests/SPC/globals/GlobalFunctionsTest.php b/tests/SPC/globals/GlobalFunctionsTest.php index 25c22198..038610f6 100644 --- a/tests/SPC/globals/GlobalFunctionsTest.php +++ b/tests/SPC/globals/GlobalFunctionsTest.php @@ -41,9 +41,6 @@ class GlobalFunctionsTest extends TestCase $this->assertInstanceOf('Psr\Log\LoggerInterface', logger()); } - /** - * @throws WrongUsageException - */ public function testArch2Gnu(): void { $this->assertEquals('x86_64', arch2gnu('x86_64')); @@ -61,9 +58,6 @@ class GlobalFunctionsTest extends TestCase $this->assertEquals("'hello'", quote('hello', "'")); } - /** - * @throws RuntimeException - */ public function testFPassthru(): void { if (PHP_OS_FAMILY === 'Windows') { diff --git a/tests/SPC/store/ConfigTest.php b/tests/SPC/store/ConfigTest.php index 6b7555c9..84701cd4 100644 --- a/tests/SPC/store/ConfigTest.php +++ b/tests/SPC/store/ConfigTest.php @@ -5,8 +5,6 @@ declare(strict_types=1); namespace SPC\Tests\store; use PHPUnit\Framework\TestCase; -use SPC\exception\FileSystemException; -use SPC\exception\WrongUsageException; use SPC\store\Config; use SPC\store\FileSystem; @@ -15,9 +13,6 @@ use SPC\store\FileSystem; */ class ConfigTest extends TestCase { - /** - * @throws FileSystemException - */ public static function setUpBeforeClass(): void { $testdir = WORKING_DIR . '/.configtest'; @@ -30,26 +25,16 @@ class ConfigTest extends TestCase FileSystem::loadConfigArray('source', $testdir); } - /** - * @throws FileSystemException - */ public static function tearDownAfterClass(): void { FileSystem::removeDir(WORKING_DIR . '/.configtest'); } - /** - * @throws FileSystemException - */ public function testGetExts() { $this->assertTrue(is_assoc_array(Config::getExts())); } - /** - * @throws FileSystemException - * @throws WrongUsageException - */ public function testGetLib() { $this->assertIsArray(Config::getLib('zlib')); @@ -60,35 +45,22 @@ class ConfigTest extends TestCase }; } - /** - * @throws WrongUsageException - * @throws FileSystemException - */ public function testGetExt() { $this->assertIsArray(Config::getExt('bcmath')); $this->assertEquals('builtin', Config::getExt('bcmath', 'type')); } - /** - * @throws FileSystemException - */ public function testGetSources() { $this->assertTrue(is_assoc_array(Config::getSources())); } - /** - * @throws FileSystemException - */ public function testGetSource() { $this->assertIsArray(Config::getSource('php-src')); } - /** - * @throws FileSystemException - */ public function testGetLibs() { $this->assertTrue(is_assoc_array(Config::getLibs())); diff --git a/tests/SPC/store/FileSystemTest.php b/tests/SPC/store/FileSystemTest.php index e2d18f73..b7f766fd 100644 --- a/tests/SPC/store/FileSystemTest.php +++ b/tests/SPC/store/FileSystemTest.php @@ -30,9 +30,6 @@ class FileSystemTest extends TestCase } } - /** - * @throws FileSystemException - */ public function testReplaceFileRegex() { $file = WORKING_DIR . '/.txt1'; @@ -54,9 +51,6 @@ class FileSystemTest extends TestCase } } - /** - * @throws FileSystemException - */ public function testReadFile() { $file = WORKING_DIR . '/.testread'; @@ -66,9 +60,6 @@ class FileSystemTest extends TestCase @unlink($file); } - /** - * @throws FileSystemException - */ public function testReplaceFileUser() { $file = WORKING_DIR . '/.txt1'; @@ -88,10 +79,6 @@ class FileSystemTest extends TestCase $this->assertEquals('', FileSystem::extname('/tmp/asd.')); } - /** - * @throws \ReflectionException - * @throws FileSystemException - */ public function testGetClassesPsr4() { $classes = FileSystem::getClassesPsr4(ROOT_DIR . '/src/SPC/builder/extension', 'SPC\builder\extension'); @@ -109,9 +96,6 @@ class FileSystemTest extends TestCase } } - /** - * @throws FileSystemException - */ public function testCreateDir() { FileSystem::createDir(WORKING_DIR . '/.testdir'); @@ -119,9 +103,6 @@ class FileSystemTest extends TestCase rmdir(WORKING_DIR . '/.testdir'); } - /** - * @throws FileSystemException - */ public function testReplaceFileStr() { $file = WORKING_DIR . '/.txt1'; @@ -133,9 +114,6 @@ class FileSystemTest extends TestCase unlink($file); } - /** - * @throws FileSystemException - */ public function testResetDir() { // prepare fake git dir to test @@ -146,10 +124,6 @@ class FileSystemTest extends TestCase FileSystem::removeDir(WORKING_DIR . '/.fake_down_test'); } - /** - * @throws FileSystemException - * @throws RuntimeException - */ public function testCopyDir() { // prepare fake git dir to test @@ -162,9 +136,6 @@ class FileSystemTest extends TestCase FileSystem::removeDir(WORKING_DIR . '/.fake_down_test2'); } - /** - * @throws FileSystemException - */ public function testRemoveDir() { FileSystem::createDir(WORKING_DIR . '/.fake_down_test'); @@ -173,9 +144,6 @@ class FileSystemTest extends TestCase $this->assertDirectoryDoesNotExist(WORKING_DIR . '/.fake_down_test'); } - /** - * @throws FileSystemException - */ public function testLoadConfigArray() { $arr = FileSystem::loadConfigArray('lib'); @@ -200,9 +168,6 @@ class FileSystemTest extends TestCase $this->assertContains('lib.json', $files); } - /** - * @throws FileSystemException - */ public function testWriteFile() { FileSystem::writeFile(WORKING_DIR . '/.txt', 'txt'); diff --git a/tests/SPC/util/ConfigValidatorTest.php b/tests/SPC/util/ConfigValidatorTest.php index ad31791d..f132636f 100644 --- a/tests/SPC/util/ConfigValidatorTest.php +++ b/tests/SPC/util/ConfigValidatorTest.php @@ -308,9 +308,6 @@ class ConfigValidatorTest extends TestCase } } - /** - * @throws ValidationException - */ public function testValidateExts(): void { // Test valid extensions diff --git a/tests/SPC/util/SPCConfigUtilTest.php b/tests/SPC/util/SPCConfigUtilTest.php index 0c0fbc7e..92353824 100644 --- a/tests/SPC/util/SPCConfigUtilTest.php +++ b/tests/SPC/util/SPCConfigUtilTest.php @@ -6,7 +6,6 @@ namespace SPC\Tests\util; use PHPUnit\Framework\TestCase; use SPC\builder\BuilderProvider; -use SPC\exception\FileSystemException; use SPC\store\FileSystem; use SPC\util\SPCConfigUtil; use Symfony\Component\Console\Input\ArgvInput; @@ -16,9 +15,6 @@ use Symfony\Component\Console\Input\ArgvInput; */ class SPCConfigUtilTest extends TestCase { - /** - * @throws FileSystemException - */ public static function setUpBeforeClass(): void { if (PHP_OS_FAMILY === 'Windows') { @@ -35,9 +31,6 @@ class SPCConfigUtilTest extends TestCase FileSystem::loadConfigArray('source', $testdir); } - /** - * @throws FileSystemException - */ public static function tearDownAfterClass(): void { FileSystem::removeDir(WORKING_DIR . '/.configtest');