|
|
|
@ -21,6 +21,8 @@ class Platform
|
|
|
|
|
{
|
|
|
|
|
/** @var ?bool */
|
|
|
|
|
private static $isVirtualBoxGuest = null;
|
|
|
|
|
/** @var ?bool */
|
|
|
|
|
private static $isWindowsSubsystemForLinux = null;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Parses tildes and environment variables in paths.
|
|
|
|
@ -67,6 +69,27 @@ class Platform
|
|
|
|
|
throw new \RuntimeException('Could not determine user directory');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return bool Whether the host machine is running on the Windows Subsystem for Linux (WSL)
|
|
|
|
|
*/
|
|
|
|
|
public static function isWindowsSubsystemForLinux()
|
|
|
|
|
{
|
|
|
|
|
if (null === self::$isWindowsSubsystemForLinux) {
|
|
|
|
|
self::$isWindowsSubsystemForLinux = false;
|
|
|
|
|
|
|
|
|
|
// while WSL will be hosted within windows, WSL itself cannot be windows based itself.
|
|
|
|
|
if (self::isWindows()) {
|
|
|
|
|
return self::$isWindowsSubsystemForLinux = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (is_readable('/proc/version') && false !== stripos(file_get_contents('/proc/version'), 'microsoft')) {
|
|
|
|
|
return self::$isWindowsSubsystemForLinux = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self::$isWindowsSubsystemForLinux;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return bool Whether the host machine is running a Windows OS
|
|
|
|
|
*/
|
|
|
|
|