@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | /** |
| 27 | 27 | * |
| 28 | 28 | */ |
| 29 | -class Document extends DOMDocument{ |
|
| 29 | +class Document extends DOMDocument { |
|
| 30 | 30 | |
| 31 | 31 | protected const NODE_CLASSES = [ |
| 32 | 32 | 'DOMAttr' => Attr::class, |
@@ -51,14 +51,14 @@ discard block |
||
| 51 | 51 | /** |
| 52 | 52 | * Document constructor. |
| 53 | 53 | */ |
| 54 | - public function __construct($content = null, bool $xml = null, string $version = null, string $encoding = null){ |
|
| 54 | + public function __construct($content = null, bool $xml = null, string $version = null, string $encoding = null) { |
|
| 55 | 55 | parent::__construct($version ?? '1.0', $encoding ?? 'UTF-8'); |
| 56 | 56 | |
| 57 | - foreach($this::NODE_CLASSES as $baseClass => $extendedClass){ |
|
| 57 | + foreach ($this::NODE_CLASSES as $baseClass => $extendedClass) { |
|
| 58 | 58 | $this->registerNodeClass($baseClass, $extendedClass); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - if($content !== null){ |
|
| 61 | + if ($content !== null) { |
|
| 62 | 62 | $this->loadDocument($content, $xml); |
| 63 | 63 | } |
| 64 | 64 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | /** |
| 73 | 73 | * @return string|null |
| 74 | 74 | */ |
| 75 | - public function getTitle():?string{ |
|
| 75 | + public function getTitle(): ?string{ |
|
| 76 | 76 | return $this->select(['head > title'])->item(0)->nodeValue ?? null; |
| 77 | 77 | } |
| 78 | 78 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | public function setTitle(string $title):void{ |
| 83 | 83 | $currentTitle = $this->select(['head > title'])->item(0); |
| 84 | 84 | |
| 85 | - if($currentTitle instanceof Element){ |
|
| 85 | + if ($currentTitle instanceof Element) { |
|
| 86 | 86 | $currentTitle->update($title); |
| 87 | 87 | |
| 88 | 88 | return; |
@@ -91,10 +91,10 @@ discard block |
||
| 91 | 91 | $head = $this->select(['head'])->item(0); |
| 92 | 92 | $currentTitle = $this->newElement('title')->update($title); |
| 93 | 93 | |
| 94 | - if(!$head){ |
|
| 94 | + if (!$head) { |
|
| 95 | 95 | $html = $this->select(['html'])->first(); |
| 96 | 96 | |
| 97 | - if(!$html instanceof PrototypeHTMLElement){ |
|
| 97 | + if (!$html instanceof PrototypeHTMLElement) { |
|
| 98 | 98 | throw new DOMException('html header missing'); |
| 99 | 99 | } |
| 100 | 100 | |
@@ -114,19 +114,19 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | public function loadDocument($content, bool $xml = null):Document{ |
| 116 | 116 | |
| 117 | - if($content instanceof NodeList){ |
|
| 117 | + if ($content instanceof NodeList) { |
|
| 118 | 118 | return $this->insertNodeList($content); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - if($content instanceof DOMNodeList){ |
|
| 121 | + if ($content instanceof DOMNodeList) { |
|
| 122 | 122 | return $this->insertNodeList(new NodeList($content)); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - if(!is_string($content)){ |
|
| 125 | + if (!is_string($content)) { |
|
| 126 | 126 | throw new DOMException('invalid document content'); |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - if(is_file($content) && is_readable($content)){ |
|
| 129 | + if (is_file($content) && is_readable($content)) { |
|
| 130 | 130 | return $this->loadDocumentFile($content, $xml); |
| 131 | 131 | } |
| 132 | 132 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | ? $this->load($file, $options) |
| 144 | 144 | : $this->loadHTMLFile($file, $options); |
| 145 | 145 | |
| 146 | - if($result === false){ |
|
| 146 | + if ($result === false) { |
|
| 147 | 147 | throw new DOMException('failed to load document from file: '.$file); // @codeCoverageIgnore |
| 148 | 148 | } |
| 149 | 149 | |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | ? $this->loadXML($documentSource, $options) |
| 161 | 161 | : $this->loadHTML($documentSource, $options); |
| 162 | 162 | |
| 163 | - if($result === false){ |
|
| 163 | + if ($result === false) { |
|
| 164 | 164 | throw new DOMException('failed to load document from string'); // @codeCoverageIgnore |
| 165 | 165 | } |
| 166 | 166 | |
@@ -172,19 +172,19 @@ discard block |
||
| 172 | 172 | */ |
| 173 | 173 | public function toNodeList($content):NodeList{ |
| 174 | 174 | |
| 175 | - if($content instanceof NodeList){ |
|
| 175 | + if ($content instanceof NodeList) { |
|
| 176 | 176 | return $content; |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - if($content instanceof DOMNode || $content instanceof PrototypeNode){ |
|
| 179 | + if ($content instanceof DOMNode || $content instanceof PrototypeNode) { |
|
| 180 | 180 | return new NodeList([$content]); |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - if($content instanceof DOMNodeList || is_iterable($content)){ |
|
| 183 | + if ($content instanceof DOMNodeList || is_iterable($content)) { |
|
| 184 | 184 | return new NodeList($content); |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - if(is_string($content)){ |
|
| 187 | + if (is_string($content)) { |
|
| 188 | 188 | $document = new self; |
| 189 | 189 | $document->loadHTML('<html lang="en"><body id="-import-content">'.$content.'</body></html>'); |
| 190 | 190 | |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | /** |
| 209 | 209 | * |
| 210 | 210 | */ |
| 211 | - public function query(string $xpath, DOMNode $contextNode = null):?NodeList{ |
|
| 211 | + public function query(string $xpath, DOMNode $contextNode = null): ?NodeList{ |
|
| 212 | 212 | $q = (new DOMXPath($this))->query($xpath, $contextNode); |
| 213 | 213 | |
| 214 | 214 | return $q !== false ? new NodeList($q) : null; |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | /** |
| 218 | 218 | * |
| 219 | 219 | */ |
| 220 | - public function querySelectorAll(string $selector, DOMNode $contextNode = null, string $axis = null):?NodeList{ |
|
| 220 | + public function querySelectorAll(string $selector, DOMNode $contextNode = null, string $axis = null): ?NodeList{ |
|
| 221 | 221 | return $this->query($this->cssSelectorConverter->toXPath($selector, $axis ?? 'descendant-or-self::'), $contextNode); |
| 222 | 222 | } |
| 223 | 223 | |
@@ -227,9 +227,9 @@ discard block |
||
| 227 | 227 | public function removeElementsBySelector(array $selectors, DOMNode $contextNode = null, string $axis = null):Document{ |
| 228 | 228 | $nodes = $this->select($selectors, $contextNode, $axis ?? 'descendant-or-self::'); |
| 229 | 229 | |
| 230 | - if(count($nodes) > 0){ |
|
| 230 | + if (count($nodes) > 0) { |
|
| 231 | 231 | |
| 232 | - foreach($nodes as $node){ |
|
| 232 | + foreach ($nodes as $node) { |
|
| 233 | 233 | $node->remove(); |
| 234 | 234 | } |
| 235 | 235 | |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | */ |
| 244 | 244 | public function insertNodeList(NodeList $nodeList):Document{ |
| 245 | 245 | |
| 246 | - foreach($nodeList as $node){ |
|
| 246 | + foreach ($nodeList as $node) { |
|
| 247 | 247 | $this->appendChild($this->importNode($node->cloneNode(true), true)); |
| 248 | 248 | } |
| 249 | 249 | |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | */ |
| 260 | 260 | public function inspect(DOMNode $context = null, bool $xml = null):string{ |
| 261 | 261 | |
| 262 | - if($xml === true){ |
|
| 262 | + if ($xml === true) { |
|
| 263 | 263 | return $this->saveXML($context); |
| 264 | 264 | } |
| 265 | 265 | |
@@ -274,15 +274,15 @@ discard block |
||
| 274 | 274 | $nodeType = $nodeType ?? XML_ELEMENT_NODE; |
| 275 | 275 | $elements = new NodeList; |
| 276 | 276 | |
| 277 | - foreach($selectors ?? ['*'] as $selector){ |
|
| 277 | + foreach ($selectors ?? ['*'] as $selector) { |
|
| 278 | 278 | |
| 279 | - if(!is_string($selector)){ |
|
| 279 | + if (!is_string($selector)) { |
|
| 280 | 280 | continue; |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - foreach($this->querySelectorAll($selector, $contextNode, $axis ?? 'descendant-or-self::') as $element){ |
|
| 283 | + foreach ($this->querySelectorAll($selector, $contextNode, $axis ?? 'descendant-or-self::') as $element) { |
|
| 284 | 284 | |
| 285 | - if($element->nodeType === $nodeType){ |
|
| 285 | + if ($element->nodeType === $nodeType) { |
|
| 286 | 286 | $elements[] = $element; |
| 287 | 287 | } |
| 288 | 288 | |
@@ -302,15 +302,15 @@ discard block |
||
| 302 | 302 | $maxLength = $maxLength ?? -1; |
| 303 | 303 | $nodes = new NodeList; |
| 304 | 304 | |
| 305 | - if(in_array($property, ['parentNode', 'previousSibling', 'nextSibling'])){ |
|
| 305 | + if (in_array($property, ['parentNode', 'previousSibling', 'nextSibling'])) { |
|
| 306 | 306 | |
| 307 | - while($element = $element->{$property}){ |
|
| 307 | + while ($element = $element->{$property}) { |
|
| 308 | 308 | |
| 309 | - if($element->nodeType === $nodeType){ |
|
| 309 | + if ($element->nodeType === $nodeType) { |
|
| 310 | 310 | $nodes[] = $element; |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | - if(count($nodes) === $maxLength){ |
|
| 313 | + if (count($nodes) === $maxLength) { |
|
| 314 | 314 | break; |
| 315 | 315 | } |
| 316 | 316 | |
@@ -324,15 +324,15 @@ discard block |
||
| 324 | 324 | /** |
| 325 | 325 | * @see https://secure.php.net/manual/dom.constants.php |
| 326 | 326 | */ |
| 327 | - public function recursivelyFind(PrototypeNode $element, string $property = null, string $selector = null, int $index = null, int $nodeType = null):?DOMNode{ |
|
| 327 | + public function recursivelyFind(PrototypeNode $element, string $property = null, string $selector = null, int $index = null, int $nodeType = null): ?DOMNode{ |
|
| 328 | 328 | $nodeType = $nodeType ?? XML_ELEMENT_NODE; |
| 329 | 329 | $index = $index ?? 0; |
| 330 | 330 | |
| 331 | - if(in_array($property, ['parentNode', 'previousSibling', 'nextSibling'])){ |
|
| 331 | + if (in_array($property, ['parentNode', 'previousSibling', 'nextSibling'])) { |
|
| 332 | 332 | |
| 333 | - while($element = $element->{$property}){ |
|
| 333 | + while ($element = $element->{$property}) { |
|
| 334 | 334 | |
| 335 | - if($element->nodeType !== $nodeType || $selector !== null && !$element->match($selector) || --$index >= 0){ |
|
| 335 | + if ($element->nodeType !== $nodeType || $selector !== null && !$element->match($selector) || --$index >= 0) { |
|
| 336 | 336 | continue; |
| 337 | 337 | } |
| 338 | 338 | |
@@ -349,9 +349,9 @@ discard block |
||
| 349 | 349 | */ |
| 350 | 350 | public function match(DOMNode $element, string $selector):bool{ |
| 351 | 351 | |
| 352 | - foreach($this->select([$selector]) as $match){ |
|
| 352 | + foreach ($this->select([$selector]) as $match) { |
|
| 353 | 353 | |
| 354 | - if($element->isSameNode($match)){ |
|
| 354 | + if ($element->isSameNode($match)) { |
|
| 355 | 355 | return true; |
| 356 | 356 | } |
| 357 | 357 | |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | /** @var \chillerlan\PrototypeDOM\Node\PrototypeHTMLElement $element */ |
| 368 | 368 | $element = $this->createElement($tag); |
| 369 | 369 | |
| 370 | - if($attributes !== null){ |
|
| 370 | + if ($attributes !== null) { |
|
| 371 | 371 | $element->setAttributes($attributes); |
| 372 | 372 | } |
| 373 | 373 | |
@@ -380,9 +380,9 @@ discard block |
||
| 380 | 380 | * @return \chillerlan\PrototypeDOM\Node\PrototypeHTMLElement|\DOMNode|null |
| 381 | 381 | * @throws \DOMException |
| 382 | 382 | */ |
| 383 | - public function getElementById($elementId):?DOMNode{ |
|
| 383 | + public function getElementById($elementId): ?DOMNode{ |
|
| 384 | 384 | |
| 385 | - if(!is_string($elementId)){ |
|
| 385 | + if (!is_string($elementId)) { |
|
| 386 | 386 | throw new DOMException('invalid element id'); |
| 387 | 387 | } |
| 388 | 388 | |
@@ -28,17 +28,17 @@ discard block |
||
| 28 | 28 | /** |
| 29 | 29 | * NodeList constructor. |
| 30 | 30 | */ |
| 31 | - public function __construct(iterable $nodes = null){ |
|
| 31 | + public function __construct(iterable $nodes = null) { |
|
| 32 | 32 | |
| 33 | - if($nodes instanceof DOMNodeList){ |
|
| 33 | + if ($nodes instanceof DOMNodeList) { |
|
| 34 | 34 | $this->array = iterator_to_array($nodes); |
| 35 | 35 | } |
| 36 | - elseif($nodes instanceof NodeList){ |
|
| 36 | + elseif ($nodes instanceof NodeList) { |
|
| 37 | 37 | $this->array = $nodes->toArray(); |
| 38 | 38 | } |
| 39 | - elseif(is_iterable($nodes)){ |
|
| 40 | - foreach($nodes as $node){ |
|
| 41 | - if($node instanceof DOMNode || $node instanceof PrototypeNode){ |
|
| 39 | + elseif (is_iterable($nodes)) { |
|
| 40 | + foreach ($nodes as $node) { |
|
| 41 | + if ($node instanceof DOMNode || $node instanceof PrototypeNode) { |
|
| 42 | 42 | $this->array[] = $node; |
| 43 | 43 | } |
| 44 | 44 | } |
@@ -56,9 +56,9 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | public function match(DOMNode $node):bool{ |
| 58 | 58 | /** @var \chillerlan\PrototypeDOM\Node\Element $element */ |
| 59 | - foreach($this->array as $element){ |
|
| 59 | + foreach ($this->array as $element) { |
|
| 60 | 60 | |
| 61 | - if($element->isSameNode($node)){ |
|
| 61 | + if ($element->isSameNode($node)) { |
|
| 62 | 62 | return true; |
| 63 | 63 | } |
| 64 | 64 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | /** |
| 87 | 87 | * @return \DOMNode|\chillerlan\PrototypeDOM\Node\PrototypeHTMLElement|null |
| 88 | 88 | */ |
| 89 | - public function item(int $offset):?DOMNode{ |
|
| 89 | + public function item(int $offset): ?DOMNode{ |
|
| 90 | 90 | return $this->offsetGet($offset); |
| 91 | 91 | } |
| 92 | 92 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * @inheritdoc |
| 112 | 112 | * @return \DOMNode|\chillerlan\PrototypeDOM\Node\PrototypeHTMLElement|null |
| 113 | 113 | */ |
| 114 | - public function current():?DOMNode{ |
|
| 114 | + public function current(): ?DOMNode{ |
|
| 115 | 115 | return $this->array[$this->offset] ?? null; |
| 116 | 116 | } |
| 117 | 117 | |
@@ -158,9 +158,9 @@ discard block |
||
| 158 | 158 | public function seek($pos):void{ |
| 159 | 159 | $this->rewind(); |
| 160 | 160 | |
| 161 | - for( ; $this->offset < $pos; ){ |
|
| 161 | + for (; $this->offset < $pos;) { |
|
| 162 | 162 | |
| 163 | - if(!\next($this->array)) { |
|
| 163 | + if (!\next($this->array)) { |
|
| 164 | 164 | throw new OutOfBoundsException('invalid seek position: '.$pos); |
| 165 | 165 | } |
| 166 | 166 | |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | * @inheritdoc |
| 187 | 187 | * @return \DOMNode|\chillerlan\PrototypeDOM\Node\PrototypeHTMLElement|null |
| 188 | 188 | */ |
| 189 | - public function offsetGet($offset):?DOMNode{ |
|
| 189 | + public function offsetGet($offset): ?DOMNode{ |
|
| 190 | 190 | return $this->array[$offset] ?? null; |
| 191 | 191 | } |
| 192 | 192 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | */ |
| 197 | 197 | public function offsetSet($offset, $value):void{ |
| 198 | 198 | |
| 199 | - if($value instanceof DOMNode){ |
|
| 199 | + if ($value instanceof DOMNode) { |
|
| 200 | 200 | |
| 201 | 201 | is_int($offset) |
| 202 | 202 | ? $this->array[$offset] = $value |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | * @inheritDoc |
| 223 | 223 | * @return \DOMNode|\chillerlan\PrototypeDOM\Node\PrototypeHTMLElement|null |
| 224 | 224 | */ |
| 225 | - public function first():?DOMNode{ |
|
| 225 | + public function first(): ?DOMNode{ |
|
| 226 | 226 | return $this->array[0] ?? null; |
| 227 | 227 | } |
| 228 | 228 | |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | * @inheritDoc |
| 231 | 231 | * @return \DOMNode|\chillerlan\PrototypeDOM\Node\PrototypeHTMLElement|null |
| 232 | 232 | */ |
| 233 | - public function last():?DOMNode{ |
|
| 233 | + public function last(): ?DOMNode{ |
|
| 234 | 234 | return $this->array[count($this->array) - 1] ?? null; |
| 235 | 235 | } |
| 236 | 236 | |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | /** |
| 262 | 262 | * @inheritDoc |
| 263 | 263 | */ |
| 264 | - public function each($callback){ |
|
| 264 | + public function each($callback) { |
|
| 265 | 265 | $this->map($callback); |
| 266 | 266 | |
| 267 | 267 | return $this; |
@@ -272,13 +272,13 @@ discard block |
||
| 272 | 272 | */ |
| 273 | 273 | public function map($callback):array { |
| 274 | 274 | |
| 275 | - if(!is_callable($callback)){ |
|
| 275 | + if (!is_callable($callback)) { |
|
| 276 | 276 | throw new Exception('invalid callback'); |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | $return = []; |
| 280 | 280 | |
| 281 | - foreach($this->array as $index => $element){ |
|
| 281 | + foreach ($this->array as $index => $element) { |
|
| 282 | 282 | $return[$index] = call_user_func_array($callback, [$element, $index]); |
| 283 | 283 | } |
| 284 | 284 | |
@@ -301,15 +301,15 @@ discard block |
||
| 301 | 301 | */ |
| 302 | 302 | public function findAll($callback):array{ |
| 303 | 303 | |
| 304 | - if(!is_callable($callback)){ |
|
| 304 | + if (!is_callable($callback)) { |
|
| 305 | 305 | throw new Exception('invalid callback'); |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | $return = []; |
| 309 | 309 | |
| 310 | - foreach($this->array as $index => $element){ |
|
| 310 | + foreach ($this->array as $index => $element) { |
|
| 311 | 311 | |
| 312 | - if(call_user_func_array($callback, [$element, $index]) === true){ |
|
| 312 | + if (call_user_func_array($callback, [$element, $index]) === true) { |
|
| 313 | 313 | $return[] = $element; |
| 314 | 314 | } |
| 315 | 315 | |
@@ -324,15 +324,15 @@ discard block |
||
| 324 | 324 | */ |
| 325 | 325 | public function reject($callback):array{ |
| 326 | 326 | |
| 327 | - if(!is_callable($callback)){ |
|
| 327 | + if (!is_callable($callback)) { |
|
| 328 | 328 | throw new Exception('invalid callback'); |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | $return = []; |
| 332 | 332 | |
| 333 | - foreach($this->array as $index => $element){ |
|
| 333 | + foreach ($this->array as $index => $element) { |
|
| 334 | 334 | |
| 335 | - if(call_user_func_array($callback, [$element, $index]) !== true){ |
|
| 335 | + if (call_user_func_array($callback, [$element, $index]) !== true) { |
|
| 336 | 336 | $return[] = $element; |
| 337 | 337 | } |
| 338 | 338 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | /** |
| 26 | 26 | * @property \chillerlan\PrototypeDOM\Document $ownerDocument |
| 27 | 27 | */ |
| 28 | -trait PrototypeTraversalTrait{ |
|
| 28 | +trait PrototypeTraversalTrait { |
|
| 29 | 29 | use PrototypeNodeTrait; |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -33,9 +33,9 @@ discard block |
||
| 33 | 33 | * |
| 34 | 34 | * @return \chillerlan\PrototypeDOM\Node\PrototypeTraversal|\DOMNode|null |
| 35 | 35 | */ |
| 36 | - public function recursivelyFind(string $selector = null, int $index = null, string $property = null, int $nodeType = XML_ELEMENT_NODE):?PrototypeTraversal{ |
|
| 36 | + public function recursivelyFind(string $selector = null, int $index = null, string $property = null, int $nodeType = XML_ELEMENT_NODE): ?PrototypeTraversal{ |
|
| 37 | 37 | |
| 38 | - if(is_numeric($selector)){ |
|
| 38 | + if (is_numeric($selector)) { |
|
| 39 | 39 | return $this->ownerDocument->recursivelyFind($this, $property, null, $selector, $nodeType); |
| 40 | 40 | } |
| 41 | 41 | |
@@ -52,19 +52,19 @@ discard block |
||
| 52 | 52 | /** |
| 53 | 53 | * @inheritDoc |
| 54 | 54 | */ |
| 55 | - public function down($expression = null, int $index = null):?PrototypeTraversal{ |
|
| 55 | + public function down($expression = null, int $index = null): ?PrototypeTraversal{ |
|
| 56 | 56 | |
| 57 | - if($expression === null && $index === null){ |
|
| 57 | + if ($expression === null && $index === null) { |
|
| 58 | 58 | return $this->firstDescendant(); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | $index = $index ?? 0; |
| 62 | 62 | |
| 63 | - if(is_int($expression)){ |
|
| 63 | + if (is_int($expression)) { |
|
| 64 | 64 | return $this->select(['*'])->item($expression); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - if(is_array($expression)){ |
|
| 67 | + if (is_array($expression)) { |
|
| 68 | 68 | return $this->select($expression)->item($index); |
| 69 | 69 | } |
| 70 | 70 | |
@@ -74,21 +74,21 @@ discard block |
||
| 74 | 74 | /** |
| 75 | 75 | * @inheritDoc |
| 76 | 76 | */ |
| 77 | - public function up($expression = null, int $index = null):?PrototypeTraversal{ |
|
| 77 | + public function up($expression = null, int $index = null): ?PrototypeTraversal{ |
|
| 78 | 78 | return $this->recursivelyFind($expression, $index, 'parentNode'); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | 82 | * @inheritDoc |
| 83 | 83 | */ |
| 84 | - public function previous($expression = null, int $index = null):?PrototypeTraversal{ |
|
| 84 | + public function previous($expression = null, int $index = null): ?PrototypeTraversal{ |
|
| 85 | 85 | return $this->recursivelyFind($expression, $index, 'previousSibling'); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * @inheritDoc |
| 90 | 90 | */ |
| 91 | - public function next($expression = null, int $index = null):?PrototypeTraversal{ |
|
| 91 | + public function next($expression = null, int $index = null): ?PrototypeTraversal{ |
|
| 92 | 92 | return $this->recursivelyFind($expression, $index, 'nextSibling'); |
| 93 | 93 | } |
| 94 | 94 | |
@@ -99,13 +99,13 @@ discard block |
||
| 99 | 99 | $nodeType = $nodeType ?? XML_ELEMENT_NODE; |
| 100 | 100 | $children = new NodeList; |
| 101 | 101 | |
| 102 | - if(!$this->hasChildNodes()){ |
|
| 102 | + if (!$this->hasChildNodes()) { |
|
| 103 | 103 | return $children; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - foreach($this->childNodes as $child){ |
|
| 106 | + foreach ($this->childNodes as $child) { |
|
| 107 | 107 | |
| 108 | - if($child->nodeType === $nodeType){ |
|
| 108 | + if ($child->nodeType === $nodeType) { |
|
| 109 | 109 | $children[] = $child; |
| 110 | 110 | } |
| 111 | 111 | |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | /** |
| 146 | 146 | * @inheritDoc |
| 147 | 147 | */ |
| 148 | - public function firstDescendant():?PrototypeTraversal{ |
|
| 148 | + public function firstDescendant(): ?PrototypeTraversal{ |
|
| 149 | 149 | return $this->descendants()->first(); |
| 150 | 150 | } |
| 151 | 151 | |