2500, CURLOPT_TIMEOUT_MS => 6000, CURLOPT_FOLLOWLOCATION => false, CURLOPT_USERAGENT => 'LaySite version check', CURLOPT_WRITEFUNCTION => static function (CurlHandle $handle, string $chunk) use (&$body): int { if (strlen($body) + strlen($chunk) > 128) { return 0; } $body .= $chunk; return strlen($chunk); }, ]); if (curl_exec($curl) === false || curl_getinfo($curl, CURLINFO_RESPONSE_CODE) !== 200) { throw new RuntimeException('无法读取上游版本,请稍后重试。'); } if (!preg_match('/^v?(\d+\.\d+\.\d+)$/D', trim($body), $version)) { throw new RuntimeException('上游仓库返回的版本格式无效。'); } $current = self::current(); $latest = $version[1]; return ['current' => $current, 'latest' => $latest, 'comparison' => version_compare($latest, $current)]; } }