Skip to content

Commit 711c5af

Browse files
committed
Extract static PHP check
1 parent 72c2a32 commit 711c5af

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/Command/CommandHelper.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,15 @@
3737
use function array_key_exists;
3838
use function array_map;
3939
use function count;
40-
use function defined;
4140
use function is_array;
4241
use function is_string;
4342
use function reset;
4443
use function sprintf;
45-
use function str_contains;
4644
use function str_starts_with;
4745
use function strtolower;
4846
use function substr;
4947
use function trim;
5048

51-
use const PHP_BUILD_PROVIDER;
5249
use const PHP_VERSION;
5350

5451
/** @internal This is not public API for PIE, so should not be depended upon unless you accept the risk of BC breaks */
@@ -200,7 +197,7 @@ public static function determineTargetPlatformFromInputs(InputInterface $input,
200197

201198
$targetPlatform = TargetPlatform::fromPhpBinaryPath($phpBinaryPath, $makeParallelJobs);
202199

203-
if (defined('PHP_BUILD_PROVIDER') && str_contains(PHP_BUILD_PROVIDER, 'static-php-cli')) {
200+
if (PiePlatform::isRunningStaticPhp()) {
204201
$io->write(sprintf('<info>You are running a PIE Static PHP %s build</info>', PHP_VERSION));
205202
} else {
206203
$io->write(sprintf('<info>You are running PHP %s</info>', PHP_VERSION));

src/Platform.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
use function implode;
1616
use function md5;
1717
use function rtrim;
18+
use function str_contains;
1819
use function strpos;
1920
use function strtr;
2021

2122
use const DIRECTORY_SEPARATOR;
23+
use const PHP_BUILD_PROVIDER;
2224
use const STDIN;
2325

2426
/** @internal This is not public API for PIE, so should not be depended upon unless you accept the risk of BC breaks */
@@ -125,4 +127,9 @@ public static function getPieJsonFilename(TargetPlatform $targetPlatform): strin
125127
{
126128
return self::getPieWorkingDirectory($targetPlatform) . '/pie.json';
127129
}
130+
131+
public static function isRunningStaticPhp(): bool
132+
{
133+
return defined('PHP_BUILD_PROVIDER') && str_contains(PHP_BUILD_PROVIDER, 'static-php-cli');
134+
}
128135
}

0 commit comments

Comments
 (0)