From 637a55d3da49e5077d608445dd18b1e979dafda4 Mon Sep 17 00:00:00 2001 From: James Titcumb Date: Thu, 12 Feb 2026 12:42:09 +0000 Subject: [PATCH] Rework PhpizePath to be passed to TargetPlatform --- phpstan-baseline.neon | 12 +- src/Building/Build.php | 2 - src/Building/UnixBuild.php | 6 +- src/Building/WindowsBuild.php | 2 - src/Command/BuildCommand.php | 2 - src/Command/CommandHelper.php | 35 +++--- src/Command/DownloadCommand.php | 1 - src/Command/InfoCommand.php | 1 - src/Command/InstallCommand.php | 2 - src/Command/UninstallCommand.php | 1 - .../InstallAndBuildProcess.php | 1 - .../InstalledJsonMetadata.php | 2 +- .../PieComposerRequest.php | 3 - src/Platform/TargetPlatform.php | 5 +- .../BuildTools/BinaryBuildToolFinder.php | 2 +- .../BuildTools/CheckAllBuildTools.php | 3 +- .../BuildTools/PhpizeBuildToolFinder.php | 27 ++++- test/assets/phpize/bad/phpize | 3 + test/assets/phpize/good/php | 5 + test/assets/phpize/good/phpize | 9 ++ test/install-bundled-php-exts.php | 1 + test/integration/Building/UnixBuildTest.php | 21 ++-- test/integration/Command/ShowCommandTest.php | 3 + .../ResolveDependencyWithComposerTest.php | 3 +- .../GithubPackageReleaseAssetsTest.php | 1 + .../Installing/UnixInstallTest.php | 6 +- .../Installing/WindowsInstallTest.php | 1 + .../BundledPhpExtensionsRepositoryTest.php | 1 + .../InstallAndBuildProcessTest.php | 6 +- .../InstalledJsonMetadataTest.php | 4 +- ...OverrideDownloadUrlInstallListenerTest.php | 20 ++-- .../RemoveUnrelatedInstallOperationsTest.php | 4 +- .../VersionSelectorFactoryTest.php | 1 + .../ResolveDependencyWithComposerTest.php | 8 ++ .../Downloading/DownloadUrlMethodTest.php | 5 + .../CouldNotFindReleaseAssetTest.php | 3 + .../GithubPackageReleaseAssetsTest.php | 3 + .../CheckAndAddExtensionToIniIfNeededTest.php | 1 + .../Installing/Ini/DockerPhpExtEnableTest.php | 1 + .../Installing/Ini/OndrejPhpenmodTest.php | 1 + .../Ini/PickBestSetupIniApproachTest.php | 1 + .../PreCheckExtensionAlreadyLoadedTest.php | 1 + .../RemoveIniEntryWithFileGetContentsTest.php | 3 + .../StandardAdditionalPhpIniDirectoryTest.php | 1 + .../Ini/StandardSinglePhpIniTest.php | 1 + .../PrePackagedBinaryAssetNameTest.php | 3 + test/unit/Platform/TargetPlatformTest.php | 53 ++++++++- .../WindowsExtensionAssetNameTest.php | 1 + .../BuildTools/BinaryBuildToolFinderTest.php | 26 +++-- .../BuildTools/CheckAllBuildToolsTest.php | 4 + .../BuildTools/PhpizeBuildToolFinderTest.php | 105 ++++++++++++++++++ 51 files changed, 315 insertions(+), 102 deletions(-) create mode 100755 test/assets/phpize/bad/phpize create mode 100755 test/assets/phpize/good/php create mode 100755 test/assets/phpize/good/phpize create mode 100644 test/unit/SelfManage/BuildTools/PhpizeBuildToolFinderTest.php diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 73debb0b..0072b0ba 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -12,12 +12,6 @@ parameters: count: 1 path: src/Command/CommandHelper.php - - - message: '#^Cannot cast mixed to string\.$#' - identifier: cast.string - count: 1 - path: src/Command/CommandHelper.php - - message: '#^Cannot cast mixed to string\.$#' identifier: cast.string @@ -480,6 +474,12 @@ parameters: count: 1 path: test/unit/Installing/InstallForPhpProject/InstallSelectedPackageTest.php + - + message: '#^Access to an undefined property Php\\PieUnitTest\\SelfManage\\BuildTools\\PhpizeBuildToolFinderTest\:\:\$phpBinaryPath\.$#' + identifier: property.notFound + count: 3 + path: test/unit/SelfManage/BuildTools/PhpizeBuildToolFinderTest.php + - message: '#^Method Php\\PieUnitTest\\SelfManage\\Verify\\FallbackVerificationUsingOpenSslTest\:\:prepareCertificateAndSignature\(\) should return array\{string, string\} but returns array\{mixed, mixed\}\.$#' identifier: return.type diff --git a/src/Building/Build.php b/src/Building/Build.php index f488b149..eb414ed6 100644 --- a/src/Building/Build.php +++ b/src/Building/Build.php @@ -7,7 +7,6 @@ use Composer\IO\IOInterface; use Php\Pie\Downloading\DownloadedPackage; use Php\Pie\File\BinaryFile; -use Php\Pie\Platform\TargetPhp\PhpizePath; use Php\Pie\Platform\TargetPlatform; /** @internal This is not public API for PIE, so should not be depended upon unless you accept the risk of BC breaks */ @@ -19,6 +18,5 @@ public function __invoke( TargetPlatform $targetPlatform, array $configureOptions, IOInterface $io, - PhpizePath|null $phpizePath, ): BinaryFile; } diff --git a/src/Building/UnixBuild.php b/src/Building/UnixBuild.php index 26699e98..e067a3de 100644 --- a/src/Building/UnixBuild.php +++ b/src/Building/UnixBuild.php @@ -34,7 +34,6 @@ public function __invoke( TargetPlatform $targetPlatform, array $configureOptions, IOInterface $io, - PhpizePath|null $phpizePath, ): BinaryFile { $selectedDownloadMethod = DownloadUrlMethod::fromDownloadedPackage($downloadedPackage); switch ($selectedDownloadMethod) { @@ -43,7 +42,7 @@ public function __invoke( case DownloadUrlMethod::ComposerDefaultDownload: case DownloadUrlMethod::PrePackagedSourceDownload: - return $this->buildFromSource($downloadedPackage, $targetPlatform, $configureOptions, $io, $phpizePath); + return $this->buildFromSource($downloadedPackage, $targetPlatform, $configureOptions, $io); default: throw new LogicException('Unsupported download method: ' . $selectedDownloadMethod->value); @@ -74,7 +73,6 @@ private function buildFromSource( TargetPlatform $targetPlatform, array $configureOptions, IOInterface $io, - PhpizePath|null $phpizePath, ): BinaryFile { $outputCallback = null; if ($io->isVerbose()) { @@ -88,7 +86,7 @@ private function buildFromSource( }; } - $phpizePath ??= PhpizePath::guessFrom($targetPlatform->phpBinaryPath); + $phpizePath = $targetPlatform->phpizePath ?? PhpizePath::guessFrom($targetPlatform->phpBinaryPath); /** * Call a cleanup first; most of the time, we expect to be changing a diff --git a/src/Building/WindowsBuild.php b/src/Building/WindowsBuild.php index c724accf..20d6ab66 100644 --- a/src/Building/WindowsBuild.php +++ b/src/Building/WindowsBuild.php @@ -7,7 +7,6 @@ use Composer\IO\IOInterface; use Php\Pie\Downloading\DownloadedPackage; use Php\Pie\File\BinaryFile; -use Php\Pie\Platform\TargetPhp\PhpizePath; use Php\Pie\Platform\TargetPlatform; use Php\Pie\Platform\WindowsExtensionAssetName; @@ -22,7 +21,6 @@ public function __invoke( TargetPlatform $targetPlatform, array $configureOptions, IOInterface $io, - PhpizePath|null $phpizePath, ): BinaryFile { $prebuiltDll = WindowsExtensionAssetName::determineDllName($targetPlatform, $downloadedPackage); diff --git a/src/Command/BuildCommand.php b/src/Command/BuildCommand.php index 8904188e..f37aa0b0 100644 --- a/src/Command/BuildCommand.php +++ b/src/Command/BuildCommand.php @@ -84,7 +84,6 @@ public function execute(InputInterface $input, OutputInterface $output): int $requestedNameAndVersion, PieOperation::Resolve, [], // Configure options are not needed for resolve only - null, false, // setting up INI not needed for build ), ); @@ -126,7 +125,6 @@ public function execute(InputInterface $input, OutputInterface $output): int $requestedNameAndVersion, PieOperation::Build, $configureOptionsValues, - CommandHelper::determinePhpizePathFromInputs($input), false, // setting up INI not needed for build ), ); diff --git a/src/Command/CommandHelper.php b/src/Command/CommandHelper.php index 54b834a9..62f08e7c 100644 --- a/src/Command/CommandHelper.php +++ b/src/Command/CommandHelper.php @@ -185,15 +185,6 @@ 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 (Platform::isWindows() && $input->hasOption(self::OPTION_WITH_PHPIZE_PATH)) { - /** @var mixed $withPhpizePath */ - $withPhpizePath = $input->getOption(self::OPTION_WITH_PHPIZE_PATH); - - if (is_string($withPhpizePath) && trim($withPhpizePath) !== '') { - throw new InvalidArgumentException('The --with-phpize-path=/path/to/phpize cannot be used on Windows.'); - } - } - if ($specifiedWithPhpConfig) { $phpBinaryPath = PhpBinaryPath::fromPhpConfigExecutable($withPhpConfig); } @@ -210,7 +201,19 @@ public static function determineTargetPlatformFromInputs(InputInterface $input, } } - $targetPlatform = TargetPlatform::fromPhpBinaryPath($phpBinaryPath, $makeParallelJobs); + $phpizePath = null; + if ($input->hasOption(self::OPTION_WITH_PHPIZE_PATH)) { + $phpizePathOption = $input->getOption(self::OPTION_WITH_PHPIZE_PATH); + if (is_string($phpizePathOption) && trim($phpizePathOption) !== '') { + if (Platform::isWindows()) { + throw new InvalidArgumentException('The --with-phpize-path=/path/to/phpize cannot be used on Windows.'); + } + + $phpizePath = new PhpizePath($phpizePathOption); + } + } + + $targetPlatform = TargetPlatform::fromPhpBinaryPath($phpBinaryPath, $makeParallelJobs, $phpizePath); if (PiePlatform::isRunningStaticPhp()) { $io->write(sprintf('You are running a PIE Static PHP %s build', PHP_VERSION)); @@ -264,18 +267,6 @@ public static function shouldCheckForBuildTools(InputInterface $input): bool || ! $input->getOption(self::OPTION_SUPPRESS_BUILD_TOOLS_CHECK); } - public static function determinePhpizePathFromInputs(InputInterface $input): PhpizePath|null - { - if ($input->hasOption(self::OPTION_WITH_PHPIZE_PATH)) { - $phpizePathOption = (string) $input->getOption(self::OPTION_WITH_PHPIZE_PATH); - if (trim($phpizePathOption) !== '') { - return new PhpizePath($phpizePathOption); - } - } - - return null; - } - public static function requestedNameAndVersionPair(InputInterface $input): RequestedPackageAndVersion { $requestedPackageString = $input->getArgument(self::ARG_REQUESTED_PACKAGE_AND_VERSION); diff --git a/src/Command/DownloadCommand.php b/src/Command/DownloadCommand.php index d43a153f..34ce6554 100644 --- a/src/Command/DownloadCommand.php +++ b/src/Command/DownloadCommand.php @@ -74,7 +74,6 @@ public function execute(InputInterface $input, OutputInterface $output): int $requestedNameAndVersion, PieOperation::Download, [], // Configure options are not needed for download only - null, false, // setting up INI not needed for download ), ); diff --git a/src/Command/InfoCommand.php b/src/Command/InfoCommand.php index 26f8bdcf..d096b49c 100644 --- a/src/Command/InfoCommand.php +++ b/src/Command/InfoCommand.php @@ -79,7 +79,6 @@ public function execute(InputInterface $input, OutputInterface $output): int $requestedNameAndVersion, PieOperation::Resolve, [], // Configure options are not needed for resolve only - null, false, // setting up INI not needed for info ), ); diff --git a/src/Command/InstallCommand.php b/src/Command/InstallCommand.php index 33e93d31..d7dbd16e 100644 --- a/src/Command/InstallCommand.php +++ b/src/Command/InstallCommand.php @@ -98,7 +98,6 @@ public function execute(InputInterface $input, OutputInterface $output): int $requestedNameAndVersion, PieOperation::Resolve, [], // Configure options are not needed for resolve only - null, false, // setting up INI not needed for resolve step ), ); @@ -140,7 +139,6 @@ public function execute(InputInterface $input, OutputInterface $output): int $requestedNameAndVersion, PieOperation::Install, $configureOptionsValues, - CommandHelper::determinePhpizePathFromInputs($input), CommandHelper::determineAttemptToSetupIniFile($input), ), ); diff --git a/src/Command/UninstallCommand.php b/src/Command/UninstallCommand.php index eda8e419..c06980a0 100644 --- a/src/Command/UninstallCommand.php +++ b/src/Command/UninstallCommand.php @@ -91,7 +91,6 @@ public function execute(InputInterface $input, OutputInterface $output): int $requestedPackageAndVersionToRemove, PieOperation::Uninstall, [], // Configure options are not needed for uninstall - null, true, ), ); diff --git a/src/ComposerIntegration/InstallAndBuildProcess.php b/src/ComposerIntegration/InstallAndBuildProcess.php index d64a4d79..2d11ab84 100644 --- a/src/ComposerIntegration/InstallAndBuildProcess.php +++ b/src/ComposerIntegration/InstallAndBuildProcess.php @@ -55,7 +55,6 @@ public function __invoke( $composerRequest->targetPlatform, $composerRequest->configureOptions, $io, - $composerRequest->phpizePath, ); $this->installedJsonMetadata->addBuildMetadata( diff --git a/src/ComposerIntegration/InstalledJsonMetadata.php b/src/ComposerIntegration/InstalledJsonMetadata.php index ee781d3b..77a35fb5 100644 --- a/src/ComposerIntegration/InstalledJsonMetadata.php +++ b/src/ComposerIntegration/InstalledJsonMetadata.php @@ -76,7 +76,7 @@ public function addBuildMetadata( $composer, $composerPackage, MetadataKey::PhpizeBinary, - $composerRequest->phpizePath->phpizeBinaryPath ?? null, + $composerRequest->targetPlatform->phpizePath->phpizeBinaryPath ?? null, ); $this->addPieMetadata( diff --git a/src/ComposerIntegration/PieComposerRequest.php b/src/ComposerIntegration/PieComposerRequest.php index 20de4ac2..3b96902d 100644 --- a/src/ComposerIntegration/PieComposerRequest.php +++ b/src/ComposerIntegration/PieComposerRequest.php @@ -6,7 +6,6 @@ use Composer\IO\IOInterface; use Php\Pie\DependencyResolver\RequestedPackageAndVersion; -use Php\Pie\Platform\TargetPhp\PhpizePath; use Php\Pie\Platform\TargetPlatform; /** @@ -23,7 +22,6 @@ public function __construct( public readonly RequestedPackageAndVersion $requestedPackage, public readonly PieOperation $operation, public readonly array $configureOptions, - public readonly PhpizePath|null $phpizePath, public readonly bool $attemptToSetupIniFile, ) { } @@ -42,7 +40,6 @@ public static function noOperation( new RequestedPackageAndVersion('null/null', null), PieOperation::Resolve, [], - null, false, ); } diff --git a/src/Platform/TargetPlatform.php b/src/Platform/TargetPlatform.php index 9a50542c..5d351aae 100644 --- a/src/Platform/TargetPlatform.php +++ b/src/Platform/TargetPlatform.php @@ -6,6 +6,7 @@ use Fidry\CpuCoreCounter\CpuCoreCounter; use Php\Pie\Platform\TargetPhp\PhpBinaryPath; +use Php\Pie\Platform\TargetPhp\PhpizePath; use function array_key_exists; use function explode; @@ -31,6 +32,7 @@ public function __construct( public readonly ThreadSafetyMode $threadSafety, public readonly int $makeParallelJobs, public readonly WindowsCompiler|null $windowsCompiler, + public readonly PhpizePath|null $phpizePath, ) { } @@ -48,7 +50,7 @@ public static function isRunningAsRoot(): bool return function_exists('posix_getuid') && posix_getuid() === 0; } - public static function fromPhpBinaryPath(PhpBinaryPath $phpBinaryPath, int|null $makeParallelJobs): self + public static function fromPhpBinaryPath(PhpBinaryPath $phpBinaryPath, int|null $makeParallelJobs, PhpizePath|null $phpizePath): self { $os = $phpBinaryPath->operatingSystem(); $osFamily = $phpBinaryPath->operatingSystemFamily(); @@ -133,6 +135,7 @@ public static function fromPhpBinaryPath(PhpBinaryPath $phpBinaryPath, int|null $threadSafety, $makeParallelJobs, $windowsCompiler, + $phpizePath, ); } } diff --git a/src/SelfManage/BuildTools/BinaryBuildToolFinder.php b/src/SelfManage/BuildTools/BinaryBuildToolFinder.php index 700aa7b7..786af850 100644 --- a/src/SelfManage/BuildTools/BinaryBuildToolFinder.php +++ b/src/SelfManage/BuildTools/BinaryBuildToolFinder.php @@ -30,7 +30,7 @@ public function toolNames(): string return is_array($this->tool) ? implode('/', $this->tool) : $this->tool; } - public function check(): bool + public function check(TargetPlatform $targetPlatform): bool { $tools = is_array($this->tool) ? $this->tool : [$this->tool]; diff --git a/src/SelfManage/BuildTools/CheckAllBuildTools.php b/src/SelfManage/BuildTools/CheckAllBuildTools.php index 9dd82366..c8bd73bd 100644 --- a/src/SelfManage/BuildTools/CheckAllBuildTools.php +++ b/src/SelfManage/BuildTools/CheckAllBuildTools.php @@ -90,7 +90,6 @@ public static function buildToolsFactory(): self ], ), new PhpizeBuildToolFinder( - 'phpize', [ PackageManager::Apt->value => 'php-dev', PackageManager::Apk->value => 'php{major}{minor}-dev', @@ -117,7 +116,7 @@ public function check(IOInterface $io, PackageManager|null $packageManager, Targ $allFound = true; foreach ($this->buildTools as $buildTool) { - if ($buildTool->check() !== false) { + if ($buildTool->check($targetPlatform) !== false) { $io->write('Build tool ' . $buildTool->toolNames() . ' is installed.', verbosity: IOInterface::VERY_VERBOSE); continue; } diff --git a/src/SelfManage/BuildTools/PhpizeBuildToolFinder.php b/src/SelfManage/BuildTools/PhpizeBuildToolFinder.php index 8c4e72ac..aae61d68 100644 --- a/src/SelfManage/BuildTools/PhpizeBuildToolFinder.php +++ b/src/SelfManage/BuildTools/PhpizeBuildToolFinder.php @@ -5,18 +5,43 @@ namespace Php\Pie\SelfManage\BuildTools; use Php\Pie\Platform\TargetPhp\PhpizePath; +use Php\Pie\Platform\TargetPlatform; +use RuntimeException; use Symfony\Component\Process\ExecutableFinder; +use function file_exists; use function is_array; +use function is_executable; /** @internal This is not public API for PIE, so should not be depended upon unless you accept the risk of BC breaks */ class PhpizeBuildToolFinder extends BinaryBuildToolFinder { - public function check(): bool + /** @param array $packageManagerPackages */ + public function __construct( + array $packageManagerPackages, + ) { + parent::__construct('phpize', $packageManagerPackages); + } + + public function check(TargetPlatform $targetPlatform): bool { $tools = is_array($this->tool) ? $this->tool : [$this->tool]; + if ($targetPlatform->phpizePath !== null) { + $tools[] = $targetPlatform->phpizePath->phpizeBinaryPath; + } + + try { + $tools[] = PhpizePath::guessFrom($targetPlatform->phpBinaryPath)->phpizeBinaryPath; + } catch (RuntimeException) { + // intentionally ignored - just don't try to use the guessed phpize path + } + foreach ($tools as $tool) { + if (file_exists($tool) && is_executable($tool) && PhpizePath::looksLikeValidPhpize($tool)) { + return true; + } + $foundTool = (new ExecutableFinder())->find($tool); if ($foundTool !== null && PhpizePath::looksLikeValidPhpize($foundTool)) { diff --git a/test/assets/phpize/bad/phpize b/test/assets/phpize/bad/phpize new file mode 100755 index 00000000..14a0ee3a --- /dev/null +++ b/test/assets/phpize/bad/phpize @@ -0,0 +1,3 @@ +#!/usr/bin/bash + +echo "Haha! I am not really phpize." diff --git a/test/assets/phpize/good/php b/test/assets/phpize/good/php new file mode 100755 index 00000000..b672700b --- /dev/null +++ b/test/assets/phpize/good/php @@ -0,0 +1,5 @@ +#!/usr/bin/bash + +echo "PHP" + +exit 0 diff --git a/test/assets/phpize/good/phpize b/test/assets/phpize/good/phpize new file mode 100755 index 00000000..329eda92 --- /dev/null +++ b/test/assets/phpize/good/phpize @@ -0,0 +1,9 @@ +#!/usr/bin/bash + +echo "Configuring for:" +echo "PHP Version: 8.4" +echo "PHP Api Version: 20240924" +echo "Zend Module Api No: 20240924" +echo "Zend Extension Api No: 420240924" + +exit 0 diff --git a/test/install-bundled-php-exts.php b/test/install-bundled-php-exts.php index b1bf2a81..7fbe20c7 100644 --- a/test/install-bundled-php-exts.php +++ b/test/install-bundled-php-exts.php @@ -28,6 +28,7 @@ TargetPlatform::fromPhpBinaryPath( $phpBinaryPath, null, + null, ), ) ->getPackages(), diff --git a/test/integration/Building/UnixBuildTest.php b/test/integration/Building/UnixBuildTest.php index bcf221e0..5ef05fad 100644 --- a/test/integration/Building/UnixBuildTest.php +++ b/test/integration/Building/UnixBuildTest.php @@ -59,10 +59,9 @@ public function testUnixSourceBuildCanBuildExtension(): void $unixBuilder = new UnixBuild(); $builtBinary = $unixBuilder->__invoke( $downloadedPackage, - TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null), + TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null, null), ['--enable-pie_test_ext'], $output, - null, ); self::assertNotEmpty($builtBinary); @@ -116,10 +115,9 @@ public function testUnixSourceBuildWillThrowExceptionWhenExpectedBinaryNameMisma try { $unixBuilder->__invoke( $downloadedPackage, - TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null), + TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null, null), ['--enable-pie_test_ext'], $output, - null, ); } finally { (new Process(['make', 'clean'], $downloadedPackage->extractedSourcePath))->mustRun(); @@ -152,10 +150,9 @@ public function testUnixSourceBuildCanBuildExtensionWithBuildPath(): void $unixBuilder = new UnixBuild(); $builtBinary = $unixBuilder->__invoke( $downloadedPackage, - TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null), + TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null, null), ['--enable-pie_test_ext'], $output, - null, ); self::assertNotEmpty($builtBinary); @@ -199,7 +196,7 @@ public function testUnixBinaryBuildThrowsErrorWhenBinaryFileNotFound(): void self::TEST_PREBUILT_PATH_INVALID, ); - $targetPlatform = TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null); + $targetPlatform = TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null, null); $unixBuilder = new UnixBuild(); $this->expectException(ExtensionBinaryNotFound::class); @@ -209,7 +206,6 @@ public function testUnixBinaryBuildThrowsErrorWhenBinaryFileNotFound(): void $targetPlatform, ['--enable-pie_test_ext'], $output, - null, ); } @@ -234,7 +230,7 @@ public function testUnixBinaryBuildReturnsBinaryFile(): void self::TEST_PREBUILT_PATH_VALID, ); - $targetPlatform = TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null); + $targetPlatform = TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null, null); $unixBuilder = new UnixBuild(); $binaryFile = $unixBuilder->__invoke( @@ -242,7 +238,6 @@ public function testUnixBinaryBuildReturnsBinaryFile(): void $targetPlatform, ['--enable-pie_test_ext'], $output, - null, ); self::assertSame('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', $binaryFile->checksum); @@ -280,10 +275,9 @@ public function testCleanupDoesNotCleanWhenConfigureIsMissing(): void $unixBuilder = new UnixBuild(); $unixBuilder->__invoke( $downloadedPackage, - TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null), + TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null, null), ['--enable-pie_test_ext'], $output, - null, ); $outputString = $output->getOutput(); @@ -322,10 +316,9 @@ public function testVerboseOutputShowsCleanupMessages(): void $unixBuilder = new UnixBuild(); $unixBuilder->__invoke( $downloadedPackage, - TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null), + TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null, null), ['--enable-pie_test_ext'], $output, - null, ); $outputString = $output->getOutput(); diff --git a/test/integration/Command/ShowCommandTest.php b/test/integration/Command/ShowCommandTest.php index c1a4948f..c097b402 100644 --- a/test/integration/Command/ShowCommandTest.php +++ b/test/integration/Command/ShowCommandTest.php @@ -82,6 +82,7 @@ public function testExecuteWithAvailableConstrainedUpdates(): void $phpConfig, ), 1, + null, ), ) ->addRequire(self::TEST_PACKAGE, '^2.0'); @@ -129,6 +130,7 @@ public function testExecuteWithAvailableUnconstrainedUpdates(): void $phpConfig, ), 1, + null, ), ) ->addRequire(self::TEST_PACKAGE, '^2.0,<=2.0.3'); @@ -176,6 +178,7 @@ public function testExecuteWithOnlyUnconstrainedUpdates(): void $phpConfig, ), 1, + null, ), ) ->addRequire(self::TEST_PACKAGE, '^2.0,<2.0.3'); diff --git a/test/integration/DependencyResolver/ResolveDependencyWithComposerTest.php b/test/integration/DependencyResolver/ResolveDependencyWithComposerTest.php index 06257ba8..750e7109 100644 --- a/test/integration/DependencyResolver/ResolveDependencyWithComposerTest.php +++ b/test/integration/DependencyResolver/ResolveDependencyWithComposerTest.php @@ -71,7 +71,7 @@ public function testDependenciesAreResolvedToExpectedVersions( $container = Container::factory(); $resolve = $container->get(DependencyResolver::class); - $targetPlatform = TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null); + $targetPlatform = TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null, null); $requestedPackageAndVersion = new RequestedPackageAndVersion( 'asgrim/example-pie-extension', $requestedVersion, @@ -86,7 +86,6 @@ public function testDependenciesAreResolvedToExpectedVersions( $requestedPackageAndVersion, PieOperation::Resolve, [], - null, false, ), ), diff --git a/test/integration/Downloading/GithubPackageReleaseAssetsTest.php b/test/integration/Downloading/GithubPackageReleaseAssetsTest.php index f26b0ef7..2d04ec80 100644 --- a/test/integration/Downloading/GithubPackageReleaseAssetsTest.php +++ b/test/integration/Downloading/GithubPackageReleaseAssetsTest.php @@ -44,6 +44,7 @@ public function testDeterminingReleaseAssetUrlForWindows(): void ThreadSafetyMode::ThreadSafe, 1, WindowsCompiler::VS16, + null, ); $package = new Package( diff --git a/test/integration/Installing/UnixInstallTest.php b/test/integration/Installing/UnixInstallTest.php index f80e21d8..0e3e8d08 100644 --- a/test/integration/Installing/UnixInstallTest.php +++ b/test/integration/Installing/UnixInstallTest.php @@ -85,7 +85,7 @@ public function testUnixInstallCanInstallExtensionBuiltFromSource(string $phpCon } $output = new BufferIO(); - $targetPlatform = TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromPhpConfigExecutable($phpConfig), null); + $targetPlatform = TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromPhpConfigExecutable($phpConfig), null, null); $extensionPath = $targetPlatform->phpBinaryPath->extensionPath(); $composerPackage = $this->createMock(CompletePackageInterface::class); @@ -110,7 +110,6 @@ public function testUnixInstallCanInstallExtensionBuiltFromSource(string $phpCon $targetPlatform, ['--enable-pie_test_ext'], $output, - null, ); $installedSharedObject = (new UnixInstall(new SetupIniFile(new PickBestSetupIniApproach([]))))->__invoke( @@ -147,7 +146,7 @@ public function testUnixInstallCanInstallPrePackagedBinary(string $phpConfig): v } $output = new BufferIO(); - $targetPlatform = TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromPhpConfigExecutable($phpConfig), null); + $targetPlatform = TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromPhpConfigExecutable($phpConfig), null, null); $extensionPath = $targetPlatform->phpBinaryPath->extensionPath(); // First build it (otherwise the test assets would need to have a binary for every test platform...) @@ -171,7 +170,6 @@ public function testUnixInstallCanInstallPrePackagedBinary(string $phpConfig): v $targetPlatform, ['--enable-pie_test_ext'], $output, - null, ); /** diff --git a/test/integration/Installing/WindowsInstallTest.php b/test/integration/Installing/WindowsInstallTest.php index a4142da6..56384135 100644 --- a/test/integration/Installing/WindowsInstallTest.php +++ b/test/integration/Installing/WindowsInstallTest.php @@ -65,6 +65,7 @@ public function testWindowsInstallCanInstallExtension(): void ThreadSafetyMode::ThreadSafe, 1, WindowsCompiler::VS16, + null, ); $phpPath = dirname($targetPlatform->phpBinaryPath->phpBinaryPath); $extensionPath = $targetPlatform->phpBinaryPath->extensionPath(); diff --git a/test/unit/ComposerIntegration/BundledPhpExtensionsRepositoryTest.php b/test/unit/ComposerIntegration/BundledPhpExtensionsRepositoryTest.php index d85678fb..5117d4ff 100644 --- a/test/unit/ComposerIntegration/BundledPhpExtensionsRepositoryTest.php +++ b/test/unit/ComposerIntegration/BundledPhpExtensionsRepositoryTest.php @@ -101,6 +101,7 @@ public function testBundledRepository(string $packageName): void ThreadSafetyMode::NonThreadSafe, 1, null, + null, ), ); diff --git a/test/unit/ComposerIntegration/InstallAndBuildProcessTest.php b/test/unit/ComposerIntegration/InstallAndBuildProcessTest.php index 84d4f88e..ec5c1b6c 100644 --- a/test/unit/ComposerIntegration/InstallAndBuildProcessTest.php +++ b/test/unit/ComposerIntegration/InstallAndBuildProcessTest.php @@ -62,11 +62,11 @@ public function testDownloadWithoutBuildAndInstall(): void ThreadSafetyMode::NonThreadSafe, 1, null, + null, ), new RequestedPackageAndVersion('foo/bar', '^1.0'), PieOperation::Download, ['--foo', '--bar="yes"'], - null, false, ); $composerPackage = new CompletePackage('foo/bar', '1.2.3.0', '1.2.3'); @@ -103,11 +103,11 @@ public function testDownloadAndBuildWithoutInstall(): void ThreadSafetyMode::NonThreadSafe, 1, null, + null, ), new RequestedPackageAndVersion('foo/bar', '^1.0'), PieOperation::Build, ['--foo', '--bar="yes"'], - null, false, ); $composerPackage = new CompletePackage('foo/bar', '1.2.3.0', '1.2.3'); @@ -147,11 +147,11 @@ public function testDownloadBuildAndInstall(): void ThreadSafetyMode::NonThreadSafe, 1, null, + null, ), new RequestedPackageAndVersion('foo/bar', '^1.0'), PieOperation::Install, ['--foo', '--bar="yes"'], - null, false, ); $composerPackage = new CompletePackage('foo/bar', '1.2.3.0', '1.2.3'); diff --git a/test/unit/ComposerIntegration/InstalledJsonMetadataTest.php b/test/unit/ComposerIntegration/InstalledJsonMetadataTest.php index c1dc4cd5..20234dff 100644 --- a/test/unit/ComposerIntegration/InstalledJsonMetadataTest.php +++ b/test/unit/ComposerIntegration/InstalledJsonMetadataTest.php @@ -60,11 +60,11 @@ public function testMetadataForDownloads(): void ThreadSafetyMode::NonThreadSafe, 1, null, + null, ), new RequestedPackageAndVersion('foo/bar', '^1.0'), PieOperation::Build, ['--foo', '--bar="yes"'], - null, false, ), clone $package, @@ -99,11 +99,11 @@ public function testMetadataForBuilds(): void ThreadSafetyMode::NonThreadSafe, 1, null, + new PhpizePath('/path/to/phpize'), ), new RequestedPackageAndVersion('foo/bar', '^1.0'), PieOperation::Build, ['--foo', '--bar="yes"'], - new PhpizePath('/path/to/phpize'), false, ), clone $package, diff --git a/test/unit/ComposerIntegration/Listeners/OverrideDownloadUrlInstallListenerTest.php b/test/unit/ComposerIntegration/Listeners/OverrideDownloadUrlInstallListenerTest.php index 657a2aab..7e34339d 100644 --- a/test/unit/ComposerIntegration/Listeners/OverrideDownloadUrlInstallListenerTest.php +++ b/test/unit/ComposerIntegration/Listeners/OverrideDownloadUrlInstallListenerTest.php @@ -78,11 +78,11 @@ public function testEventListenerRegistration(): void ThreadSafetyMode::NonThreadSafe, 1, WindowsCompiler::VC15, + null, ), new RequestedPackageAndVersion('foo/bar', '^1.1'), PieOperation::Install, [], - null, false, ), ); @@ -120,11 +120,11 @@ public function testNonInstallOperationsAreIgnored(): void ThreadSafetyMode::NonThreadSafe, 1, WindowsCompiler::VC15, + null, ), new RequestedPackageAndVersion('foo/bar', '^1.1'), PieOperation::Install, [], - null, false, ), ))($installerEvent); @@ -162,11 +162,11 @@ public function testNonCompletePackagesAreIgnored(): void ThreadSafetyMode::NonThreadSafe, 1, WindowsCompiler::VC15, + null, ), new RequestedPackageAndVersion('foo/bar', '^1.1'), PieOperation::Install, [], - null, false, ), ))($installerEvent); @@ -204,11 +204,11 @@ public function testInstallOperationsForDifferentPackagesAreIgnored(): void ThreadSafetyMode::NonThreadSafe, 1, WindowsCompiler::VC15, + null, ), new RequestedPackageAndVersion('foo/bar', '^1.1'), PieOperation::Install, [], - null, false, ), ))($installerEvent); @@ -246,11 +246,11 @@ public function testWindowsUrlInstallerDoesNotRunOnNonWindows(): void ThreadSafetyMode::NonThreadSafe, 1, WindowsCompiler::VC15, + null, ), new RequestedPackageAndVersion('foo/bar', '^1.1'), PieOperation::Install, [], - null, false, ), ))($installerEvent); @@ -301,11 +301,11 @@ public function testDistUrlIsUpdatedForWindowsInstallers(): void ThreadSafetyMode::NonThreadSafe, 1, WindowsCompiler::VC15, + null, ), new RequestedPackageAndVersion('foo/bar', '^1.1'), PieOperation::Install, [], - null, false, ), ))($installerEvent); @@ -361,11 +361,11 @@ public function testDistUrlIsUpdatedForPrePackagedTgzSource(): void ThreadSafetyMode::NonThreadSafe, 1, WindowsCompiler::VC15, + null, ), new RequestedPackageAndVersion('foo/bar', '^1.1'), PieOperation::Install, [], - null, false, ), ))($installerEvent); @@ -422,11 +422,11 @@ public function testDistUrlIsUpdatedForPrePackagedTgzBinaryWhenBinaryIsFound(): ThreadSafetyMode::NonThreadSafe, 1, WindowsCompiler::VC15, + null, ), new RequestedPackageAndVersion('foo/bar', '^1.1'), PieOperation::Install, [], - null, false, ), ))($installerEvent); @@ -483,11 +483,11 @@ public function testDistUrlIsUpdatedForPrePackagedTgzBinaryWhenBinaryIsNotFound( ThreadSafetyMode::NonThreadSafe, 1, WindowsCompiler::VC15, + null, ), new RequestedPackageAndVersion('foo/bar', '^1.1'), PieOperation::Install, [], - null, false, ), ))($installerEvent); @@ -544,11 +544,11 @@ public function testNoSelectedDownloadUrlMethodWillThrowException(): void ThreadSafetyMode::NonThreadSafe, 1, WindowsCompiler::VC15, + null, ), new RequestedPackageAndVersion('foo/bar', '^1.1'), PieOperation::Install, [], - null, false, ), ); diff --git a/test/unit/ComposerIntegration/Listeners/RemoveUnrelatedInstallOperationsTest.php b/test/unit/ComposerIntegration/Listeners/RemoveUnrelatedInstallOperationsTest.php index 865bae1e..e6c1d733 100644 --- a/test/unit/ComposerIntegration/Listeners/RemoveUnrelatedInstallOperationsTest.php +++ b/test/unit/ComposerIntegration/Listeners/RemoveUnrelatedInstallOperationsTest.php @@ -71,11 +71,11 @@ public function testEventListenerRegistration(): void ThreadSafetyMode::NonThreadSafe, 1, WindowsCompiler::VC15, + null, ), new RequestedPackageAndVersion('foo/bar', '^1.1'), PieOperation::Install, [], - null, false, ), ); @@ -107,11 +107,11 @@ public function testUnrelatedInstallOperationsAreRemoved(): void ThreadSafetyMode::NonThreadSafe, 1, WindowsCompiler::VC15, + null, ), new RequestedPackageAndVersion('bat/baz', '^3.2'), PieOperation::Install, [], - null, false, ), ))($installerEvent); diff --git a/test/unit/ComposerIntegration/VersionSelectorFactoryTest.php b/test/unit/ComposerIntegration/VersionSelectorFactoryTest.php index 4069e6c1..60d7925c 100644 --- a/test/unit/ComposerIntegration/VersionSelectorFactoryTest.php +++ b/test/unit/ComposerIntegration/VersionSelectorFactoryTest.php @@ -66,6 +66,7 @@ public function testVersionSelectorFactory(): void ThreadSafetyMode::NonThreadSafe, 1, null, + null, ), ); diff --git a/test/unit/DependencyResolver/ResolveDependencyWithComposerTest.php b/test/unit/DependencyResolver/ResolveDependencyWithComposerTest.php index 03e4ee47..33ab2c9a 100644 --- a/test/unit/DependencyResolver/ResolveDependencyWithComposerTest.php +++ b/test/unit/DependencyResolver/ResolveDependencyWithComposerTest.php @@ -78,6 +78,7 @@ public function testPackageThatCanBeResolved(): void ThreadSafetyMode::ThreadSafe, 1, null, + null, ); $package = (new ResolveDependencyWithComposer( @@ -120,6 +121,7 @@ public function testPackageThatCannotBeResolvedThrowsException(array $platformOv ThreadSafetyMode::ThreadSafe, 1, null, + null, ); $this->expectException(UnableToResolveRequirement::class); @@ -159,6 +161,7 @@ public function testUnresolvedPackageCanBeInstalledWithForceOption(array $platfo ThreadSafetyMode::ThreadSafe, 1, null, + null, ); $this->expectException(UnableToResolveRequirement::class); @@ -211,6 +214,7 @@ public function testZtsOnlyPackageCannotBeInstalledOnNtsSystem(): void ThreadSafetyMode::NonThreadSafe, 1, null, + null, ); $this->expectException(IncompatibleThreadSafetyMode::class); @@ -260,6 +264,7 @@ public function testNtsOnlyPackageCannotBeInstalledOnZtsSystem(): void ThreadSafetyMode::ThreadSafe, 1, null, + null, ); $this->expectException(IncompatibleThreadSafetyMode::class); @@ -309,6 +314,7 @@ public function testExtensionCanOnlyBeInstalledIfOsFamilyIsCompatible(): void ThreadSafetyMode::ThreadSafe, 1, null, + null, ); $this->expectException(IncompatibleOperatingSystemFamily::class); @@ -358,6 +364,7 @@ public function testExtensionCanOnlyBeInstalledIfOsFamilyIsNotInCompatible(): vo ThreadSafetyMode::ThreadSafe, 1, null, + null, ); $this->expectException(IncompatibleOperatingSystemFamily::class); @@ -397,6 +404,7 @@ public function testPackageThatCanBeResolvedWithReplaceConflict(): void ThreadSafetyMode::ThreadSafe, 1, null, + null, ); $package = (new ResolveDependencyWithComposer( diff --git a/test/unit/Downloading/DownloadUrlMethodTest.php b/test/unit/Downloading/DownloadUrlMethodTest.php index b1113b9d..442f4be1 100644 --- a/test/unit/Downloading/DownloadUrlMethodTest.php +++ b/test/unit/Downloading/DownloadUrlMethodTest.php @@ -52,6 +52,7 @@ public function testWindowsPackages(): void ThreadSafetyMode::NonThreadSafe, 1, WindowsCompiler::VC15, + null, ); $downloadUrlMethods = DownloadUrlMethod::possibleDownloadUrlMethodsForPackage($package, $targetPlatform); @@ -88,6 +89,7 @@ public function testPrePackagedSourceDownloads(): void ThreadSafetyMode::NonThreadSafe, 1, null, + null, ); $downloadUrlMethods = DownloadUrlMethod::possibleDownloadUrlMethodsForPackage($package, $targetPlatform); @@ -133,6 +135,7 @@ public function testPrePackagedBinaryDownloads(): void ThreadSafetyMode::ThreadSafe, 1, null, + null, ); $downloadUrlMethods = DownloadUrlMethod::possibleDownloadUrlMethodsForPackage($package, $targetPlatform); @@ -170,6 +173,7 @@ public function testComposerDefaultDownload(): void ThreadSafetyMode::NonThreadSafe, 1, null, + null, ); $downloadUrlMethods = DownloadUrlMethod::possibleDownloadUrlMethodsForPackage($package, $targetPlatform); @@ -208,6 +212,7 @@ public function testMultipleDownloadUrlMethods(): void ThreadSafetyMode::NonThreadSafe, 1, null, + null, ); $downloadUrlMethods = DownloadUrlMethod::possibleDownloadUrlMethodsForPackage($package, $targetPlatform); diff --git a/test/unit/Downloading/Exception/CouldNotFindReleaseAssetTest.php b/test/unit/Downloading/Exception/CouldNotFindReleaseAssetTest.php index 32bd161c..6989ce91 100644 --- a/test/unit/Downloading/Exception/CouldNotFindReleaseAssetTest.php +++ b/test/unit/Downloading/Exception/CouldNotFindReleaseAssetTest.php @@ -43,6 +43,7 @@ public function testForPackageWithRegularPackage(): void ThreadSafetyMode::NonThreadSafe, 1, null, + null, ), $package, DownloadUrlMethod::PrePackagedSourceDownload, @@ -72,6 +73,7 @@ public function testForPackageWithWindowsPackage(): void ThreadSafetyMode::NonThreadSafe, 1, WindowsCompiler::VS17, + null, ), $package, DownloadUrlMethod::WindowsBinaryDownload, @@ -108,6 +110,7 @@ public function testForMissingWindowsCompiler(): void ThreadSafetyMode::NonThreadSafe, 1, null, + null, )); self::assertSame('Could not determine Windows Compiler for PHP ' . $phpBinary->version() . ' on NonWindows', $exception->getMessage()); diff --git a/test/unit/Downloading/GithubPackageReleaseAssetsTest.php b/test/unit/Downloading/GithubPackageReleaseAssetsTest.php index 4002a366..e36347b5 100644 --- a/test/unit/Downloading/GithubPackageReleaseAssetsTest.php +++ b/test/unit/Downloading/GithubPackageReleaseAssetsTest.php @@ -45,6 +45,7 @@ public function testUrlIsReturnedWhenFindingWindowsDownloadUrl(): void ThreadSafetyMode::ThreadSafe, 1, WindowsCompiler::VC14, + null, ); $httpDownloaderResponse = $this->createMock(Response::class); @@ -111,6 +112,7 @@ public function testUrlIsReturnedWhenFindingWindowsDownloadUrlWithCompilerAndThr ThreadSafetyMode::ThreadSafe, 1, WindowsCompiler::VC14, + null, ); $httpDownloaderResponse = $this->createMock(Response::class); @@ -172,6 +174,7 @@ public function testFindWindowsDownloadUrlForPackageThrowsExceptionWhenAssetNotF ThreadSafetyMode::ThreadSafe, 1, WindowsCompiler::VC14, + null, ); $e = new TransportException('not found', 404); diff --git a/test/unit/Installing/Ini/CheckAndAddExtensionToIniIfNeededTest.php b/test/unit/Installing/Ini/CheckAndAddExtensionToIniIfNeededTest.php index 624fccdf..147fedf7 100644 --- a/test/unit/Installing/Ini/CheckAndAddExtensionToIniIfNeededTest.php +++ b/test/unit/Installing/Ini/CheckAndAddExtensionToIniIfNeededTest.php @@ -59,6 +59,7 @@ public function setUp(): void ThreadSafetyMode::ThreadSafe, 1, null, + null, ); $this->downloadedPackage = DownloadedPackage::fromPackageAndExtractedPath( diff --git a/test/unit/Installing/Ini/DockerPhpExtEnableTest.php b/test/unit/Installing/Ini/DockerPhpExtEnableTest.php index af43fb27..e2f47b88 100644 --- a/test/unit/Installing/Ini/DockerPhpExtEnableTest.php +++ b/test/unit/Installing/Ini/DockerPhpExtEnableTest.php @@ -57,6 +57,7 @@ public function setUp(): void ThreadSafetyMode::ThreadSafe, 1, null, + null, ); $this->downloadedPackage = DownloadedPackage::fromPackageAndExtractedPath( diff --git a/test/unit/Installing/Ini/OndrejPhpenmodTest.php b/test/unit/Installing/Ini/OndrejPhpenmodTest.php index c8b18fbb..39c311d9 100644 --- a/test/unit/Installing/Ini/OndrejPhpenmodTest.php +++ b/test/unit/Installing/Ini/OndrejPhpenmodTest.php @@ -70,6 +70,7 @@ public function setUp(): void ThreadSafetyMode::ThreadSafe, 1, null, + null, ); $this->downloadedPackage = DownloadedPackage::fromPackageAndExtractedPath( diff --git a/test/unit/Installing/Ini/PickBestSetupIniApproachTest.php b/test/unit/Installing/Ini/PickBestSetupIniApproachTest.php index 151c5cdf..5af76ab4 100644 --- a/test/unit/Installing/Ini/PickBestSetupIniApproachTest.php +++ b/test/unit/Installing/Ini/PickBestSetupIniApproachTest.php @@ -36,6 +36,7 @@ private function targetPlatform(): TargetPlatform ThreadSafetyMode::ThreadSafe, 1, null, + null, ); } diff --git a/test/unit/Installing/Ini/PreCheckExtensionAlreadyLoadedTest.php b/test/unit/Installing/Ini/PreCheckExtensionAlreadyLoadedTest.php index e04ad661..66cffde5 100644 --- a/test/unit/Installing/Ini/PreCheckExtensionAlreadyLoadedTest.php +++ b/test/unit/Installing/Ini/PreCheckExtensionAlreadyLoadedTest.php @@ -52,6 +52,7 @@ public function setUp(): void ThreadSafetyMode::ThreadSafe, 1, null, + null, ); $this->downloadedPackage = DownloadedPackage::fromPackageAndExtractedPath( diff --git a/test/unit/Installing/Ini/RemoveIniEntryWithFileGetContentsTest.php b/test/unit/Installing/Ini/RemoveIniEntryWithFileGetContentsTest.php index e4f20a95..ef571853 100644 --- a/test/unit/Installing/Ini/RemoveIniEntryWithFileGetContentsTest.php +++ b/test/unit/Installing/Ini/RemoveIniEntryWithFileGetContentsTest.php @@ -104,6 +104,7 @@ public function testRelevantIniFilesHaveExtensionRemoved(ExtensionType $extensio ThreadSafetyMode::ThreadSafe, 1, null, + null, ); $affectedFiles = (new RemoveIniEntryWithFileGetContents())( @@ -156,6 +157,7 @@ public function testNonExistentAdditionalIniDirectoryDoesNotCrash(ExtensionType ThreadSafetyMode::ThreadSafe, 1, null, + null, ); self::assertSame( @@ -202,6 +204,7 @@ public function testSymlinkedIniFilesAreResolved(): void ThreadSafetyMode::ThreadSafe, 1, null, + null, ); $affectedFiles = (new RemoveIniEntryWithFileGetContents())( diff --git a/test/unit/Installing/Ini/StandardAdditionalPhpIniDirectoryTest.php b/test/unit/Installing/Ini/StandardAdditionalPhpIniDirectoryTest.php index 9c7681eb..f6113cae 100644 --- a/test/unit/Installing/Ini/StandardAdditionalPhpIniDirectoryTest.php +++ b/test/unit/Installing/Ini/StandardAdditionalPhpIniDirectoryTest.php @@ -64,6 +64,7 @@ public function setUp(): void ThreadSafetyMode::ThreadSafe, 1, null, + null, ); $this->downloadedPackage = DownloadedPackage::fromPackageAndExtractedPath( diff --git a/test/unit/Installing/Ini/StandardSinglePhpIniTest.php b/test/unit/Installing/Ini/StandardSinglePhpIniTest.php index d93f0f22..73a5b6e9 100644 --- a/test/unit/Installing/Ini/StandardSinglePhpIniTest.php +++ b/test/unit/Installing/Ini/StandardSinglePhpIniTest.php @@ -57,6 +57,7 @@ public function setUp(): void ThreadSafetyMode::ThreadSafe, 1, null, + null, ); $this->downloadedPackage = DownloadedPackage::fromPackageAndExtractedPath( diff --git a/test/unit/Platform/PrePackagedBinaryAssetNameTest.php b/test/unit/Platform/PrePackagedBinaryAssetNameTest.php index 022312c6..66f70781 100644 --- a/test/unit/Platform/PrePackagedBinaryAssetNameTest.php +++ b/test/unit/Platform/PrePackagedBinaryAssetNameTest.php @@ -36,6 +36,7 @@ public function testPackageNamesNts(): void ThreadSafetyMode::NonThreadSafe, 1, null, + null, ); $libc = $targetPlatform->libcFlavour(); @@ -74,6 +75,7 @@ public function testPackageNamesZts(): void ThreadSafetyMode::ThreadSafe, 1, null, + null, ); $libc = $targetPlatform->libcFlavour(); @@ -110,6 +112,7 @@ public function testPackageNamesDebug(): void ThreadSafetyMode::NonThreadSafe, 1, null, + null, ); $libc = $targetPlatform->libcFlavour(); diff --git a/test/unit/Platform/TargetPlatformTest.php b/test/unit/Platform/TargetPlatformTest.php index 48c79df3..87499da7 100644 --- a/test/unit/Platform/TargetPlatformTest.php +++ b/test/unit/Platform/TargetPlatformTest.php @@ -8,6 +8,7 @@ use Php\Pie\Platform\OperatingSystem; use Php\Pie\Platform\OperatingSystemFamily; use Php\Pie\Platform\TargetPhp\PhpBinaryPath; +use Php\Pie\Platform\TargetPhp\PhpizePath; use Php\Pie\Platform\TargetPlatform; use Php\Pie\Platform\ThreadSafetyMode; use Php\Pie\Platform\WindowsCompiler; @@ -54,7 +55,7 @@ public function testWindowsPlatformFromPhpInfo(): void PHP Extension Build => API20230831,TS,VS16 TEXT); - $platform = TargetPlatform::fromPhpBinaryPath($phpBinaryPath, null); + $platform = TargetPlatform::fromPhpBinaryPath($phpBinaryPath, null, null); self::assertSame(OperatingSystem::Windows, $platform->operatingSystem); self::assertSame(OperatingSystemFamily::Windows, $platform->operatingSystemFamily); @@ -99,7 +100,7 @@ public function testLinuxPlatform(): void Thread Safety => disabled TEXT); - $platform = TargetPlatform::fromPhpBinaryPath($phpBinaryPath, null); + $platform = TargetPlatform::fromPhpBinaryPath($phpBinaryPath, null, null); self::assertSame(OperatingSystem::NonWindows, $platform->operatingSystem); self::assertSame(OperatingSystemFamily::Linux, $platform->operatingSystemFamily); @@ -111,8 +112,52 @@ public function testLinuxPlatform(): void public function testLibcFlavourIsMemoized(): void { self::assertSame( - TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null)->libcFlavour(), - TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null)->libcFlavour(), + TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null, null)->libcFlavour(), + TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null, null)->libcFlavour(), + ); + } + + public function testPhpizePathCanBeSet(): void + { + $phpBinaryPath = $this->createMock(PhpBinaryPath::class); + $phpBinaryPath->expects(self::any()) + ->method('operatingSystem') + ->willReturn(OperatingSystem::NonWindows); + $phpBinaryPath->expects(self::any()) + ->method('operatingSystemFamily') + ->willReturn(OperatingSystemFamily::Linux); + $phpBinaryPath->expects(self::any()) + ->method('machineType') + ->willReturn(Architecture::x86_64); + $phpBinaryPath->expects(self::any()) + ->method('phpinfo') + ->willReturn(<<<'TEXT' +phpinfo() +PHP Version => 8.3.6 + +System => Linux myhostname 1.2.3 Ubuntu x86_64 +Build Date => Apr 11 2024 20:23:38 +Build System => Linux +Server API => Command Line Interface +Virtual Directory Support => disabled +Configuration File (php.ini) Path => /etc/php/8.3/cli +Loaded Configuration File => /etc/php/8.3/cli/php.ini +Scan this dir for additional .ini files => /etc/php/8.3/cli/conf.d +Additional .ini files parsed => (none) +PHP API => 20230831 +PHP Extension => 20230831 +Zend Extension => 420230831 +Zend Extension Build => API420230831,NTS +PHP Extension Build => API20230831,NTS +Debug Build => no +Thread Safety => disabled +TEXT); + + self::assertSame( + '/path/to/phpize', + TargetPlatform::fromPhpBinaryPath($phpBinaryPath, null, new PhpizePath('/path/to/phpize')) + ->phpizePath + ?->phpizeBinaryPath, ); } } diff --git a/test/unit/Platform/WindowsExtensionAssetNameTest.php b/test/unit/Platform/WindowsExtensionAssetNameTest.php index 446b8a3d..00e00cb3 100644 --- a/test/unit/Platform/WindowsExtensionAssetNameTest.php +++ b/test/unit/Platform/WindowsExtensionAssetNameTest.php @@ -38,6 +38,7 @@ public function setUp(): void ThreadSafetyMode::ThreadSafe, 1, WindowsCompiler::VC14, + null, ); $this->phpVersion = $this->platform->phpBinaryPath->majorMinorVersion(); diff --git a/test/unit/SelfManage/BuildTools/BinaryBuildToolFinderTest.php b/test/unit/SelfManage/BuildTools/BinaryBuildToolFinderTest.php index 5eb1d582..c5b63096 100644 --- a/test/unit/SelfManage/BuildTools/BinaryBuildToolFinderTest.php +++ b/test/unit/SelfManage/BuildTools/BinaryBuildToolFinderTest.php @@ -9,29 +9,39 @@ use Php\Pie\SelfManage\BuildTools\BinaryBuildToolFinder; use Php\Pie\SelfManage\BuildTools\PackageManager; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; #[CoversClass(BinaryBuildToolFinder::class)] final class BinaryBuildToolFinderTest extends TestCase { + private TargetPlatform&MockObject $targetPlatform; + + public function setUp(): void + { + parent::setUp(); + + $this->targetPlatform = $this->createMock(TargetPlatform::class); + } + public function testCheckFailsToFindTool(): void { - self::assertFalse((new BinaryBuildToolFinder('this-should-not-be-anything-in-path', []))->check()); + self::assertFalse((new BinaryBuildToolFinder('this-should-not-be-anything-in-path', []))->check($this->targetPlatform)); } public function testCheckFailsToFindToolInList(): void { - self::assertFalse((new BinaryBuildToolFinder(['this-should-not-be-anything-in-path-1', 'this-should-not-be-anything-in-path-2'], []))->check()); + self::assertFalse((new BinaryBuildToolFinder(['this-should-not-be-anything-in-path-1', 'this-should-not-be-anything-in-path-2'], []))->check($this->targetPlatform)); } public function testCheckFindsTool(): void { - self::assertTrue((new BinaryBuildToolFinder('echo', []))->check()); + self::assertTrue((new BinaryBuildToolFinder('echo', []))->check($this->targetPlatform)); } public function testCheckFindsToolFromList(): void { - self::assertTrue((new BinaryBuildToolFinder(['this-should-not-be-anything-in-path', 'echo'], []))->check()); + self::assertTrue((new BinaryBuildToolFinder(['this-should-not-be-anything-in-path', 'echo'], []))->check($this->targetPlatform)); } public function testPackageNameIsNullWhenNoPackageConfiguredForPackageManager(): void @@ -40,7 +50,7 @@ public function testPackageNameIsNullWhenNoPackageConfiguredForPackageManager(): (new BinaryBuildToolFinder('a', [])) ->packageNameFor( PackageManager::Test, - TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null), + TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null, null), ), ); } @@ -51,7 +61,7 @@ public function testPackageNameIsNullWhenPackageConfiguredForPackageManagerIsNul (new BinaryBuildToolFinder('a', [PackageManager::Test->value => null])) ->packageNameFor( PackageManager::Test, - TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null), + TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null, null), ), ); } @@ -63,7 +73,7 @@ public function testPackageNameIsReturnedWhenPackageConfiguredForPackageManager( (new BinaryBuildToolFinder('a', [PackageManager::Test->value => 'the-package'])) ->packageNameFor( PackageManager::Test, - TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null), + TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess(), null, null), ), ); } @@ -77,7 +87,7 @@ public function testPackageNameIsReturnedWithFormattingWhenPackageConfiguredForP (new BinaryBuildToolFinder('a', [PackageManager::Test->value => 'php{major}{minor}-dev'])) ->packageNameFor( PackageManager::Test, - TargetPlatform::fromPhpBinaryPath($phpBinary, null), + TargetPlatform::fromPhpBinaryPath($phpBinary, null, null), ), ); } diff --git a/test/unit/SelfManage/BuildTools/CheckAllBuildToolsTest.php b/test/unit/SelfManage/BuildTools/CheckAllBuildToolsTest.php index b3bbe6d1..07a479f4 100644 --- a/test/unit/SelfManage/BuildTools/CheckAllBuildToolsTest.php +++ b/test/unit/SelfManage/BuildTools/CheckAllBuildToolsTest.php @@ -40,6 +40,7 @@ public function testCheckDoesNothingWhenAllBuildToolsAreFound(): void ThreadSafetyMode::NonThreadSafe, 1, null, + null, ), false, ); @@ -70,6 +71,7 @@ public function testCheckInstallsMissingToolWhenPromptedInInteractiveMode(): voi ThreadSafetyMode::NonThreadSafe, 1, null, + null, ), false, ); @@ -100,6 +102,7 @@ public function testCheckDoesNotInstallToolsWhenInNonInteractiveModeAndFlagNotPr ThreadSafetyMode::NonThreadSafe, 1, null, + null, ), false, ); @@ -130,6 +133,7 @@ public function testCheckInstallsMissingToolInNonInteractiveModeAndFlagIsProvide ThreadSafetyMode::NonThreadSafe, 1, null, + null, ), true, ); diff --git a/test/unit/SelfManage/BuildTools/PhpizeBuildToolFinderTest.php b/test/unit/SelfManage/BuildTools/PhpizeBuildToolFinderTest.php new file mode 100644 index 00000000..067bf32d --- /dev/null +++ b/test/unit/SelfManage/BuildTools/PhpizeBuildToolFinderTest.php @@ -0,0 +1,105 @@ +createMock(PhpBinaryPath::class); + (fn () => $this->phpBinaryPath = '/path/to/php') + ->bindTo($mockPhpBinary, PhpBinaryPath::class)(); + + self::assertTrue((new PhpizeBuildToolFinder([]))->check(new TargetPlatform( + OperatingSystem::NonWindows, + OperatingSystemFamily::Linux, + $mockPhpBinary, + Architecture::x86_64, + ThreadSafetyMode::NonThreadSafe, + 1, + null, + null, + ))); + + putenv('PATH=' . $oldPath); + } + + public function testCheckWithPhpizeFromTargetPlatform(): void + { + $oldPath = getenv('PATH'); + putenv('PATH=' . realpath(self::BAD_PHPIZE_PATH)); + + $mockPhpBinary = $this->createMock(PhpBinaryPath::class); + (fn () => $this->phpBinaryPath = '/path/to/php') + ->bindTo($mockPhpBinary, PhpBinaryPath::class)(); + + $goodPhpize = realpath(self::GOOD_PHPIZE_PATH . DIRECTORY_SEPARATOR . 'phpize'); + self::assertNotFalse($goodPhpize); + + self::assertTrue((new PhpizeBuildToolFinder([]))->check(new TargetPlatform( + OperatingSystem::NonWindows, + OperatingSystemFamily::Linux, + $mockPhpBinary, + Architecture::x86_64, + ThreadSafetyMode::NonThreadSafe, + 1, + null, + new PhpizePath($goodPhpize), + ))); + + putenv('PATH=' . $oldPath); + } + + public function testCheckWithPhpizeGuessed(): void + { + $oldPath = getenv('PATH'); + putenv('PATH=' . realpath(self::BAD_PHPIZE_PATH)); + + $mockPhpBinary = $this->createMock(PhpBinaryPath::class); + $mockPhpBinary->method('phpApiVersion')->willReturn('20240924'); + $phpPath = realpath(self::GOOD_PHPIZE_PATH . DIRECTORY_SEPARATOR . 'php'); + (fn () => $this->phpBinaryPath = $phpPath) + ->bindTo($mockPhpBinary, PhpBinaryPath::class)(); + + self::assertTrue((new PhpizeBuildToolFinder([]))->check(new TargetPlatform( + OperatingSystem::NonWindows, + OperatingSystemFamily::Linux, + $mockPhpBinary, + Architecture::x86_64, + ThreadSafetyMode::NonThreadSafe, + 1, + null, + null, + ))); + + putenv('PATH=' . $oldPath); + } +}