Skip to content

Commit 637a55d

Browse files
committed
Rework PhpizePath to be passed to TargetPlatform
1 parent adfe984 commit 637a55d

51 files changed

Lines changed: 315 additions & 102 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

phpstan-baseline.neon

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ parameters:
1212
count: 1
1313
path: src/Command/CommandHelper.php
1414

15-
-
16-
message: '#^Cannot cast mixed to string\.$#'
17-
identifier: cast.string
18-
count: 1
19-
path: src/Command/CommandHelper.php
20-
2115
-
2216
message: '#^Cannot cast mixed to string\.$#'
2317
identifier: cast.string
@@ -480,6 +474,12 @@ parameters:
480474
count: 1
481475
path: test/unit/Installing/InstallForPhpProject/InstallSelectedPackageTest.php
482476

477+
-
478+
message: '#^Access to an undefined property Php\\PieUnitTest\\SelfManage\\BuildTools\\PhpizeBuildToolFinderTest\:\:\$phpBinaryPath\.$#'
479+
identifier: property.notFound
480+
count: 3
481+
path: test/unit/SelfManage/BuildTools/PhpizeBuildToolFinderTest.php
482+
483483
-
484484
message: '#^Method Php\\PieUnitTest\\SelfManage\\Verify\\FallbackVerificationUsingOpenSslTest\:\:prepareCertificateAndSignature\(\) should return array\{string, string\} but returns array\{mixed, mixed\}\.$#'
485485
identifier: return.type

src/Building/Build.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Composer\IO\IOInterface;
88
use Php\Pie\Downloading\DownloadedPackage;
99
use Php\Pie\File\BinaryFile;
10-
use Php\Pie\Platform\TargetPhp\PhpizePath;
1110
use Php\Pie\Platform\TargetPlatform;
1211

1312
/** @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(
1918
TargetPlatform $targetPlatform,
2019
array $configureOptions,
2120
IOInterface $io,
22-
PhpizePath|null $phpizePath,
2321
): BinaryFile;
2422
}

src/Building/UnixBuild.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ public function __invoke(
3434
TargetPlatform $targetPlatform,
3535
array $configureOptions,
3636
IOInterface $io,
37-
PhpizePath|null $phpizePath,
3837
): BinaryFile {
3938
$selectedDownloadMethod = DownloadUrlMethod::fromDownloadedPackage($downloadedPackage);
4039
switch ($selectedDownloadMethod) {
@@ -43,7 +42,7 @@ public function __invoke(
4342

4443
case DownloadUrlMethod::ComposerDefaultDownload:
4544
case DownloadUrlMethod::PrePackagedSourceDownload:
46-
return $this->buildFromSource($downloadedPackage, $targetPlatform, $configureOptions, $io, $phpizePath);
45+
return $this->buildFromSource($downloadedPackage, $targetPlatform, $configureOptions, $io);
4746

4847
default:
4948
throw new LogicException('Unsupported download method: ' . $selectedDownloadMethod->value);
@@ -74,7 +73,6 @@ private function buildFromSource(
7473
TargetPlatform $targetPlatform,
7574
array $configureOptions,
7675
IOInterface $io,
77-
PhpizePath|null $phpizePath,
7876
): BinaryFile {
7977
$outputCallback = null;
8078
if ($io->isVerbose()) {
@@ -88,7 +86,7 @@ private function buildFromSource(
8886
};
8987
}
9088

91-
$phpizePath ??= PhpizePath::guessFrom($targetPlatform->phpBinaryPath);
89+
$phpizePath = $targetPlatform->phpizePath ?? PhpizePath::guessFrom($targetPlatform->phpBinaryPath);
9290

9391
/**
9492
* Call a cleanup first; most of the time, we expect to be changing a

src/Building/WindowsBuild.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Composer\IO\IOInterface;
88
use Php\Pie\Downloading\DownloadedPackage;
99
use Php\Pie\File\BinaryFile;
10-
use Php\Pie\Platform\TargetPhp\PhpizePath;
1110
use Php\Pie\Platform\TargetPlatform;
1211
use Php\Pie\Platform\WindowsExtensionAssetName;
1312

@@ -22,7 +21,6 @@ public function __invoke(
2221
TargetPlatform $targetPlatform,
2322
array $configureOptions,
2423
IOInterface $io,
25-
PhpizePath|null $phpizePath,
2624
): BinaryFile {
2725
$prebuiltDll = WindowsExtensionAssetName::determineDllName($targetPlatform, $downloadedPackage);
2826

src/Command/BuildCommand.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ public function execute(InputInterface $input, OutputInterface $output): int
8484
$requestedNameAndVersion,
8585
PieOperation::Resolve,
8686
[], // Configure options are not needed for resolve only
87-
null,
8887
false, // setting up INI not needed for build
8988
),
9089
);
@@ -126,7 +125,6 @@ public function execute(InputInterface $input, OutputInterface $output): int
126125
$requestedNameAndVersion,
127126
PieOperation::Build,
128127
$configureOptionsValues,
129-
CommandHelper::determinePhpizePathFromInputs($input),
130128
false, // setting up INI not needed for build
131129
),
132130
);

src/Command/CommandHelper.php

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,6 @@ public static function determineTargetPlatformFromInputs(InputInterface $input,
185185
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.');
186186
}
187187

188-
if (Platform::isWindows() && $input->hasOption(self::OPTION_WITH_PHPIZE_PATH)) {
189-
/** @var mixed $withPhpizePath */
190-
$withPhpizePath = $input->getOption(self::OPTION_WITH_PHPIZE_PATH);
191-
192-
if (is_string($withPhpizePath) && trim($withPhpizePath) !== '') {
193-
throw new InvalidArgumentException('The --with-phpize-path=/path/to/phpize cannot be used on Windows.');
194-
}
195-
}
196-
197188
if ($specifiedWithPhpConfig) {
198189
$phpBinaryPath = PhpBinaryPath::fromPhpConfigExecutable($withPhpConfig);
199190
}
@@ -210,7 +201,19 @@ public static function determineTargetPlatformFromInputs(InputInterface $input,
210201
}
211202
}
212203

213-
$targetPlatform = TargetPlatform::fromPhpBinaryPath($phpBinaryPath, $makeParallelJobs);
204+
$phpizePath = null;
205+
if ($input->hasOption(self::OPTION_WITH_PHPIZE_PATH)) {
206+
$phpizePathOption = $input->getOption(self::OPTION_WITH_PHPIZE_PATH);
207+
if (is_string($phpizePathOption) && trim($phpizePathOption) !== '') {
208+
if (Platform::isWindows()) {
209+
throw new InvalidArgumentException('The --with-phpize-path=/path/to/phpize cannot be used on Windows.');
210+
}
211+
212+
$phpizePath = new PhpizePath($phpizePathOption);
213+
}
214+
}
215+
216+
$targetPlatform = TargetPlatform::fromPhpBinaryPath($phpBinaryPath, $makeParallelJobs, $phpizePath);
214217

215218
if (PiePlatform::isRunningStaticPhp()) {
216219
$io->write(sprintf('<info>You are running a PIE Static PHP %s build</info>', PHP_VERSION));
@@ -264,18 +267,6 @@ public static function shouldCheckForBuildTools(InputInterface $input): bool
264267
|| ! $input->getOption(self::OPTION_SUPPRESS_BUILD_TOOLS_CHECK);
265268
}
266269

267-
public static function determinePhpizePathFromInputs(InputInterface $input): PhpizePath|null
268-
{
269-
if ($input->hasOption(self::OPTION_WITH_PHPIZE_PATH)) {
270-
$phpizePathOption = (string) $input->getOption(self::OPTION_WITH_PHPIZE_PATH);
271-
if (trim($phpizePathOption) !== '') {
272-
return new PhpizePath($phpizePathOption);
273-
}
274-
}
275-
276-
return null;
277-
}
278-
279270
public static function requestedNameAndVersionPair(InputInterface $input): RequestedPackageAndVersion
280271
{
281272
$requestedPackageString = $input->getArgument(self::ARG_REQUESTED_PACKAGE_AND_VERSION);

src/Command/DownloadCommand.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ public function execute(InputInterface $input, OutputInterface $output): int
7474
$requestedNameAndVersion,
7575
PieOperation::Download,
7676
[], // Configure options are not needed for download only
77-
null,
7877
false, // setting up INI not needed for download
7978
),
8079
);

src/Command/InfoCommand.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ public function execute(InputInterface $input, OutputInterface $output): int
7979
$requestedNameAndVersion,
8080
PieOperation::Resolve,
8181
[], // Configure options are not needed for resolve only
82-
null,
8382
false, // setting up INI not needed for info
8483
),
8584
);

src/Command/InstallCommand.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ public function execute(InputInterface $input, OutputInterface $output): int
9898
$requestedNameAndVersion,
9999
PieOperation::Resolve,
100100
[], // Configure options are not needed for resolve only
101-
null,
102101
false, // setting up INI not needed for resolve step
103102
),
104103
);
@@ -140,7 +139,6 @@ public function execute(InputInterface $input, OutputInterface $output): int
140139
$requestedNameAndVersion,
141140
PieOperation::Install,
142141
$configureOptionsValues,
143-
CommandHelper::determinePhpizePathFromInputs($input),
144142
CommandHelper::determineAttemptToSetupIniFile($input),
145143
),
146144
);

src/Command/UninstallCommand.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ public function execute(InputInterface $input, OutputInterface $output): int
9191
$requestedPackageAndVersionToRemove,
9292
PieOperation::Uninstall,
9393
[], // Configure options are not needed for uninstall
94-
null,
9594
true,
9695
),
9796
);

0 commit comments

Comments
 (0)