@@ -108,34 +108,34 @@ discard block |
||
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
| 111 | - * Evaluate and return the result of a given XPath expression using this element as context node |
|
| 112 | - * |
|
| 113 | - * @param string $expr XPath expression |
|
| 114 | - * @return mixed |
|
| 115 | - */ |
|
| 111 | + * Evaluate and return the result of a given XPath expression using this element as context node |
|
| 112 | + * |
|
| 113 | + * @param string $expr XPath expression |
|
| 114 | + * @return mixed |
|
| 115 | + */ |
|
| 116 | 116 | public function evaluate(string $expr) |
| 117 | 117 | { |
| 118 | 118 | return $this->ownerDocument->evaluate($expr, $this); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
| 122 | - * Evaluate and return the first element of a given XPath query using this element as context node |
|
| 123 | - * |
|
| 124 | - * @param string $expr XPath expression |
|
| 125 | - * @return DOMNode|null |
|
| 126 | - */ |
|
| 122 | + * Evaluate and return the first element of a given XPath query using this element as context node |
|
| 123 | + * |
|
| 124 | + * @param string $expr XPath expression |
|
| 125 | + * @return DOMNode|null |
|
| 126 | + */ |
|
| 127 | 127 | public function firstOf(string $expr): ?DOMNode |
| 128 | 128 | { |
| 129 | 129 | return $this->ownerDocument->firstOf($expr, $this); |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
| 133 | - * Insert given element relative to this element's position |
|
| 134 | - * |
|
| 135 | - * @param string $where One of 'beforebegin', 'afterbegin', 'beforeend', 'afterend' |
|
| 136 | - * @param self $element |
|
| 137 | - * @return self |
|
| 138 | - */ |
|
| 133 | + * Insert given element relative to this element's position |
|
| 134 | + * |
|
| 135 | + * @param string $where One of 'beforebegin', 'afterbegin', 'beforeend', 'afterend' |
|
| 136 | + * @param self $element |
|
| 137 | + * @return self |
|
| 138 | + */ |
|
| 139 | 139 | public function insertAdjacentElement(string $where, self $element): self |
| 140 | 140 | { |
| 141 | 141 | $this->insertAdjacentNode($where, $element); |
@@ -144,24 +144,24 @@ discard block |
||
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
| 147 | - * Insert given text relative to this element's position |
|
| 148 | - * |
|
| 149 | - * @param string $where One of 'beforebegin', 'afterbegin', 'beforeend', 'afterend' |
|
| 150 | - * @param string $text |
|
| 151 | - * @return void |
|
| 152 | - */ |
|
| 147 | + * Insert given text relative to this element's position |
|
| 148 | + * |
|
| 149 | + * @param string $where One of 'beforebegin', 'afterbegin', 'beforeend', 'afterend' |
|
| 150 | + * @param string $text |
|
| 151 | + * @return void |
|
| 152 | + */ |
|
| 153 | 153 | public function insertAdjacentText(string $where, string $text): void |
| 154 | 154 | { |
| 155 | 155 | $this->insertText($where, $text); |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
| 159 | - * Insert given XML relative to this element's position |
|
| 160 | - * |
|
| 161 | - * @param string $where One of 'beforebegin', 'afterbegin', 'beforeend', 'afterend' |
|
| 162 | - * @param string $xml |
|
| 163 | - * @return void |
|
| 164 | - */ |
|
| 159 | + * Insert given XML relative to this element's position |
|
| 160 | + * |
|
| 161 | + * @param string $where One of 'beforebegin', 'afterbegin', 'beforeend', 'afterend' |
|
| 162 | + * @param string $xml |
|
| 163 | + * @return void |
|
| 164 | + */ |
|
| 165 | 165 | public function insertAdjacentXML(string $where, string $xml): void |
| 166 | 166 | { |
| 167 | 167 | $fragment = $this->ownerDocument->createDocumentFragment(); |
@@ -171,32 +171,32 @@ discard block |
||
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
| 174 | - * Evaluate and return the result of a given XPath query using this element as context node |
|
| 175 | - * |
|
| 176 | - * @param string $expr XPath expression |
|
| 177 | - * @return DOMNodeList |
|
| 178 | - */ |
|
| 174 | + * Evaluate and return the result of a given XPath query using this element as context node |
|
| 175 | + * |
|
| 176 | + * @param string $expr XPath expression |
|
| 177 | + * @return DOMNodeList |
|
| 178 | + */ |
|
| 179 | 179 | public function query(string $expr): DOMNodeList |
| 180 | 180 | { |
| 181 | 181 | return $this->ownerDocument->query($expr, $this); |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | /** |
| 185 | - * Remove this element from the document |
|
| 186 | - * |
|
| 187 | - * @return void |
|
| 188 | - */ |
|
| 185 | + * Remove this element from the document |
|
| 186 | + * |
|
| 187 | + * @return void |
|
| 188 | + */ |
|
| 189 | 189 | public function remove(): void |
| 190 | 190 | { |
| 191 | 191 | $this->parentOrThrow()->removeChild($this); |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | /** |
| 195 | - * Replace this element with given nodes/text |
|
| 196 | - * |
|
| 197 | - * @param DOMNode|string $nodes |
|
| 198 | - * @return void |
|
| 199 | - */ |
|
| 195 | + * Replace this element with given nodes/text |
|
| 196 | + * |
|
| 197 | + * @param DOMNode|string $nodes |
|
| 198 | + * @return void |
|
| 199 | + */ |
|
| 200 | 200 | public function replaceWith(...$nodes): void |
| 201 | 201 | { |
| 202 | 202 | $parentNode = $this->parentOrThrow(new DOMException('No Modification Allowed Error', DOM_NO_MODIFICATION_ALLOWED_ERR)); |
@@ -213,11 +213,11 @@ discard block |
||
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
| 216 | - * Add namespace declarations that may be missing in given XML |
|
| 217 | - * |
|
| 218 | - * @param string $xml Original XML |
|
| 219 | - * @return string Modified XML |
|
| 220 | - */ |
|
| 216 | + * Add namespace declarations that may be missing in given XML |
|
| 217 | + * |
|
| 218 | + * @param string $xml Original XML |
|
| 219 | + * @return string Modified XML |
|
| 220 | + */ |
|
| 221 | 221 | protected function addMissingNamespaceDeclarations(string $xml): string |
| 222 | 222 | { |
| 223 | 223 | preg_match_all('(xmlns:\\K[-\\w]++(?==))', $xml, $m); |
@@ -242,12 +242,12 @@ discard block |
||
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | /** |
| 245 | - * Insert given node relative to this element's position |
|
| 246 | - * |
|
| 247 | - * @param string $where One of 'beforebegin', 'afterbegin', 'beforeend', 'afterend' |
|
| 248 | - * @param DOMNode $node |
|
| 249 | - * @return void |
|
| 250 | - */ |
|
| 245 | + * Insert given node relative to this element's position |
|
| 246 | + * |
|
| 247 | + * @param string $where One of 'beforebegin', 'afterbegin', 'beforeend', 'afterend' |
|
| 248 | + * @param DOMNode $node |
|
| 249 | + * @return void |
|
| 250 | + */ |
|
| 251 | 251 | protected function insertAdjacentNode(string $where, DOMNode $node): void |
| 252 | 252 | { |
| 253 | 253 | $where = strtolower($where); |
@@ -274,13 +274,13 @@ discard block |
||
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | /** |
| 277 | - * Create and insert an element at given position |
|
| 278 | - * |
|
| 279 | - * @param string $where One of 'beforebegin', 'afterbegin', 'beforeend', 'afterend' |
|
| 280 | - * @param string $nodeName Element's nodeName |
|
| 281 | - * @param string $text Text content |
|
| 282 | - * @return self |
|
| 283 | - */ |
|
| 277 | + * Create and insert an element at given position |
|
| 278 | + * |
|
| 279 | + * @param string $where One of 'beforebegin', 'afterbegin', 'beforeend', 'afterend' |
|
| 280 | + * @param string $nodeName Element's nodeName |
|
| 281 | + * @param string $text Text content |
|
| 282 | + * @return self |
|
| 283 | + */ |
|
| 284 | 284 | protected function insertElement(string $where, string $nodeName, string $text): self |
| 285 | 285 | { |
| 286 | 286 | $text = htmlspecialchars($text, ENT_NOQUOTES); |
@@ -300,12 +300,12 @@ discard block |
||
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | /** |
| 303 | - * Insert given text relative to this element's position |
|
| 304 | - * |
|
| 305 | - * @param string $where One of 'beforebegin', 'afterbegin', 'beforeend', 'afterend' |
|
| 306 | - * @param string $text |
|
| 307 | - * @return DOMText |
|
| 308 | - */ |
|
| 303 | + * Insert given text relative to this element's position |
|
| 304 | + * |
|
| 305 | + * @param string $where One of 'beforebegin', 'afterbegin', 'beforeend', 'afterend' |
|
| 306 | + * @param string $text |
|
| 307 | + * @return DOMText |
|
| 308 | + */ |
|
| 309 | 309 | protected function insertText(string $where, string $text): DOMText |
| 310 | 310 | { |
| 311 | 311 | $node = $this->ownerDocument->createTextNode($text); |
@@ -315,13 +315,13 @@ discard block |
||
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | /** |
| 318 | - * Create and insert an XSL element at given position |
|
| 319 | - * |
|
| 320 | - * @param string $where One of 'beforebegin', 'afterbegin', 'beforeend', 'afterend' |
|
| 321 | - * @param string $localName Element's localName |
|
| 322 | - * @param array $arguments Arguments passed to the Document::create* function |
|
| 323 | - * @return self |
|
| 324 | - */ |
|
| 318 | + * Create and insert an XSL element at given position |
|
| 319 | + * |
|
| 320 | + * @param string $where One of 'beforebegin', 'afterbegin', 'beforeend', 'afterend' |
|
| 321 | + * @param string $localName Element's localName |
|
| 322 | + * @param array $arguments Arguments passed to the Document::create* function |
|
| 323 | + * @return self |
|
| 324 | + */ |
|
| 325 | 325 | protected function insertXslElement(string $where, string $localName, array $arguments): self |
| 326 | 326 | { |
| 327 | 327 | $callback = [$this->ownerDocument, 'createXsl' . ucfirst($localName)]; |
@@ -336,11 +336,11 @@ discard block |
||
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | /** |
| 339 | - * Return this element's parent element if available, or throw an exception |
|
| 340 | - * |
|
| 341 | - * @param DOMException $previous Previous exception |
|
| 342 | - * @return DOMNode |
|
| 343 | - */ |
|
| 339 | + * Return this element's parent element if available, or throw an exception |
|
| 340 | + * |
|
| 341 | + * @param DOMException $previous Previous exception |
|
| 342 | + * @return DOMNode |
|
| 343 | + */ |
|
| 344 | 344 | protected function parentOrThrow(DOMException $previous = null): DOMNode |
| 345 | 345 | { |
| 346 | 346 | if (isset($this->parentNode)) |