@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public function outerHtml() |
| 47 | 47 | { |
| 48 | - return $this->mapFirst(function (HtmlNode $node) { |
|
| 48 | + return $this->mapFirst(function(HtmlNode $node) { |
|
| 49 | 49 | return $node->outerHtml(); |
| 50 | 50 | }); |
| 51 | 51 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | public function getHtml() |
| 76 | 76 | { |
| 77 | - return $this->mapFirst(function (HtmlNode $node) { |
|
| 77 | + return $this->mapFirst(function(HtmlNode $node) { |
|
| 78 | 78 | return $node->getHtml(); |
| 79 | 79 | }); |
| 80 | 80 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | public function getText() |
| 124 | 124 | { |
| 125 | - return $this->mapFirst(function (HtmlNode $node) { |
|
| 125 | + return $this->mapFirst(function(HtmlNode $node) { |
|
| 126 | 126 | return $node->getText(); |
| 127 | 127 | }); |
| 128 | 128 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | public function setText(string $text) |
| 138 | 138 | { |
| 139 | - return $this->each(function (HtmlNode $node) use ($text) { |
|
| 139 | + return $this->each(function(HtmlNode $node) use ($text) { |
|
| 140 | 140 | $node->setText($text); |
| 141 | 141 | }); |
| 142 | 142 | } |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | public function getAttr(string $name) |
| 178 | 178 | { |
| 179 | - return $this->mapFirst(function (HtmlNode $node) use ($name) { |
|
| 179 | + return $this->mapFirst(function(HtmlNode $node) use ($name) { |
|
| 180 | 180 | return $node->getAttr($name); |
| 181 | 181 | }); |
| 182 | 182 | } |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | */ |
| 192 | 192 | public function setAttr(string $name, string $value) |
| 193 | 193 | { |
| 194 | - return $this->each(function (HtmlNode $node) use ($name, $value) { |
|
| 194 | + return $this->each(function(HtmlNode $node) use ($name, $value) { |
|
| 195 | 195 | $node->setAttr($name, $value); |
| 196 | 196 | }); |
| 197 | 197 | } |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | */ |
| 206 | 206 | public function removeAttr(string $attributeName) |
| 207 | 207 | { |
| 208 | - return $this->each(function (HtmlNode $node) use ($attributeName) { |
|
| 208 | + return $this->each(function(HtmlNode $node) use ($attributeName) { |
|
| 209 | 209 | $node->removeAttr($attributeName); |
| 210 | 210 | }); |
| 211 | 211 | } |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | public function removeAllAttrs($except = []) |
| 221 | 221 | { |
| 222 | - return $this->each(function (HtmlNode $node) use ($except) { |
|
| 222 | + return $this->each(function(HtmlNode $node) use ($except) { |
|
| 223 | 223 | $node->removeAllAttrs($except); |
| 224 | 224 | }); |
| 225 | 225 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | public function hasAttr(string $attributeName) |
| 235 | 235 | { |
| 236 | 236 | return $this->mapAnyTrue( |
| 237 | - function (HtmlNode $node) use ($attributeName) { |
|
| 237 | + function(HtmlNode $node) use ($attributeName) { |
|
| 238 | 238 | return $node->hasAttr($attributeName); |
| 239 | 239 | } |
| 240 | 240 | ); |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | { |
| 282 | 282 | if (is_array($name)) { |
| 283 | 283 | $keys = array_keys($name); |
| 284 | - $keys = array_map(function ($value) { |
|
| 284 | + $keys = array_map(function($value) { |
|
| 285 | 285 | return 'data-' . $value; |
| 286 | 286 | }, $keys); |
| 287 | 287 | |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | */ |
| 339 | 339 | public function empty() |
| 340 | 340 | { |
| 341 | - return $this->each(function (HtmlNode $node) { |
|
| 341 | + return $this->each(function(HtmlNode $node) { |
|
| 342 | 342 | $node->empty(); |
| 343 | 343 | }); |
| 344 | 344 | } |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | if (!is_null($selector)) { |
| 357 | 357 | $this->filter($selector)->remove(); |
| 358 | 358 | } else { |
| 359 | - $this->each(function (HtmlNode $node) { |
|
| 359 | + $this->each(function(HtmlNode $node) { |
|
| 360 | 360 | $node->remove(); |
| 361 | 361 | }); |
| 362 | 362 | } |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | */ |
| 389 | 389 | public function getVal() |
| 390 | 390 | { |
| 391 | - return $this->mapFirst(function (DOMNode $node) { |
|
| 391 | + return $this->mapFirst(function(DOMNode $node) { |
|
| 392 | 392 | if (!($node instanceof DOMElement)) { |
| 393 | 393 | return null; |
| 394 | 394 | } |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | */ |
| 427 | 427 | public function setVal(string $value) |
| 428 | 428 | { |
| 429 | - return $this->each(function (DOMNode $node) use ($value) { |
|
| 429 | + return $this->each(function(DOMNode $node) use ($value) { |
|
| 430 | 430 | if (!($node instanceof DOMElement)) { |
| 431 | 431 | return; |
| 432 | 432 | } |
@@ -464,7 +464,7 @@ discard block |
||
| 464 | 464 | */ |
| 465 | 465 | public function addClass(string $className) |
| 466 | 466 | { |
| 467 | - return $this->each(function (HtmlNode $node) use ($className) { |
|
| 467 | + return $this->each(function(HtmlNode $node) use ($className) { |
|
| 468 | 468 | $node->addClass($className); |
| 469 | 469 | }); |
| 470 | 470 | } |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | public function hasClass(string $className) |
| 480 | 480 | { |
| 481 | 481 | return $this->mapAnyTrue( |
| 482 | - function (HtmlNode $node) use ($className) { |
|
| 482 | + function(HtmlNode $node) use ($className) { |
|
| 483 | 483 | return $node->hasClass($className); |
| 484 | 484 | } |
| 485 | 485 | ); |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | */ |
| 496 | 496 | public function removeClass(?string $className = null) |
| 497 | 497 | { |
| 498 | - return $this->each(function (HtmlNode $node) use ($className) { |
|
| 498 | + return $this->each(function(HtmlNode $node) use ($className) { |
|
| 499 | 499 | $node->removeClass($className); |
| 500 | 500 | }); |
| 501 | 501 | } |
@@ -511,7 +511,7 @@ discard block |
||
| 511 | 511 | */ |
| 512 | 512 | public function toggleClass(string $className, ?bool $state = null) |
| 513 | 513 | { |
| 514 | - return $this->each(function (HtmlNode $node) use ($className, $state) { |
|
| 514 | + return $this->each(function(HtmlNode $node) use ($className, $state) { |
|
| 515 | 515 | $node->toggleClass($className, $state); |
| 516 | 516 | }); |
| 517 | 517 | } |
@@ -552,7 +552,7 @@ discard block |
||
| 552 | 552 | */ |
| 553 | 553 | public function getCss(string $name) |
| 554 | 554 | { |
| 555 | - return $this->mapFirst(function (HtmlNode $node) use ($name) { |
|
| 555 | + return $this->mapFirst(function(HtmlNode $node) use ($name) { |
|
| 556 | 556 | return $node->getCss($name); |
| 557 | 557 | }); |
| 558 | 558 | } |
@@ -567,7 +567,7 @@ discard block |
||
| 567 | 567 | */ |
| 568 | 568 | public function setCss(string $name, ?string $value) |
| 569 | 569 | { |
| 570 | - return $this->each(function (HtmlNode $node) use ($name, $value) { |
|
| 570 | + return $this->each(function(HtmlNode $node) use ($name, $value) { |
|
| 571 | 571 | $node->setCss($name, $value); |
| 572 | 572 | }); |
| 573 | 573 | } |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | */ |
| 582 | 582 | public function removeCss(string $name) |
| 583 | 583 | { |
| 584 | - return $this->each(function (HtmlNode $node) use ($name) { |
|
| 584 | + return $this->each(function(HtmlNode $node) use ($name) { |
|
| 585 | 585 | return $node->removeCss($name); |
| 586 | 586 | }); |
| 587 | 587 | } |
@@ -597,8 +597,8 @@ discard block |
||
| 597 | 597 | { |
| 598 | 598 | $content = $this->contentResolve($content); |
| 599 | 599 | |
| 600 | - return $this->each(function (HtmlNode $node, $index) use ($content) { |
|
| 601 | - $content->each(function (DOMNode $newNode) use ($node, $index) { |
|
| 600 | + return $this->each(function(HtmlNode $node, $index) use ($content) { |
|
| 601 | + $content->each(function(DOMNode $newNode) use ($node, $index) { |
|
| 602 | 602 | $newNode = $index !== $this->count() - 1 |
| 603 | 603 | ? $newNode->cloneNode(true) |
| 604 | 604 | : $newNode; |
@@ -633,8 +633,8 @@ discard block |
||
| 633 | 633 | { |
| 634 | 634 | $content = $this->contentResolve($content); |
| 635 | 635 | |
| 636 | - return $this->each(function (HtmlQuery $node, $index) use ($content) { |
|
| 637 | - $content->each(function (DOMNode $newNode) use ($node, $index) { |
|
| 636 | + return $this->each(function(HtmlQuery $node, $index) use ($content) { |
|
| 637 | + $content->each(function(DOMNode $newNode) use ($node, $index) { |
|
| 638 | 638 | $newNode = $index !== $this->count() - 1 |
| 639 | 639 | ? $newNode->cloneNode(true) |
| 640 | 640 | : $newNode; |
@@ -673,8 +673,8 @@ discard block |
||
| 673 | 673 | { |
| 674 | 674 | $content = $this->contentResolve($content); |
| 675 | 675 | |
| 676 | - return $this->each(function (HtmlNode $node, $index) use ($content) { |
|
| 677 | - $content->each(function (DOMNode $newNode) use ($node, $index) { |
|
| 676 | + return $this->each(function(HtmlNode $node, $index) use ($content) { |
|
| 677 | + $content->each(function(DOMNode $newNode) use ($node, $index) { |
|
| 678 | 678 | $newNode = $index !== $this->count() - 1 |
| 679 | 679 | ? $newNode->cloneNode(true) |
| 680 | 680 | : $newNode; |
@@ -709,8 +709,8 @@ discard block |
||
| 709 | 709 | { |
| 710 | 710 | $content = $this->contentResolve($content); |
| 711 | 711 | |
| 712 | - return $this->each(function (HtmlNode $node, $index) use ($content) { |
|
| 713 | - $content->each(function (DOMNode $newNode) use ($node, $index) { |
|
| 712 | + return $this->each(function(HtmlNode $node, $index) use ($content) { |
|
| 713 | + $content->each(function(DOMNode $newNode) use ($node, $index) { |
|
| 714 | 714 | $newNode = $index !== $this->count() - 1 |
| 715 | 715 | ? $newNode->cloneNode(true) |
| 716 | 716 | : $newNode; |
@@ -744,14 +744,14 @@ discard block |
||
| 744 | 744 | public function replaceWith($content) |
| 745 | 745 | { |
| 746 | 746 | $content = $this->contentResolve($content); |
| 747 | - return $this->each(function (DOMNode $node, $index) use ($content) { |
|
| 747 | + return $this->each(function(DOMNode $node, $index) use ($content) { |
|
| 748 | 748 | if (!$node->parentNode) { |
| 749 | 749 | return; |
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | $len = $content->count(); |
| 753 | 753 | $content->each( |
| 754 | - function (DOMNode $newNode) use ($node, $index, $len) { |
|
| 754 | + function(DOMNode $newNode) use ($node, $index, $len) { |
|
| 755 | 755 | $newNode = $index !== $this->count() - 1 |
| 756 | 756 | ? $newNode->cloneNode(true) |
| 757 | 757 | : $newNode; |
@@ -803,7 +803,7 @@ discard block |
||
| 803 | 803 | |
| 804 | 804 | $newNode = $content[0]; |
| 805 | 805 | |
| 806 | - return $this->each(function (DOMNode $node, $index) use ($newNode) { |
|
| 806 | + return $this->each(function(DOMNode $node, $index) use ($newNode) { |
|
| 807 | 807 | $newNode = $index !== $this->count() - 1 |
| 808 | 808 | ? $newNode->cloneNode(true) |
| 809 | 809 | : $newNode; |
@@ -835,7 +835,7 @@ discard block |
||
| 835 | 835 | return $this; |
| 836 | 836 | } |
| 837 | 837 | |
| 838 | - return $this->each(function (DOMNode $node, $index) use ($newNode) { |
|
| 838 | + return $this->each(function(DOMNode $node, $index) use ($newNode) { |
|
| 839 | 839 | $newNode = $index !== $this->count() - 1 |
| 840 | 840 | ? $newNode->cloneNode(true) |
| 841 | 841 | : $newNode; |
@@ -872,7 +872,7 @@ discard block |
||
| 872 | 872 | } |
| 873 | 873 | |
| 874 | 874 | $newNode = $content[0]; |
| 875 | - $this->each(function (DOMNode $node, $index) use ($newNode) { |
|
| 875 | + $this->each(function(DOMNode $node, $index) use ($newNode) { |
|
| 876 | 876 | if ($index === 0) { |
| 877 | 877 | $this->resolve($node)->wrap($newNode); |
| 878 | 878 | } else { |
@@ -904,7 +904,7 @@ discard block |
||
| 904 | 904 | */ |
| 905 | 905 | public function unwrapSelf() |
| 906 | 906 | { |
| 907 | - return $this->each(function (DOMNode $node) { |
|
| 907 | + return $this->each(function(DOMNode $node) { |
|
| 908 | 908 | if (!$node->parentNode) { |
| 909 | 909 | return; |
| 910 | 910 | } |
@@ -430,7 +430,6 @@ |
||
| 430 | 430 | protected function getDoc() |
| 431 | 431 | { |
| 432 | 432 | return $this->node instanceof DOMDocument |
| 433 | - ? $this->node : |
|
| 434 | - $this->node->ownerDocument; |
|
| 433 | + ? $this->node : $this->node->ownerDocument; |
|
| 435 | 434 | } |
| 436 | 435 | } |