mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-04 07:15:38 +08:00
Add command to dump required PHP extensions based on vendor/composer/… (#599)
* Add command to dump required PHP extensions based on vendor/composer/installed.json, composer.lock, composer.json (in this order) * remove unused use * missing translation * Adjust dump-extensions * Add docs for dump-extension command --------- Co-authored-by: crazywhalecc <jesse2061@outlook.com>
This commit is contained in:
@@ -154,24 +154,24 @@ abstract class BaseCommand extends Command
|
||||
/**
|
||||
* Parse extension list from string, replace alias and filter internal extensions.
|
||||
*
|
||||
* @param string $ext_list Extension string list, e.g. "mbstring,posix,sockets"
|
||||
* @param array|string $ext_list Extension string list, e.g. "mbstring,posix,sockets" or array
|
||||
*/
|
||||
protected function parseExtensionList(string $ext_list): array
|
||||
protected function parseExtensionList(array|string $ext_list): array
|
||||
{
|
||||
// replace alias
|
||||
$ls = array_map(function ($x) {
|
||||
$lower = strtolower(trim($x));
|
||||
if (isset(SPC_EXTENSION_ALIAS[$lower])) {
|
||||
logger()->notice("Extension [{$lower}] is an alias of [" . SPC_EXTENSION_ALIAS[$lower] . '], it will be replaced.');
|
||||
logger()->debug("Extension [{$lower}] is an alias of [" . SPC_EXTENSION_ALIAS[$lower] . '], it will be replaced.');
|
||||
return SPC_EXTENSION_ALIAS[$lower];
|
||||
}
|
||||
return $lower;
|
||||
}, explode(',', $ext_list));
|
||||
}, is_array($ext_list) ? $ext_list : explode(',', $ext_list));
|
||||
|
||||
// filter internals
|
||||
return array_values(array_filter($ls, function ($x) {
|
||||
if (in_array($x, SPC_INTERNAL_EXTENSIONS)) {
|
||||
logger()->warning("Extension [{$x}] is an builtin extension, it will be ignored.");
|
||||
logger()->debug("Extension [{$x}] is an builtin extension, it will be ignored.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user