| @@ -6,14 +6,14 @@ | ||
| 6 | 6 | * @license http://opensource.org/licenses/LGPL-2.1 LGPL-2.1 |
| 7 | 7 | * @package pQuery |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -use pQuery\IQuery; | |
| 10 | +use pagelayerQuery\IQuery; | |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * A jQuery-like object for php. |
| 14 | 14 | */ |
| 15 | -class pQuery implements ArrayAccess, IteratorAggregate, IQuery { | |
| 15 | +class pagelayerQuery implements ArrayAccess, IteratorAggregate, IQuery { | |
| 16 | 16 | /// Properties /// |
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * @var IQuery[] |
| @@ -53,8 +53,10 @@ | ||
| 53 | 53 | |
| 54 | 54 | foreach ($this->nodes as $node) { |
| 55 | 55 | if ($value === null) |
| 56 | 56 | return $node->attr($name); |
| 57 | + $value = str_replace('<', '<', $value); | |
| 58 | + $value = str_replace('>', '>', $value); | |
| 57 | 59 | $node->attr($name, $value); |
| 58 | 60 | } |
| 59 | 61 | return $this; |
| 60 | 62 | } |
| @@ -77,8 +79,10 @@ | ||
| 77 | 79 | * Get the count of matched elements. |
| 78 | 80 | * |
| 79 | 81 | * @return int Returns the count of matched elements. |
| 80 | 82 | */ |
| 83 | + | |
| 84 | + #[\ReturnTypeWillChange] | |
| 81 | 85 | public function count() { |
| 82 | 86 | return count($this->nodes); |
| 83 | 87 | } |
| 84 | 88 | |
| @@ -84,17 +88,18 @@ | ||
| 84 | 88 | |
| 85 | 89 | /** |
| 86 | 90 | * Format/beautify a DOM. |
| 87 | 91 | * |
| 88 | - * @param pQuery\DomNode $dom The dom to format. | |
| 89 | - * @param array $options Extra formatting options. See {@link pQuery\HtmlFormatter::$options}. | |
| 92 | + * @param pagelayerQuery\DomNode $dom The dom to format. | |
| 93 | + * @param array $options Extra formatting options. See {@link pagelayerQuery\HtmlFormatter::$options}. | |
| 90 | 94 | * @return bool Returns `true` on sucess and `false` on failure. |
| 91 | 95 | */ |
| 92 | 96 | // public static function format($dom, $options = array()) { |
| 93 | -// $formatter = new pQuery\HtmlFormatter($options); | |
| 97 | +// $formatter = new pagelayerQuery\HtmlFormatter($options); | |
| 94 | 98 | // return $formatter->format($dom); |
| 95 | 99 | // } |
| 96 | 100 | |
| 101 | + #[\ReturnTypeWillChange] | |
| 97 | 102 | public function getIterator() { |
| 98 | 103 | return new ArrayIterator($this->nodes); |
| 99 | 104 | } |
| 100 | 105 | |
| @@ -116,17 +121,20 @@ | ||
| 116 | 121 | $node->html($value); |
| 117 | 122 | } |
| 118 | 123 | return $this; |
| 119 | 124 | } |
| 120 | - | |
| 121 | - public function offsetExists($offset) { | |
| 125 | + | |
| 126 | + #[\ReturnTypeWillChange] | |
| 127 | + public function offsetExists($offset){ | |
| 122 | 128 | return isset($this->nodes[$offset]); |
| 123 | 129 | } |
| 124 | - | |
| 130 | + | |
| 131 | + #[\ReturnTypeWillChange] | |
| 125 | 132 | public function offsetGet($offset) { |
| 126 | 133 | return isset($this->nodes[$offset]) ? $this->nodes[$offset] : null; |
| 127 | 134 | } |
| 128 | - | |
| 135 | + | |
| 136 | + #[\ReturnTypeWillChange] | |
| 129 | 137 | public function offsetSet($offset, $value) { |
| 130 | 138 | |
| 131 | 139 | if (is_null($offset) || !isset($this->nodes[$offset])) { |
| 132 | 140 | throw new \BadMethodCallException("You are not allowed to add new nodes to the pQuery object."); |
| @@ -133,9 +141,10 @@ | ||
| 133 | 141 | } else { |
| 134 | 142 | $this->nodes[$offset]->replaceWith($value); |
| 135 | 143 | } |
| 136 | 144 | } |
| 137 | - | |
| 145 | + | |
| 146 | + #[\ReturnTypeWillChange] | |
| 138 | 147 | public function offsetUnset($offset) { |
| 139 | 148 | if (isset($this->nodes[$offset])) { |
| 140 | 149 | $this->nodes[$offset]->remove(); |
| 141 | 150 | unset($this->nodes[$offset]); |
| @@ -146,9 +155,9 @@ | ||
| 146 | 155 | * Query a file or url. |
| 147 | 156 | * |
| 148 | 157 | * @param string $path The path to the url. |
| 149 | 158 | * @param resource $context A context suitable to be passed into {@link file_get_contents} |
| 150 | - * @return pQuery\DomNode Returns the root dom node for the html file. | |
| 159 | + * @return pagelayerQuery\DomNode Returns the root dom node for the html file. | |
| 151 | 160 | */ |
| 152 | 161 | public static function parseFile($path, $context = null) { |
| 153 | 162 | $html_str = file_get_contents($path, false, $context); |
| 154 | 163 | return static::parseStr($html_str); |
| @@ -157,12 +166,12 @@ | ||
| 157 | 166 | /** |
| 158 | 167 | * Query a string of html. |
| 159 | 168 | * |
| 160 | 169 | * @param string $html |
| 161 | - * @return pQuery\DomNode Returns the root dom node for the html string. | |
| 170 | + * @return pagelayerQuery\DomNode Returns the root dom node for the html string. | |
| 162 | 171 | */ |
| 163 | 172 | public static function parseStr($html) { |
| 164 | - $parser = new pQuery\Html5Parser($html); | |
| 173 | + $parser = new pagelayerQuery\Html5Parser($html); | |
| 165 | 174 | return $parser->root; |
| 166 | 175 | } |
| 167 | 176 | |
| 168 | 177 | public function prepend($content = null) { |