From 097af804a7a504619190bf5f95170e0091e626bb Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 8 Apr 2026 22:13:44 +0800 Subject: [PATCH] Add OS support checks to PhpExtensionPackage --- src/StaticPHP/Package/PhpExtensionPackage.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/StaticPHP/Package/PhpExtensionPackage.php b/src/StaticPHP/Package/PhpExtensionPackage.php index ca3dab73..6ee1edf5 100644 --- a/src/StaticPHP/Package/PhpExtensionPackage.php +++ b/src/StaticPHP/Package/PhpExtensionPackage.php @@ -61,6 +61,28 @@ class PhpExtensionPackage extends Package return str_replace('ext-', '', $this->getName()); } + /** + * Get the list of OS platforms that this extension supports. + * Returns an empty array if no restriction is defined (all platforms supported). + */ + public function getSupportedOSList(): array + { + return $this->extension_config['os'] ?? []; + } + + /** + * Check if this extension is supported on the current target OS. + * Returns true if no 'os' restriction is defined, or if the current OS is in the list. + */ + public function isSupportedOnCurrentOS(): bool + { + $osList = $this->getSupportedOSList(); + if (empty($osList)) { + return true; + } + return in_array(SystemTarget::getTargetOS(), $osList, true); + } + public function addCustomPhpConfigureArgCallback(string $os, callable $fn): void { if ($os === '') {