in gen_stub.php [41:80]
function processStubFile(string $stubFile, Context $context): ?FileInfo {
try {
if (!file_exists($stubFile)) {
throw new Exception("File $stubFile does not exist");
}
$arginfoFile = str_replace('.stub.php', '_arginfo.h', $stubFile);
$legacyFile = str_replace('.stub.php', '_legacy_arginfo.h', $stubFile);
$stubCode = file_get_contents($stubFile);
$stubHash = computeStubHash($stubCode);
$oldStubHash = extractStubHash($arginfoFile);
if ($stubHash === $oldStubHash && !$context->forceParse) {
/* Stub file did not change, do not regenerate. */
return null;
}
initPhpParser();
$fileInfo = parseStubFile($stubCode);
$arginfoCode = generateArgInfoCode($fileInfo, $stubHash, $context->minimalArgInfo);
if (($context->forceRegeneration || $stubHash !== $oldStubHash) && file_put_contents($arginfoFile, $arginfoCode)) {
echo "Saved $arginfoFile\n";
}
if ($fileInfo->generateLegacyArginfo) {
foreach ($fileInfo->getAllFuncInfos() as $funcInfo) {
$funcInfo->discardInfoForOldPhpVersions();
}
$arginfoCode = generateArgInfoCode($fileInfo, $stubHash, $context->minimalArgInfo);
if (($context->forceRegeneration || $stubHash !== $oldStubHash) && file_put_contents($legacyFile, $arginfoCode)) {
echo "Saved $legacyFile\n";
}
}
return $fileInfo;
} catch (Exception $e) {
echo "In $stubFile:\n{$e->getMessage()}\n";
exit(1);
}
}