in src/utils/ExampleTypechecker.php [18:72]
async function typecheck_example_async(
string $in_file,
): Awaitable<(string, string)> {
$source_dir = \dirname($in_file);
await using $tmp_dir = new TemporaryDirectory();
await using $hh_tmp_dir = new TemporaryDirectory();
$work_dir = $tmp_dir->getPath();
\copy(
$in_file,
$work_dir.'/'.Str\strip_suffix(\basename($in_file), '.type-errors'),
);
$hhconfig = \file_exists($in_file.'.hhconfig')
? \file_get_contents($in_file.'.hhconfig')."\n"
: '';
if (
!Str\contains($hhconfig, 'allowed_decl_fixme_codes') &&
!Str\contains($hhconfig, 'allowed_fixme_codes_strict')
) {
$hhconfig .= get_hhconfig_whitelists();
}
\file_put_contents($work_dir.'/.hhconfig', $hhconfig);
foreach (\glob($source_dir.'/*.inc.php') as $include_file) {
\copy($include_file, $work_dir.'/'.\basename($include_file));
}
$hh_server_path = get_hh_server_path();
invariant($hh_server_path is nonnull, "Couldn't find hh_server");
list($_exit_code, $stdout, $stderr) = await execute_async(
shape(
'environment' => dict[
'HH_TMPDIR' => $hh_tmp_dir->getPath(),
// HHVM_DISABLE_PERSONALITY: `hh_server` tries to disable ASLR via the
// `personality()` syscall, which fails in Docker.
'HHVM_DISABLE_PERSONALITY' => '1',
],
),
$hh_server_path,
'--check',
'--max-procs=1',
'--config',
'extra_paths='.LocalConfig::ROOT.'/vendor/',
'--config',
// Composer generates .hack files in bin/ that are not hack; by default,
// hack ignores them, but as we're pulling them in via `extra_paths`, we
// need to explicitly ignore them
'ignored_paths=[".*vendor/bin/.*"]',
$work_dir,
);
return tuple($stdout, $stderr);
}