private static function getPermissionInfo()
{
$proc = proc_open('whoami', [['pipe', 'r'], ['pipe', 'w'], ['pipe', 'w']], $pipes);
$procOpenUser = trim(stream_get_contents($pipes[1]));
$processInfo = ['exec-user' => exec('whoami'), 'proc_open-user' => $procOpenUser];
$writeTargets = ['ABSPATH' => ABSPATH, 'WP_CONTENT_DIR' => WP_CONTENT_DIR, 'sys_temp_dir' => sys_get_temp_dir()];
foreach ($writeTargets as $target => $directory) {
$filePath = $directory . '/' . '.vp-try-write-php';
/** @noinspection PhpUsageOfSilenceOperatorInspection */
@file_put_contents($filePath, "");
$processInfo['php-can-write'][$target] = is_file($filePath);
FileSystem::remove($filePath);
$processInfo['php-can-delete'][$target] = !is_file($filePath);
$filePath = $directory . '/' . '.vp-try-write-process';
$process = new Process(sprintf("echo test > %s", ProcessUtils::escapeshellarg($filePath)));
$process->run();
$processInfo['process-can-write'][$target] = is_file($filePath);
try {
FileSystem::remove($filePath);
$processInfo['php-can-delete-file-created-by-process'][$target] = !is_file($filePath);
} catch (IOException $ex) {
$processInfo['php-can-delete-file-created-by-process'][$target] = false;
}
}
return $processInfo;
}