Skip to content

Commit 02a0b17

Browse files
committed
make sure embed can only contain null, static, shared or false
1 parent 68c706e commit 02a0b17

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/SPC/command/BuildPHPCommand.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -295,14 +295,14 @@ private function parseRules(array $shared_extensions = []): int
295295
$rule |= ($this->getOption('build-micro') ? BUILD_TARGET_MICRO : BUILD_TARGET_NONE);
296296
$rule |= ($this->getOption('build-fpm') ? BUILD_TARGET_FPM : BUILD_TARGET_NONE);
297297
$embed = $this->getOption('build-embed');
298-
$embed = $embed === null ? true : $embed;
299-
if (!$embed && !empty($shared_extensions)) {
300-
$embed = true;
301-
}
298+
$embed = match ($embed) {
299+
null => getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') ?: 'static',
300+
'static' => 'static',
301+
'shared' => 'shared',
302+
false => false,
303+
default => throw new WrongUsageException('Invalid --build-embed option, please use --build-embed[=static|shared]'),
304+
};
302305
if ($embed) {
303-
if ($embed === true) {
304-
$embed = getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') ?: 'static';
305-
}
306306
$rule |= BUILD_TARGET_EMBED;
307307
f_putenv('SPC_CMD_VAR_PHP_EMBED_TYPE=' . ($embed === 'static' ? 'static' : 'shared'));
308308
}

0 commit comments

Comments
 (0)