1
0
mirror of https://github.com/php/pie.git synced 2026-03-23 23:12:17 +01:00

482: fix PHP_OS_FAMILY missing in PHP <7.2 with polyfill

This commit is contained in:
James Titcumb
2026-01-19 15:12:15 +00:00
parent 90d6d1850b
commit 0dd84d6f5f

View File

@@ -254,11 +254,38 @@ PHP,
public function operatingSystemFamily(): OperatingSystemFamily
{
/** @link https://github.com/sebastianbergmann/environment/commit/eb6dd721cfaca04c27ac61c7201493a8f62f7f1d */
$osFamily = OperatingSystemFamily::tryFrom(strtolower(trim(
self::cleanWarningAndDeprecationsFromOutput(Process::run([
$this->phpBinaryPath,
'-r',
'echo PHP_OS_FAMILY;',
<<<'PHP'
if (defined('PHP_OS_FAMILY')) {
echo PHP_OS_FAMILY;
} elseif ('\\' === DIRECTORY_SEPARATOR) {
echo 'Windows';
} else {
switch(PHP_OS) {
case 'Darwin':
echo 'Darwin';
break;
case 'DragonFly':
case 'FreeBSD':
case 'NetBSD':
case 'OpenBSD':
echo 'BSD';
break;
case 'Linux':
echo 'Linux';
break;
case 'SunOS':
echo 'Solaris';
break;
default:
echo 'Unknown';
}
}
PHP,
])),
)));
Assert::notNull($osFamily, 'Could not determine operating system family');