From 370f225b646430e0b97e0435655d17e7539ca5c5 Mon Sep 17 00:00:00 2001 From: James Titcumb Date: Wed, 21 Oct 2026 20:12:18 +0100 Subject: [PATCH 1/3] 780: handle --with-php-path and --with-php-config properly fallback --- src/Command/CommandHelper.php | 10 +++--- test/integration/Command/ShowCommandTest.php | 34 ++++++++++++++++++++ 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/Command/CommandHelper.php b/src/Command/CommandHelper.php index ecd6c39f..a1fe7c6b 100644 --- a/src/Command/CommandHelper.php +++ b/src/Command/CommandHelper.php @@ -232,8 +232,6 @@ public static function validateInput(InputInterface $input, Command $command): v public static function determineTargetPlatformFromInputs(InputInterface $input, IOInterface $io): TargetPlatform { - $phpBinaryPath = PhpBinaryPath::fromCurrentProcess(); - /** @var mixed $withPhpConfig */ $withPhpConfig = $input->getOption(self::OPTION_WITH_PHP_CONFIG); $specifiedWithPhpConfig = is_string($withPhpConfig) && $withPhpConfig !== ''; @@ -249,12 +247,12 @@ public static function determineTargetPlatformFromInputs(InputInterface $input, throw new InvalidArgumentException('The --with-php-path=/path/to/php cannot be used on non-Windows, use --with-php-config=/path/to/php-config instead.'); } - if ($specifiedWithPhpConfig) { - $phpBinaryPath = PhpBinaryPath::fromPhpConfigExecutable($withPhpConfig); - } - if ($specifiedWithPhpPath) { $phpBinaryPath = PhpBinaryPath::fromPhpBinaryPath($withPhpPath); + } elseif ($specifiedWithPhpConfig) { + $phpBinaryPath = PhpBinaryPath::fromPhpConfigExecutable($withPhpConfig); + } else { + $phpBinaryPath = PhpBinaryPath::fromCurrentProcess(); } $makeParallelJobs = null; /** `null` means {@see TargetPlatform} will try to auto-detect */ diff --git a/test/integration/Command/ShowCommandTest.php b/test/integration/Command/ShowCommandTest.php index 031e0009..7eb3ad9f 100644 --- a/test/integration/Command/ShowCommandTest.php +++ b/test/integration/Command/ShowCommandTest.php @@ -4,6 +4,7 @@ namespace Php\PieIntegrationTest\Command; +use Composer\Util\Platform; use InvalidArgumentException; use Php\Pie\Command\InstallCommand; use Php\Pie\Command\ShowCommand; @@ -17,9 +18,14 @@ use Webmozart\Assert\Assert; use function get_loaded_extensions; +use function getenv; use function phpversion; +use function Safe\putenv; use function str_contains; +use function sys_get_temp_dir; +use const DIRECTORY_SEPARATOR; +use const PHP_BINARY; use const PHP_VERSION_ID; #[CoversClass(ShowCommand::class)] @@ -50,6 +56,34 @@ public function testExecute(): void } } + public function testExecuteWithExplicitTargetPhpWhenRunningPhpCannotBeFound(): void + { + if (Platform::isWindows()) { + $targetPhpOption = ['--with-php-path' => PHP_BINARY]; + } else { + try { + $phpConfig = Process::run(['which', 'php-config']); + Assert::stringNotEmpty($phpConfig); + } catch (ProcessFailedException | InvalidArgumentException) { + self::markTestSkipped('This test can only run on systems with php-config'); + } + + $targetPhpOption = ['--with-php-config' => $phpConfig]; + } + + $originalPhpBinaryEnv = getenv('PHP_BINARY'); + putenv('PHP_BINARY=' . sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'php-that-does-not-exist'); + + try { + $this->commandTester->execute($targetPhpOption); + } finally { + putenv($originalPhpBinaryEnv === false ? 'PHP_BINARY' : 'PHP_BINARY=' . $originalPhpBinaryEnv); + } + + $this->commandTester->assertCommandIsSuccessful(); + self::assertStringContainsString('Target PHP installation:', $this->commandTester->getDisplay()); + } + public function testExecuteWithAvailableConstrainedUpdates(): void { if (PHP_VERSION_ID >= 80500) { From 4d197996d731e26c769bbc3a53364df6f12f4d94 Mon Sep 17 00:00:00 2001 From: James Titcumb Date: Wed, 21 Oct 2026 20:19:06 +0100 Subject: [PATCH 2/3] 780: backport ea76188 to fix isRunningStaticPhp() check --- src/Platform.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Platform.php b/src/Platform.php index e2a3f778..31a73604 100644 --- a/src/Platform.php +++ b/src/Platform.php @@ -22,6 +22,7 @@ use const DIRECTORY_SEPARATOR; use const PHP_BUILD_PROVIDER; +use const PHP_SAPI; use const STDIN; /** @internal This is not public API for PIE, so should not be depended upon unless you accept the risk of BC breaks */ @@ -135,6 +136,6 @@ public static function getPieJsonFilename(TargetPlatform $targetPlatform): strin public static function isRunningStaticPhp(): bool { - return defined('PHP_BUILD_PROVIDER') && str_contains(PHP_BUILD_PROVIDER, 'static-php-cli'); + return PHP_SAPI === 'micro' || (defined('PHP_BUILD_PROVIDER') && str_contains(PHP_BUILD_PROVIDER, 'static-php-cli')); } } From e5bd5c14d8b339edb79da458c04866922e3ce381 Mon Sep 17 00:00:00 2001 From: James Titcumb Date: Wed, 21 Oct 2026 21:44:43 +0100 Subject: [PATCH 3/3] 780: temporarily disable ubi9 and rocky e2e flaky tests --- test/end-to-end/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/end-to-end/Dockerfile b/test/end-to-end/Dockerfile index c3c0acba..73451fec 100644 --- a/test/end-to-end/Dockerfile +++ b/test/end-to-end/Dockerfile @@ -24,13 +24,13 @@ COPY --from=build_pie_phar /app/pie.phar /usr/local/bin/pie RUN pie install --auto-install-build-tools -v asgrim/example-pie-extension:2.0.5 RUN pie show -FROM quay.io/rockylinux/rockylinux:10 AS test_pie_installs_build_tools_on_rocky +FROM quay.io/rockylinux/rockylinux:10 AS disabled_test_pie_installs_build_tools_on_rocky RUN dnf install -y php8.4-cli epel-release unzip COPY --from=build_pie_phar /app/pie.phar /usr/local/bin/pie RUN pie install --auto-install-build-tools -vv asgrim/example-pie-extension:2.0.5 RUN pie show -FROM ubi9_base AS test_pie_installs_build_tools_on_ubi9 +FROM ubi9_base AS disabled_test_pie_installs_build_tools_on_ubi9 RUN microdnf module enable -y php:8.3 && microdnf install -y php-cli php-pecl-zip unzip COPY --from=build_pie_phar /app/pie.phar /usr/local/bin/pie RUN pie install --auto-install-build-tools -v asgrim/example-pie-extension:2.0.5