Document gen fixed

This commit is contained in:
2025-10-12 17:52:17 +02:00
parent e0303ece74
commit 23f2011e33
16 changed files with 1116 additions and 88 deletions
+12 -6
View File
@@ -4,19 +4,25 @@
class TokenScanner
{
// Allow entity.attr with attr accepting letters, digits, underscore, dot and hyphen for flexibility (e.g., custom.order-id)
private const REGEX = '/{{\s*([a-zA-Z0-9_]+\.[a-zA-Z0-9_.-]+)\s*}}/';
// Allow nested tokens like client.person.full_name or custom.order-id
// Pattern: entity(.[subentity])* . attribute
private const REGEX_DOUBLE = '/{{\s*([a-zA-Z0-9_]+(?:\.[a-zA-Z0-9_]+)*\.[a-zA-Z0-9_.-]+)\s*}}/';
private const REGEX_SINGLE = '/\{\s*([a-zA-Z0-9_]+(?:\.[a-zA-Z0-9_]+)*\.[a-zA-Z0-9_.-]+)\s*\}/';
/**
* @return array<int,string>
*/
public function scan(string $content): array
{
preg_match_all(self::REGEX, $content, $m);
if (empty($m[1])) {
return [];
$out = [];
if (preg_match_all(self::REGEX_DOUBLE, $content, $m1) && ! empty($m1[1])) {
$out = array_merge($out, $m1[1]);
}
if (preg_match_all(self::REGEX_SINGLE, $content, $m2) && ! empty($m2[1])) {
$out = array_merge($out, $m2[1]);
}
return array_values(array_unique($m[1]));
return array_values(array_unique($out));
}
}