You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/Reader.php
+15-2Lines changed: 15 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -87,9 +87,13 @@ function parse() {
87
87
*
88
88
* If there's both text and sub-elements, the text will be discarded.
89
89
*
90
+
* If the $elementMap argument is specified, the existing elementMap will
91
+
* be overridden while parsing the tree, and restored after this process.
92
+
*
93
+
* @param array $elementMap
90
94
* @return array|string
91
95
*/
92
-
functionparseInnerTree() {
96
+
functionparseInnerTree(array$elementMap = null) {
93
97
94
98
$previousDepth = $this->depth;
95
99
@@ -103,6 +107,12 @@ function parseInnerTree() {
103
107
returnnull;
104
108
}
105
109
110
+
if (!is_null($elementMap)) {
111
+
$this->pushContext();
112
+
$this->elementMap = $elementMap;
113
+
}
114
+
115
+
106
116
// Really sorry about the silence operator, seems like I have no
107
117
// choice. See:
108
118
//
@@ -125,7 +135,7 @@ function parseInnerTree() {
125
135
$this->read();
126
136
break2;
127
137
caseself::NONE :
128
-
thrownewParseException('We hit the end of the document prematurely. This likely means that some parser "eats" too many elements.');
138
+
thrownewParseException('We hit the end of the document prematurely. This likely means that some parser "eats" too many elements. Do not attempt to continue parsing.');
0 commit comments