summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/HTML5.php16
-rw-r--r--test/HTML5/ParserTest.php17
-rw-r--r--test/HTML5/Serializer/TraverserTest.php6
3 files changed, 11 insertions, 28 deletions
diff --git a/src/HTML5.php b/src/HTML5.php
index 23948b3..9407e84 100644
--- a/src/HTML5.php
+++ b/src/HTML5.php
@@ -38,16 +38,16 @@ class HTML5 {
* A DOM document. These object type is defined by the libxml
* library, and should have been included with your version of PHP.
*/
- public function load($file, $options = NULL) {
+ public static function load($file, $options = NULL) {
// Handle the case where file is a resource.
if (is_resource($file)) {
// FIXME: We need a StreamInputStream class.
- return $this->loadHTML(stream_get_contents($file));
+ return self::loadHTML(stream_get_contents($file));
}
$input = new FileInputStream($file);
- return $this->parse($input);
+ return self::parse($input);
}
/**
@@ -63,9 +63,9 @@ class HTML5 {
* A DOM document. DOM is part of libxml, which is included with
* almost all distribtions of PHP.
*/
- public function loadHTML($string, $options = NULL) {
+ public static function loadHTML($string, $options = NULL) {
$input = new StringInputStream($string);
- return $this->parse($input);
+ return self::parse($input);
}
/**
@@ -74,8 +74,8 @@ class HTML5 {
* This is here to provide backwards compatibility with the
* PHP DOM implementation. It simply calls load().
*/
- public function loadHTMLFile($file, $options = NULL) {
- return $this->load($file, $options);
+ public static function loadHTMLFile($file, $options = NULL) {
+ return self::load($file, $options);
}
/**
@@ -97,7 +97,7 @@ class HTML5 {
/**
* Parse an input stream.
*/
- protected function parse($input) {
+ public static function parse($input) {
$events = new DOMTreeBuilder();
$scanner = new Scanner($input);
$parser = new Tokenizer($scanner, $events);
diff --git a/test/HTML5/ParserTest.php b/test/HTML5/ParserTest.php
deleted file mode 100644
index 7f36237..0000000
--- a/test/HTML5/ParserTest.php
+++ /dev/null
@@ -1,17 +0,0 @@
-<?php
-namespace HTML5\Tests;
-
-use \HTML5\Parser;
-
-require_once 'TestCase.php';
-
-class ParserTest extends TestCase {
- public function testParse() {
- $result = Parser::parse('<html><body></body></html>');
- $this->assertTrue($result instanceof \DOMDocument);
- }
- public function testParseFragment() {
- $result = Parser::parseFragment('<b>asdf</b> foo');
- $this->assertTrue($result instanceof \DOMNodeList);
- }
-}
diff --git a/test/HTML5/Serializer/TraverserTest.php b/test/HTML5/Serializer/TraverserTest.php
index 83302f0..1a17af3 100644
--- a/test/HTML5/Serializer/TraverserTest.php
+++ b/test/HTML5/Serializer/TraverserTest.php
@@ -39,7 +39,7 @@ class TraverserTest extends \HTML5\Tests\TestCase {
function getTraverser() {
$stream = fopen('php://temp', 'w');
- $dom = \HTML5::parse($this->markup);
+ $dom = \HTML5::loadHTML($this->markup);
$t = new Traverser($dom, $stream);
// We return both the traverser and stream so we can pull from it.
@@ -52,7 +52,7 @@ class TraverserTest extends \HTML5\Tests\TestCase {
// use a stream in temp space.
$stream = fopen('php://temp', 'w');
- $dom = \HTML5::parse($this->markup);
+ $dom = \HTML5::loadHTML($this->markup);
$t = new Traverser($dom, $stream);
@@ -76,7 +76,7 @@ class TraverserTest extends \HTML5\Tests\TestCase {
}
function testText() {
- $dom = \HTML5::parse('<!doctype html>
+ $dom = \HTML5::loadHTML('<!doctype html>
<html lang="en">
<head>
<script>baz();</script>