These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | class SS_HTML5Value extends SS_HTMLValue { |
||
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
4 | |||
5 | public function setContent($content) { |
||
6 | require_once(HTML5LIB_PATH.'/HTML5/Parser.php'); |
||
7 | |||
8 | // Convert any errors to exceptions |
||
9 | set_error_handler( |
||
10 | function($no, $str){ |
||
11 | throw new Exception("HTML Parse Error: ".$str); |
||
12 | }, |
||
13 | error_reporting() |
||
14 | ); |
||
15 | |||
16 | // Use HTML5lib to parse the HTML fragment |
||
17 | try { |
||
18 | $document = HTML5_Parser::parse( |
||
19 | '<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head>'. |
||
20 | "<body>$content</body></html>" |
||
21 | ); |
||
22 | } |
||
23 | catch (Exception $e) { |
||
24 | $document = false; |
||
25 | } |
||
26 | |||
27 | // Disable our error handler (restoring to previous value) |
||
28 | restore_error_handler(); |
||
29 | |||
30 | // If we couldn't parse the HTML, set the error state |
||
31 | if ($document) $this->setDocument($document); |
||
32 | else $this->setInvalid(); |
||
33 | } |
||
34 | |||
35 | } |
||
0 ignored issues
–
show
According to PSR2, the closing brace of classes should be placed on the next line directly after the body.
Below you find some examples: // Incorrect placement according to PSR2
class MyClass
{
public function foo()
{
}
// This blank line is not allowed.
}
// Correct
class MyClass
{
public function foo()
{
} // No blank lines after this line.
}
Loading history...
|