Completed
Pull Request — master (#16)
by
unknown
10:12
created

ganon.php (3 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 19 and the first side effect is on line 51.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * @author Niels A.D.
4
 * @author Todd Burry <[email protected]>
5
 * @copyright 2010 Niels A.D., 2014 Todd Burry
6
 * @license http://opensource.org/licenses/LGPL-2.1 LGPL-2.1
7
 * @package pQuery
8
 */
9
10
use pQuery\Html5Parser;
11
use pQuery\HtmlFormatter;
12
13
/**
14
 * Returns HTML DOM from string
15
 * @param string $str
16
 * @param bool $return_root Return root node or return parser object
17
 * @return Html5Parser|DomNode
18
 */
19
function str_get_dom($str, $return_root = true) {
20
	$a = new Html5Parser($str);
21
	return (($return_root) ? $a->root : $a);
22
}
23
24
/**
25
 * Returns HTML DOM from file/website
26
 * @param string $str
0 ignored issues
show
There is no parameter named $str. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
27
 * @param bool $return_root Return root node or return parser object
28
 * @param bool $use_include_path Use include path search in file_get_contents
29
 * @param resource $context Context resource used in file_get_contents (PHP >= 5.0.0)
30
 * @return Html5Parser|DomNode
31
 */
32
function file_get_dom($file, $return_root = true, $use_include_path = false, $context = null) {
33
	$f = file_get_contents($file, $use_include_path, $context);
34
	return (($f === false) ? false : str_get_dom($f, $return_root));
35
}
36
37
/**
38
 * Format/beautify DOM
39
 * @param DomNode $root
40
 * @param array $options Extra formatting options {@link Formatter::$options}
41
 * @return bool
42
 */
43
function dom_format(&$root, $options = array()) {
44
	$formatter = new HtmlFormatter($options);
45
	return $formatter->format($root);
46
}
47
48
#!! <- Ignore when converting to single file
49
if (!defined('GANON_NO_INCLUDES')) {
50
	define('GANON_NO_INCLUDES', true);
51
    include_once('IQuery.php');
52
	include_once('gan_tokenizer.php');
53
	include_once('gan_parser_html.php');
54
	include_once('gan_node_html.php');
55
	include_once('gan_selector_html.php');
56
	include_once('gan_formatter.php');
57
}
58
#!
59
60
?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...