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
* The previous fix (substituting a stdClass for an empty rels array) was causing looping problems, so there is now a “JSON mode” into which the parser can be put either by passing true as the third constructor parameter or by setting jsonMode = true. By default an empty rels key will be an array, but if JSON mode is set it will be an empty stdClass, ensuringcorrect serialisation.
* The tests have been updated accordingly
* A missing value property from one test has been added
Copy file name to clipboardExpand all lines: Mf2/Parser.php
+18-1
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,7 @@
9
9
useDOMNodeList;
10
10
useException;
11
11
useSplObjectStorage;
12
+
usestdClass;
12
13
13
14
/**
14
15
* Parse Microformats2
@@ -163,14 +164,17 @@ class Parser {
163
164
164
165
/** @var SplObjectStorage */
165
166
protected$parsed;
167
+
168
+
public$jsonMode;
166
169
167
170
/**
168
171
* Constructor
169
172
*
170
173
* @param DOMDocument|string $input The data to parse. A string of HTML or a DOMDocument
171
174
* @param string $url The URL of the parsed document, for relative URL resolution
175
+
* @param boolean $jsonMode Whether or not to use a stdClass instance for an empty `rels` dictionary. This breaks PHP looping over rels, but allows the output to be correctly serialized as JSON.
0 commit comments