Remove all @throws PHPDoc, it's almost useless for SPC anymore

This commit is contained in:
crazywhalecc
2025-08-06 20:17:26 +08:00
committed by Jerry Ma
parent fa10142f13
commit 0c9a30256e
120 changed files with 169 additions and 1203 deletions

View File

@@ -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
{

View File

@@ -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<string, array{depends: array<int, string>, suggests: array<int, string>}>
* @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
{

View File

@@ -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:

View File

@@ -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
{

View File

@@ -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
{

View File

@@ -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
{

View File

@@ -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
{

View File

@@ -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
{