1
0
Fork 0
mirror of https://github.com/mlocati/docker-php-extension-installer synced 2025-05-09 00:22:40 +00:00

Add support for testing more than one PHP extension at once

This commit is contained in:
Michele Locati 2019-12-18 16:45:20 +01:00
parent 9d30d8806f
commit 2de4f3462d
No known key found for this signature in database
GPG key ID: 98B7CE2E7234E28B
3 changed files with 99 additions and 44 deletions

View file

@ -1,24 +1,35 @@
<?php
$extension = isset($argv[1]) ? trim($argv[1]) : '';
$rc = 1;
if ($extension === '') {
fprintf(STDERR, "Missing module handle.\n");
} else {
$nameMap = array(
'opcache' => 'Zend OPcache',
);
$extensionLowerCase = strtolower($extension);
if (isset($nameMap[$extensionLowerCase])) {
$extension = $nameMap[$extensionLowerCase];
}
if (!extension_loaded($extension)) {
fprintf(STDERR, sprintf("Extension not loaded: %s\n", $extension));
$rc = 0;
$numTestedExtensions = 0;
$nameMap = array(
'opcache' => 'Zend OPcache',
);
for ($index = 1, $count = isset($argv) ? count($argv) : 0; $index < $count; $index++) {
$numTestedExtensions++;
$rcThis = 1;
$extension = $argv[$index];
if ($extension === '') {
fprintf(STDERR, "Missing extension handle.\n");
} else {
fprintf(STDOUT, sprintf("Extension correctly loaded: %s\n", $extension));
$rc = 0;
$extensionLowerCase = strtolower($extension);
if (isset($nameMap[$extensionLowerCase])) {
$extension = $nameMap[$extensionLowerCase];
}
if (!extension_loaded($extension)) {
fprintf(STDERR, sprintf("Extension not loaded: %s\n", $extension));
} else {
fprintf(STDOUT, sprintf("Extension correctly loaded: %s\n", $extension));
$rcThis = 0;
}
}
if ($rcThis !== 0) {
$rc = $rcThis;
}
}
if ($numTestedExtensions === 0) {
fprintf(STDERR, "No extension handles specified.\n");
$rc = 1;
}
exit($rc);