-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathErrors.php
More file actions
109 lines (105 loc) · 10.1 KB
/
Errors.php
File metadata and controls
109 lines (105 loc) · 10.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
declare(strict_types=1);
namespace JustHTML;
final class Errors
{
public static function generateErrorMessage(string $code, ?string $tagName = null): string
{
$messages = [
"eof-in-doctype" => "Unexpected end of file in DOCTYPE declaration",
"eof-in-doctype-name" => "Unexpected end of file while reading DOCTYPE name",
"eof-in-doctype-public-identifier" => "Unexpected end of file in DOCTYPE public identifier",
"eof-in-doctype-system-identifier" => "Unexpected end of file in DOCTYPE system identifier",
"expected-doctype-name-but-got-right-bracket" => "Expected DOCTYPE name but got >",
"missing-whitespace-before-doctype-name" => "Missing whitespace after <!DOCTYPE",
"abrupt-doctype-public-identifier" => "DOCTYPE public identifier ended abruptly",
"abrupt-doctype-system-identifier" => "DOCTYPE system identifier ended abruptly",
"missing-quote-before-doctype-public-identifier" => "Missing quote before DOCTYPE public identifier",
"missing-quote-before-doctype-system-identifier" => "Missing quote before DOCTYPE system identifier",
"missing-doctype-public-identifier" => "Missing DOCTYPE public identifier",
"missing-doctype-system-identifier" => "Missing DOCTYPE system identifier",
"missing-whitespace-before-doctype-public-identifier" => "Missing whitespace before DOCTYPE public identifier",
"missing-whitespace-after-doctype-public-identifier" => "Missing whitespace after DOCTYPE public identifier",
"missing-whitespace-between-doctype-public-and-system-identifiers" => "Missing whitespace between DOCTYPE identifiers",
"missing-whitespace-after-doctype-name" => "Missing whitespace after DOCTYPE name",
"unexpected-character-after-doctype-public-keyword" => "Unexpected character after PUBLIC keyword",
"unexpected-character-after-doctype-system-keyword" => "Unexpected character after SYSTEM keyword",
"unexpected-character-after-doctype-public-identifier" => "Unexpected character after public identifier",
"unexpected-character-after-doctype-system-identifier" => "Unexpected character after system identifier",
"eof-in-comment" => "Unexpected end of file in comment",
"abrupt-closing-of-empty-comment" => "Comment ended abruptly with -->",
"incorrectly-closed-comment" => "Comment ended with --!> instead of -->",
"eof-in-tag" => "Unexpected end of file in tag",
"eof-before-tag-name" => "Unexpected end of file before tag name",
"empty-end-tag" => "Empty end tag </> is not allowed",
"invalid-first-character-of-tag-name" => "Invalid first character of tag name",
"unexpected-question-mark-instead-of-tag-name" => "Unexpected ? instead of tag name",
"unexpected-character-after-solidus-in-tag" => "Unexpected character after / in tag",
"duplicate-attribute" => "Duplicate attribute name",
"missing-attribute-value" => "Missing attribute value",
"unexpected-character-in-attribute-name" => "Unexpected character in attribute name",
"unexpected-character-in-unquoted-attribute-value" => "Unexpected character in unquoted attribute value",
"missing-whitespace-between-attributes" => "Missing whitespace between attributes",
"unexpected-equals-sign-before-attribute-name" => "Unexpected = before attribute name",
"eof-in-script-html-comment-like-text" => "Unexpected end of file in script with HTML-like comment",
"eof-in-script-in-script" => "Unexpected end of file in nested script tag",
"eof-in-cdata" => "Unexpected end of file in CDATA section",
"cdata-in-html-content" => "CDATA section only allowed in SVG/MathML content",
"unexpected-null-character" => "Unexpected NULL character (U+0000)",
"incorrectly-opened-comment" => "Incorrectly opened comment",
"control-character-reference" => "Invalid control character in character reference",
"illegal-codepoint-for-numeric-entity" => "Invalid codepoint in numeric character reference",
"missing-semicolon-after-character-reference" => "Missing semicolon after character reference",
"named-entity-without-semicolon" => "Named entity used without semicolon",
"unexpected-doctype" => "Unexpected DOCTYPE declaration",
"unknown-doctype" => "Unknown DOCTYPE (expected <!DOCTYPE html>)",
"expected-doctype-but-got-chars" => "Expected DOCTYPE but got text content",
"expected-doctype-but-got-eof" => "Expected DOCTYPE but reached end of file",
"expected-doctype-but-got-start-tag" => $tagName ? "Expected DOCTYPE but got <{$tagName}> tag" : "Expected DOCTYPE but got start tag",
"expected-doctype-but-got-end-tag" => $tagName ? "Expected DOCTYPE but got </{$tagName}> tag" : "Expected DOCTYPE but got end tag",
"unexpected-doctype-in-foreign-content" => "Unexpected DOCTYPE in SVG/MathML content",
"unexpected-start-tag" => $tagName ? "Unexpected <{$tagName}> start tag" : "Unexpected start tag",
"unexpected-end-tag" => $tagName ? "Unexpected </{$tagName}> end tag" : "Unexpected end tag",
"unexpected-end-tag-before-html" => $tagName ? "Unexpected </{$tagName}> end tag before <html>" : "Unexpected end tag before <html>",
"unexpected-end-tag-before-head" => $tagName ? "Unexpected </{$tagName}> end tag before <head>" : "Unexpected end tag before <head>",
"unexpected-end-tag-after-head" => $tagName ? "Unexpected </{$tagName}> end tag after <head>" : "Unexpected end tag after <head>",
"unexpected-start-tag-ignored" => $tagName ? "<{$tagName}> start tag ignored in current context" : "Start tag ignored in current context",
"unexpected-start-tag-implies-end-tag" => $tagName ? "<{$tagName}> start tag implicitly closes previous element" : "Start tag implicitly closes previous element",
"expected-closing-tag-but-got-eof" => $tagName ? "Expected </{$tagName}> closing tag but reached end of file" : "Expected closing tag but reached end of file",
"expected-named-closing-tag-but-got-eof" => $tagName ? "Expected </{$tagName}> closing tag but reached end of file" : "Expected closing tag but reached end of file",
"invalid-codepoint" => "Invalid character (U+0000 NULL or U+000C FORM FEED)",
"invalid-codepoint-before-head" => "Invalid character before <head>",
"invalid-codepoint-in-body" => "Invalid character in <body>",
"invalid-codepoint-in-table-text" => "Invalid character in table text",
"invalid-codepoint-in-select" => "Invalid character in <select>",
"invalid-codepoint-in-foreign-content" => "Invalid character in SVG/MathML content",
"foster-parenting-character" => "Text content in table requires foster parenting",
"foster-parenting-start-tag" => "Start tag in table requires foster parenting",
"unexpected-start-tag-implies-table-voodoo" => $tagName ? "<{$tagName}> start tag in table triggers foster parenting" : "Start tag in table triggers foster parenting",
"unexpected-end-tag-implies-table-voodoo" => $tagName ? "</{$tagName}> end tag in table triggers foster parenting" : "End tag in table triggers foster parenting",
"unexpected-cell-in-table-body" => "Unexpected table cell outside of table row",
"unexpected-form-in-table" => "Form element not allowed in table context",
"unexpected-hidden-input-in-table" => "Hidden input in table triggers foster parenting",
"unexpected-hidden-input-after-head" => "Unexpected hidden input after <head>",
"unexpected-token-in-frameset" => "Unexpected content in <frameset>",
"unexpected-token-after-frameset" => "Unexpected content after <frameset>",
"unexpected-token-after-after-frameset" => "Unexpected content after frameset closed",
"unexpected-token-after-body" => "Unexpected content after </body>",
"unexpected-char-after-body" => "Unexpected character after </body>",
"unexpected-characters-in-column-group" => "Text not allowed in <colgroup>",
"unexpected-characters-in-template-column-group" => "Text not allowed in template column group",
"unexpected-start-tag-in-column-group" => $tagName ? "<{$tagName}> start tag not allowed in <colgroup>" : "Start tag not allowed in <colgroup>",
"unexpected-start-tag-in-template-column-group" => $tagName ? "<{$tagName}> start tag not allowed in template column group" : "Start tag not allowed in template column group",
"unexpected-start-tag-in-template-table-context" => $tagName ? "<{$tagName}> start tag not allowed in template table context" : "Start tag not allowed in template table context",
"unexpected-start-tag-in-cell-fragment" => $tagName ? "<{$tagName}> start tag not allowed in cell fragment context" : "Start tag not allowed in cell fragment context",
"unexpected-html-element-in-foreign-content" => "HTML element breaks out of SVG/MathML content",
"unexpected-end-tag-in-foreign-content" => $tagName ? "Mismatched </{$tagName}> end tag in SVG/MathML content" : "Mismatched end tag in SVG/MathML content",
"unexpected-end-tag-in-fragment-context" => $tagName ? "</{$tagName}> end tag not allowed in fragment parsing context" : "End tag not allowed in fragment parsing context",
"end-tag-too-early" => $tagName ? "</{$tagName}> end tag closed early (unclosed children)" : "End tag closed early (unclosed children)",
"adoption-agency-1.3" => "Misnested tags require adoption agency algorithm",
"non-void-html-element-start-tag-with-trailing-solidus" => $tagName ? "<{$tagName}/> self-closing syntax on non-void element" : "Self-closing syntax on non-void element",
"image-start-tag" => $tagName ? "Deprecated <{$tagName}> tag (use <img> instead)" : "Deprecated image tag",
];
return $messages[$code] ?? $code;
}
}