Skip to content

Commit

Permalink
fix: Fix the extension name used for the requirements for Zend OPcache (
Browse files Browse the repository at this point in the history
#871)

Closes #653.
  • Loading branch information
theofidry authored Feb 11, 2023
1 parent 7b6c8dd commit 812a770
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/RequirementChecker/PackageInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@
*/
final class PackageInfo
{
public const EXTENSION_REGEX = '/^ext-(?<extension>.+)$/';
private const EXTENSION_REGEX = '/^ext-(?<extension>.+)$/';

// Some extensions name differs in how they are registered in composer.json
// and the name used when doing a `extension_loaded()` check.
// See https://github.com/box-project/box/issues/653.
private const EXTENSION_NAME_MAP = [
'zend-opcache' => 'zend opcache',
];

private const POLYFILL_MAP = [
'paragonie/sodium_compat' => 'libsodium',
Expand Down Expand Up @@ -93,7 +100,9 @@ public static function parseExtensions(array $constraints): array

foreach ($constraints as $package => $constraint) {
if (preg_match(self::EXTENSION_REGEX, $package, $matches)) {
$extensions[] = $matches['extension'];
$extension = $matches['extension'];

$extensions[] = self::EXTENSION_NAME_MAP[$extension] ?? $extension;
}
}

Expand Down
4 changes: 3 additions & 1 deletion tests/RequirementChecker/PackageInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ public static function packageInfoProvider(): iterable
'ext-json' => '*',
'ext-phar' => '*',
'ext-xdebug' => '3.0',
'ext-zend-opcache' => '*',
],
'require-dev' => [
'ext-zend-opcache' => '*',
'ext-http' => '*',
],
],
'box/test',
Expand All @@ -107,6 +108,7 @@ public static function packageInfoProvider(): iterable
'json',
'phar',
'xdebug',
'zend opcache',
],
[],
];
Expand Down

0 comments on commit 812a770

Please sign in to comment.