Skip to content

Commit 63f95e6

Browse files
committed
dedup loaded ext names remap
1 parent a682d60 commit 63f95e6

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

run-tests.php

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -878,13 +878,7 @@ function write_information(): void
878878
// load list of enabled and loadable extensions
879879
save_text($info_file, <<<'PHP'
880880
<?php
881-
$exts = [];
882-
foreach (get_loaded_extensions() as $ext) {
883-
if ($ext === 'Core') {
884-
continue;
885-
}
886-
$exts[] = ['Zend OPcache' => 'opcache'][$ext] ?? $ext;
887-
}
881+
$exts = remap_loaded_extensions_names(get_loaded_extensions());
888882
$ext_dir = ini_get('extension_dir');
889883
foreach (scandir($ext_dir) as $file) {
890884
if (!preg_match('/^(?:php_)?([_a-zA-Z0-9]+)\.(?:so|dll)$/', $file, $matches)) {
@@ -2785,6 +2779,19 @@ function run_test(string $php, $file, array $env): string
27852779
return $restype[0] . 'ED';
27862780
}
27872781

2782+
function remap_loaded_extensions_names(array $names): array
2783+
{
2784+
$exts = [];
2785+
foreach ($names as $name) {
2786+
if ($name === 'Core') {
2787+
continue;
2788+
}
2789+
$exts[] = strtolower(['Zend OPcache' => 'opcache'][$name] ?? $name);
2790+
}
2791+
2792+
return $exts;
2793+
}
2794+
27882795
/**
27892796
* @return bool|int
27902797
*/
@@ -3672,13 +3679,8 @@ public function getExtensions(string $php): array
36723679
}
36733680

36743681
$extDir = shell_exec("$php -d display_errors=0 -r \"echo ini_get('extension_dir');\"");
3675-
$extensionsRaw = explode(",", shell_exec("$php -d display_errors=0 -r \"echo implode(',', get_loaded_extensions());\""));
3676-
foreach ($extensionsRaw as $ext) {
3677-
if ($ext === 'Core') {
3678-
continue;
3679-
}
3680-
$extensions[] = strtolower(['Zend OPcache' => 'opcache'][$ext] ?? $ext);
3681-
}
3682+
$extensions = explode(",", shell_exec("$php -d display_errors=0 -r \"echo implode(',', get_loaded_extensions());\""));
3683+
$extensions = remap_loaded_extensions_names($extensions);
36823684

36833685
$result = [$extDir, $extensions];
36843686
$this->extensions[$php] = $result;

0 commit comments

Comments
 (0)