Skip to content

Commit a7df737

Browse files
authored
Merge pull request #399 from asgrim/fix-case-sensitive-ext-requires
Fix case sensitivity of ext requires in pie install and pie show
2 parents f6ba46c + 0aa4228 commit a7df737

File tree

5 files changed

+16
-2
lines changed

5 files changed

+16
-2
lines changed

src/Command/InstallExtensionsForProjectCommand.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
use function is_string;
4646
use function realpath;
4747
use function sprintf;
48+
use function strtolower;
4849

4950
use const PHP_EOL;
5051

@@ -152,7 +153,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
152153
),
153154
);
154155

155-
$phpEnabledExtensions = array_keys($targetPlatform->phpBinaryPath->extensions());
156+
$phpEnabledExtensions = array_map('strtolower', array_keys($targetPlatform->phpBinaryPath->extensions()));
156157
$installedPiePackages = $this->installedPiePackages->allPiePackages($pieComposer);
157158

158159
$anyErrorsHappened = false;
@@ -177,7 +178,7 @@ function (Link $link) use ($pieComposer, $phpEnabledExtensions, $installedPiePac
177178
);
178179
}
179180

180-
if (in_array($extension->name(), $phpEnabledExtensions)) {
181+
if (in_array(strtolower($extension->name()), $phpEnabledExtensions)) {
181182
if ($piePackageVersion !== null && $piePackageVersionMatchesLinkConstraint === false) {
182183
$this->io->write(sprintf(
183184
'%s: <comment>%s:%s</comment> %s Version %s is installed, but does not meet the version requirement %s',

src/Command/ShowCommand.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ function (string $version, string $phpExtensionName) use ($composer, $rootPackag
125125
$packageRequirement = $rootPackageRequires[$piePackage->name()]->getPrettyConstraint();
126126

127127
try {
128+
// Don't check for updates for bundled PHP extensions
129+
if ($piePackage->isBundledPhpExtension()) {
130+
throw new BundledPhpExtensionRefusal();
131+
}
132+
128133
Assert::stringNotEmpty($packageName);
129134
Assert::stringNotEmpty($packageRequirement);
130135

src/Platform/InstalledPiePackages.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ static function (BasePackage $basePackage): bool {
4848
/** @return non-empty-string */
4949
static function (Package $package): string {
5050
return match ($package->extensionName()->name()) {
51+
'core' => 'Core',
52+
'spl' => 'SPL',
53+
'phar' => 'Phar',
54+
'reflection' => 'Reflection',
55+
'pdo' => 'PDO',
5156
'ffi' => 'FFI',
5257
'opcache' => 'Zend OPcache',
5358
'simplexml' => 'SimpleXML',

test/install-bundled-php-exts.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ static function (PackageInterface $package) use ($phpVersionConstraint): bool {
6161
}
6262
}
6363

64+
echo Process::run([$phpBinaryPath->phpBinaryPath, '-m'], timeout: 60);
6465
echo Process::run(['bin/pie', 'show', '--with-php-config=' . $phpBinaryPath->phpConfigPath()], timeout: 60);
6566

6667
if ($anyFailures) {

test/integration/Command/InstallExtensionsForProjectCommandTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public function testInstallingExtensionsForPhpProject(): void
9999
$rootPackage = new RootPackage('my/project', '1.2.3.0', '1.2.3');
100100
$rootPackage->setRequires([
101101
'ext-standard' => new Link('my/project', 'ext-standard', new Constraint('=', '*'), Link::TYPE_REQUIRE, '*'),
102+
'ext-spl' => new Link('my/project', 'ext-spl', new Constraint('=', '*'), Link::TYPE_REQUIRE, '*'),
102103
'ext-foobar' => new Link('my/project', 'ext-foobar', new MultiConstraint([
103104
new Constraint('>=', '1.2.0.0-dev'),
104105
new Constraint('<', '2.0.0.0-dev'),
@@ -137,6 +138,7 @@ public function testInstallingExtensionsForPhpProject(): void
137138
$this->commandTester->assertCommandIsSuccessful($outputString);
138139
self::assertStringContainsString('Checking extensions for your project my/project', $outputString);
139140
self::assertStringContainsString('requires: ext-standard:* ✅ Already installed', $outputString);
141+
self::assertStringContainsString('requires: ext-spl:* ✅ Already installed', $outputString);
140142
self::assertStringContainsString('requires: ext-foobar:^1.2 🚫 Missing', $outputString);
141143
}
142144

0 commit comments

Comments
 (0)