instances added god may help

This commit is contained in:
2026-02-23 12:58:19 +01:00
parent 25370a1a55
commit 99db252f60
290 changed files with 9858 additions and 4914 deletions

View File

@@ -301,13 +301,13 @@ class DocsCatalogService
$parsedHeadings = [];
foreach ($headingBlocks as $headingBlock) {
$level = (int) ($headingBlock[1][0] ?? 0);
$level = (int) $headingBlock[1][0];
if (!in_array($level, [1, 2, 3], true)) {
continue;
}
$attrs = (string) ($headingBlock[2][0] ?? '');
$html = (string) ($headingBlock[3][0] ?? '');
$attrs = (string) $headingBlock[2][0];
$html = (string) $headingBlock[3][0];
$text = self::normalizePlainText(strip_tags($html));
if ($text === '') {
continue;
@@ -315,7 +315,7 @@ class DocsCatalogService
$id = '';
if (preg_match('/\bid=(["\'])([^"\']+)\1/i', $attrs, $idMatch)) {
$id = trim((string) ($idMatch[2] ?? ''));
$id = trim((string) $idMatch[2]);
}
if ($id === '') {
@@ -325,8 +325,8 @@ class DocsCatalogService
$id = self::nextUniqueAnchor($id, $seenAnchors);
}
$fullHtml = (string) ($headingBlock[0][0] ?? '');
$start = (int) ($headingBlock[0][1] ?? 0);
$fullHtml = (string) $headingBlock[0][0];
$start = (int) $headingBlock[0][1];
$end = $start + strlen($fullHtml);
$parsedHeadings[] = [
@@ -357,9 +357,9 @@ class DocsCatalogService
}
$heading = $parsedHeadings[$headingIndex++];
$level = (string) ($match[1] ?? '2');
$attrs = (string) ($match[2] ?? '');
$html = (string) ($match[3] ?? '');
$level = (string) $match[1];
$attrs = (string) $match[2];
$html = (string) $match[3];
if (preg_match('/\bid=(["\'])([^"\']+)\1/i', $attrs)) {
return "<h{$level}{$attrs}>{$html}</h{$level}>";
@@ -517,21 +517,21 @@ class DocsCatalogService
$docScore = self::titleScore($needle, $title);
if ($docScore > 0) {
$firstHeading = $headings[0];
$docKey = $slug . '#' . (string) ($firstHeading['anchor'] ?? '');
$docKey = $slug . '#' . (string) $firstHeading['anchor'];
$resultsByKey[$docKey] = [
'slug' => $slug,
'title' => $title,
'section' => '',
'anchor' => (string) ($firstHeading['anchor'] ?? ''),
'snippet' => self::buildSnippet((string) ($firstHeading['body'] ?? ''), $needle),
'anchor' => (string) $firstHeading['anchor'],
'snippet' => self::buildSnippet((string) $firstHeading['body'], $needle),
'score' => $docScore,
];
}
foreach ($headings as $heading) {
$sectionText = (string) ($heading['text'] ?? '');
$anchor = (string) ($heading['anchor'] ?? '');
$body = (string) ($heading['body'] ?? '');
$sectionText = (string) $heading['text'];
$anchor = (string) $heading['anchor'];
$body = (string) $heading['body'];
$score = self::sectionScore($needle, $sectionText, $body);
if ($score <= 0) {
continue;