mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-05 07:45:39 +08:00
Merge pull request #835 from crazywhalecc/chore/test-and-validate
Chore: PHPUnit test & docs & PHPDoc for vendor mode
This commit is contained in:
@@ -7,9 +7,6 @@ namespace SPC\store;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
|
||||
/**
|
||||
* 一个读取 config 配置的操作类
|
||||
*/
|
||||
class Config
|
||||
{
|
||||
public static ?array $pkg = null;
|
||||
@@ -23,6 +20,10 @@ class Config
|
||||
public static ?array $pre_built = null;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
@@ -50,8 +51,10 @@ class Config
|
||||
}
|
||||
|
||||
/**
|
||||
* 从配置文件读取一个资源(source)的元信息
|
||||
* 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
|
||||
*/
|
||||
public static function getSource(string $name): ?array
|
||||
@@ -63,8 +66,10 @@ class Config
|
||||
}
|
||||
|
||||
/**
|
||||
* Read pkg from pkg.json
|
||||
* 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
|
||||
*/
|
||||
public static function getPkg(string $name): ?array
|
||||
@@ -76,11 +81,13 @@ class Config
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据不同的操作系统分别选择不同的 lib 库依赖项
|
||||
* 如果 key 为 null,那么直接返回整个 meta。
|
||||
* 如果 key 不为 null,则可以使用的 key 有 static-libs、headers、lib-depends、lib-suggests。
|
||||
* 对于 macOS 平台,支持 frameworks。
|
||||
* 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
|
||||
*/
|
||||
@@ -115,6 +122,9 @@ class Config
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all library configurations
|
||||
*
|
||||
* @return array All library configurations
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public static function getLibs(): array
|
||||
@@ -126,6 +136,10 @@ 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
|
||||
*/
|
||||
@@ -141,6 +155,13 @@ 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
|
||||
*/
|
||||
@@ -175,6 +196,9 @@ class Config
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all extension configurations
|
||||
*
|
||||
* @return array All extension configurations
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public static function getExts(): array
|
||||
@@ -186,6 +210,9 @@ class Config
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all source configurations
|
||||
*
|
||||
* @return array All source configurations
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public static function getSources(): array
|
||||
|
||||
Reference in New Issue
Block a user