Skip to content

Commit 097af80

Browse files
committed
Add OS support checks to PhpExtensionPackage
1 parent a5a3a99 commit 097af80

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

src/StaticPHP/Package/PhpExtensionPackage.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,28 @@ public function getExtensionName(): string
6161
return str_replace('ext-', '', $this->getName());
6262
}
6363

64+
/**
65+
* Get the list of OS platforms that this extension supports.
66+
* Returns an empty array if no restriction is defined (all platforms supported).
67+
*/
68+
public function getSupportedOSList(): array
69+
{
70+
return $this->extension_config['os'] ?? [];
71+
}
72+
73+
/**
74+
* Check if this extension is supported on the current target OS.
75+
* Returns true if no 'os' restriction is defined, or if the current OS is in the list.
76+
*/
77+
public function isSupportedOnCurrentOS(): bool
78+
{
79+
$osList = $this->getSupportedOSList();
80+
if (empty($osList)) {
81+
return true;
82+
}
83+
return in_array(SystemTarget::getTargetOS(), $osList, true);
84+
}
85+
6486
public function addCustomPhpConfigureArgCallback(string $os, callable $fn): void
6587
{
6688
if ($os === '') {

0 commit comments

Comments
 (0)