@@ -55,7 +55,7 @@ public function getOptions()
5555 *
5656 * The rules governing parsing are set out in the HTML 5 spec.
5757 *
58- * @param string $file
58+ * @param string|resource $file
5959 * The path to the file to parse. If this is a resource, it is
6060 * assumed to be an open stream whose pointer is set to the first
6161 * byte of input.
@@ -68,13 +68,10 @@ public function load($file, array $options = array())
6868 {
6969 // Handle the case where file is a resource.
7070 if (is_resource ($ file )) {
71- // FIXME: We need a StreamInputStream class.
72- return $ this ->loadHTML (stream_get_contents ($ file ), $ options );
71+ return $ this ->parse (stream_get_contents ($ file ), $ options );
7372 }
7473
75- $ input = new FileInputStream ($ file );
76-
77- return $ this ->parse ($ input , $ options );
74+ return $ this ->parse (file_get_contents ($ file ), $ options );
7875 }
7976
8077 /**
@@ -92,9 +89,7 @@ public function load($file, array $options = array())
9289 */
9390 public function loadHTML ($ string , array $ options = array ())
9491 {
95- $ input = new StringInputStream ($ string );
96-
97- return $ this ->parse ($ input , $ options );
92+ return $ this ->parse ($ string , $ options );
9893 }
9994
10095 /**
@@ -121,19 +116,15 @@ public function loadHTMLFile($file, array $options = array())
121116 /**
122117 * Parse a HTML fragment from a string.
123118 *
124- * @param string $string
125- * The html5 fragment as a string.
126- * @param array $options
127- * Configuration options when parsing the HTML
119+ * @param string $string The HTML5 fragment as a string.
120+ * @param array $options Configuration options when parsing the HTML
128121 *
129122 * @return \DOMDocumentFragment A DOM fragment. The DOM is part of libxml, which is included with
130123 * almost all distributions of PHP.
131124 */
132125 public function loadHTMLFragment ($ string , array $ options = array ())
133126 {
134- $ input = new StringInputStream ($ string );
135-
136- return $ this ->parseFragment ($ input , $ options );
127+ return $ this ->parseFragment ($ string , $ options );
137128 }
138129
139130 /**
@@ -162,12 +153,12 @@ public function hasErrors()
162153 * Lower-level loading function. This requires an input stream instead
163154 * of a string, file, or resource.
164155 *
165- * @param InputStream $input
156+ * @param string $input
166157 * @param array $options
167158 *
168159 * @return \DOMDocument
169160 */
170- public function parse (InputStream $ input , array $ options = array ())
161+ public function parse ($ input , array $ options = array ())
171162 {
172163 $ this ->errors = array ();
173164 $ options = array_merge ($ this ->getOptions (), $ options );
@@ -187,14 +178,12 @@ public function parse(InputStream $input, array $options = array())
187178 * Lower-level loading function. This requires an input stream instead
188179 * of a string, file, or resource.
189180 *
190- * @param InputStream $input
191- * The input data to parse in the form of a InputStream instance.
192- * @param array $options
193- * An array of options
181+ * @param string $input The input data to parse in the form of a string.
182+ * @param array $options An array of options
194183 *
195184 * @return \DOMDocumentFragment
196185 */
197- public function parseFragment (InputStream $ input , array $ options = array ())
186+ public function parseFragment ($ input , array $ options = array ())
198187 {
199188 $ options = array_merge ($ this ->getOptions (), $ options );
200189 $ events = new DOMTreeBuilder (true , $ options );
0 commit comments