Completed
Push — master ( 872339...c28159 )
by Todd
03:07
created

ganon.php (4 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 92.

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);
0 ignored issues
show
The property root cannot be accessed from this context as it is declared private in class pQuery\HtmlParser.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
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
	if (version_compare(PHP_VERSION, '5.0.0', '>='))
34
		$f = file_get_contents($file, $use_include_path, $context);
35
	else {
36
		if ($context !== null)
37
			trigger_error('Context parameter not supported in this PHP version');
38
		$f = file_get_contents($file, $use_include_path);
39
	}
40
41
	return (($f === false) ? false : str_get_dom($f, $return_root));
42
}
43
44
/**
45
 * Format/beautify DOM
46
 * @param DomNode $root
47
 * @param array $options Extra formatting options {@link Formatter::$options}
48
 * @return bool
49
 */
50
function dom_format(&$root, $options = array()) {
51
	$formatter = new HtmlFormatter($options);
52
	return $formatter->format($root);
53
}
54
55
if (version_compare(PHP_VERSION, '5.0.0', '<')) {
56
	/**
57
	 * PHP alternative to str_split, for backwards compatibility
58
	 * @param string $string
59
	 * @return string
60
	 */
61
	function str_split($string) {
62
		$res = array();
63
		$size = strlen($string);
64
		for ($i = 0; $i < $size; $i++) {
65
			$res[] = $string[$i];
66
		}
67
68
		return $res;
69
	}
70
}
71
72
if (version_compare(PHP_VERSION, '5.2.0', '<')) {
73
	/**
74
	 * PHP alternative to array_fill_keys, for backwards compatibility
75
	 * @param array $keys
76
	 * @param mixed $value
77
	 * @return array
78
	 */
79
	function array_fill_keys($keys, $value) {
80
		$res = array();
81
		foreach($keys as $k) {
82
			$res[$k] = $value;
83
		}
84
85
		return $res;
86
	}
87
}
88
89
#!! <- Ignore when converting to single file
90
if (!defined('GANON_NO_INCLUDES')) {
91
	define('GANON_NO_INCLUDES', true);
92
    include_once('IQuery.php');
93
	include_once('gan_tokenizer.php');
94
	include_once('gan_parser_html.php');
95
	include_once('gan_node_html.php');
96
	include_once('gan_selector_html.php');
97
	include_once('gan_formatter.php');
98
}
99
#!
100
101
?>
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...