@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | public static function strictArrayIntersect(array $arr1, array $arr2): array |
| 60 | 60 | { |
| 61 | - $arr = array_filter($arr1, function ($val1) use ($arr2) { |
|
| 61 | + $arr = array_filter($arr1, function($val1) use ($arr2) { |
|
| 62 | 62 | return in_array($val1, $arr2, true); |
| 63 | 63 | }); |
| 64 | 64 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | public static function strictArrayDiff(array $arr1, array $arr2): array |
| 77 | 77 | { |
| 78 | - $arr = array_filter($arr1, function ($val1) use ($arr2) { |
|
| 78 | + $arr = array_filter($arr1, function($val1) use ($arr2) { |
|
| 79 | 79 | return !in_array($val1, $arr2, true); |
| 80 | 80 | }); |
| 81 | 81 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public function outerHtml() |
| 46 | 46 | { |
| 47 | - return $this->mapFirst(function (HtmlNode $node) { |
|
| 47 | + return $this->mapFirst(function(HtmlNode $node) { |
|
| 48 | 48 | return $node->outerHtml(); |
| 49 | 49 | }); |
| 50 | 50 | } |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public function getHtml() |
| 75 | 75 | { |
| 76 | - return $this->mapFirst(function (HtmlNode $node) { |
|
| 76 | + return $this->mapFirst(function(HtmlNode $node) { |
|
| 77 | 77 | return $node->getHtml(); |
| 78 | 78 | }); |
| 79 | 79 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function getText() |
| 123 | 123 | { |
| 124 | - return $this->mapFirst(function (HtmlNode $node) { |
|
| 124 | + return $this->mapFirst(function(HtmlNode $node) { |
|
| 125 | 125 | return $node->getText(); |
| 126 | 126 | }); |
| 127 | 127 | } |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | public function setText(string $text) |
| 137 | 137 | { |
| 138 | - return $this->each(function (HtmlNode $node) use ($text) { |
|
| 138 | + return $this->each(function(HtmlNode $node) use ($text) { |
|
| 139 | 139 | $node->setText($text); |
| 140 | 140 | }); |
| 141 | 141 | } |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | public function getAttr(string $name) |
| 177 | 177 | { |
| 178 | - return $this->mapFirst(function (HtmlElement $node) use ($name) { |
|
| 178 | + return $this->mapFirst(function(HtmlElement $node) use ($name) { |
|
| 179 | 179 | return $node->getAttr($name); |
| 180 | 180 | }); |
| 181 | 181 | } |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | */ |
| 191 | 191 | public function setAttr(string $name, string $value) |
| 192 | 192 | { |
| 193 | - return $this->each(function (HtmlElement $node) use ($name, $value) { |
|
| 193 | + return $this->each(function(HtmlElement $node) use ($name, $value) { |
|
| 194 | 194 | $node->setAttr($name, $value); |
| 195 | 195 | }); |
| 196 | 196 | } |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | */ |
| 205 | 205 | public function removeAttr(string $attributeName) |
| 206 | 206 | { |
| 207 | - return $this->each(function (HtmlElement $node) use ($attributeName) { |
|
| 207 | + return $this->each(function(HtmlElement $node) use ($attributeName) { |
|
| 208 | 208 | $node->removeAttr($attributeName); |
| 209 | 209 | }); |
| 210 | 210 | } |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | */ |
| 219 | 219 | public function removeAllAttrs($except = []) |
| 220 | 220 | { |
| 221 | - return $this->each(function (HtmlElement $node) use ($except) { |
|
| 221 | + return $this->each(function(HtmlElement $node) use ($except) { |
|
| 222 | 222 | $node->removeAllAttrs($except); |
| 223 | 223 | }); |
| 224 | 224 | } |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | public function hasAttr(string $attributeName) |
| 234 | 234 | { |
| 235 | 235 | return $this->mapAnyTrue( |
| 236 | - function (HtmlElement $node) use ($attributeName) { |
|
| 236 | + function(HtmlElement $node) use ($attributeName) { |
|
| 237 | 237 | return $node->hasAttr($attributeName); |
| 238 | 238 | } |
| 239 | 239 | ); |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | { |
| 281 | 281 | if (is_array($name)) { |
| 282 | 282 | $keys = array_keys($name); |
| 283 | - $keys = array_map(function ($value) { |
|
| 283 | + $keys = array_map(function($value) { |
|
| 284 | 284 | return 'data-' . $value; |
| 285 | 285 | }, $keys); |
| 286 | 286 | |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | */ |
| 338 | 338 | public function empty() |
| 339 | 339 | { |
| 340 | - return $this->each(function (HtmlNode $node) { |
|
| 340 | + return $this->each(function(HtmlNode $node) { |
|
| 341 | 341 | $node->empty(); |
| 342 | 342 | }); |
| 343 | 343 | } |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | if (!is_null($selector)) { |
| 356 | 356 | $this->filter($selector)->remove(); |
| 357 | 357 | } else { |
| 358 | - $this->each(function (HtmlNode $node) { |
|
| 358 | + $this->each(function(HtmlNode $node) { |
|
| 359 | 359 | $node->remove(); |
| 360 | 360 | }); |
| 361 | 361 | } |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | */ |
| 388 | 388 | public function getVal() |
| 389 | 389 | { |
| 390 | - return $this->mapFirst(function (DOMElement $node) { |
|
| 390 | + return $this->mapFirst(function(DOMElement $node) { |
|
| 391 | 391 | switch ($node->tagName) { |
| 392 | 392 | case 'input': |
| 393 | 393 | return $node->getAttribute('value'); |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | */ |
| 422 | 422 | public function setVal(string $value) |
| 423 | 423 | { |
| 424 | - return $this->each(function (DOMElement $node) use ($value) { |
|
| 424 | + return $this->each(function(DOMElement $node) use ($value) { |
|
| 425 | 425 | switch ($node->tagName) { |
| 426 | 426 | case 'input': |
| 427 | 427 | $node->setAttribute('value', $value); |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | */ |
| 456 | 456 | public function addClass(string $className) |
| 457 | 457 | { |
| 458 | - return $this->each(function (HtmlElement $node) use ($className) { |
|
| 458 | + return $this->each(function(HtmlElement $node) use ($className) { |
|
| 459 | 459 | $node->addClass($className); |
| 460 | 460 | }); |
| 461 | 461 | } |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | public function hasClass(string $className) |
| 471 | 471 | { |
| 472 | 472 | return $this->mapAnyTrue( |
| 473 | - function (HtmlElement $node) use ($className) { |
|
| 473 | + function(HtmlElement $node) use ($className) { |
|
| 474 | 474 | return $node->hasClass($className); |
| 475 | 475 | } |
| 476 | 476 | ); |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | */ |
| 487 | 487 | public function removeClass(?string $className = null) |
| 488 | 488 | { |
| 489 | - return $this->each(function (HtmlElement $node) use ($className) { |
|
| 489 | + return $this->each(function(HtmlElement $node) use ($className) { |
|
| 490 | 490 | $node->removeClass($className); |
| 491 | 491 | }); |
| 492 | 492 | } |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | */ |
| 503 | 503 | public function toggleClass(string $className, ?bool $state = null) |
| 504 | 504 | { |
| 505 | - return $this->each(function (HtmlElement $node) use ($className, $state) { |
|
| 505 | + return $this->each(function(HtmlElement $node) use ($className, $state) { |
|
| 506 | 506 | $node->toggleClass($className, $state); |
| 507 | 507 | }); |
| 508 | 508 | } |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | */ |
| 544 | 544 | public function getCss(string $name) |
| 545 | 545 | { |
| 546 | - return $this->mapFirst(function (HtmlElement $node) use ($name) { |
|
| 546 | + return $this->mapFirst(function(HtmlElement $node) use ($name) { |
|
| 547 | 547 | return $node->getCss($name); |
| 548 | 548 | }); |
| 549 | 549 | } |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | */ |
| 559 | 559 | public function setCss(string $name, ?string $value) |
| 560 | 560 | { |
| 561 | - return $this->each(function (HtmlElement $node) use ($name, $value) { |
|
| 561 | + return $this->each(function(HtmlElement $node) use ($name, $value) { |
|
| 562 | 562 | $node->setCss($name, $value); |
| 563 | 563 | }); |
| 564 | 564 | } |
@@ -572,7 +572,7 @@ discard block |
||
| 572 | 572 | */ |
| 573 | 573 | public function removeCss(string $name) |
| 574 | 574 | { |
| 575 | - return $this->each(function (HtmlElement $node) use ($name) { |
|
| 575 | + return $this->each(function(HtmlElement $node) use ($name) { |
|
| 576 | 576 | $node->removeCss($name); |
| 577 | 577 | }); |
| 578 | 578 | } |
@@ -588,8 +588,8 @@ discard block |
||
| 588 | 588 | { |
| 589 | 589 | $content = $this->contentResolve($content); |
| 590 | 590 | |
| 591 | - return $this->each(function (HtmlNode $node, $index) use ($content) { |
|
| 592 | - $content->each(function (DOMNode $newNode) use ($node, $index) { |
|
| 591 | + return $this->each(function(HtmlNode $node, $index) use ($content) { |
|
| 592 | + $content->each(function(DOMNode $newNode) use ($node, $index) { |
|
| 593 | 593 | $newNode = $this->newNode($newNode, $index); |
| 594 | 594 | $node->before($newNode); |
| 595 | 595 | }); |
@@ -621,8 +621,8 @@ discard block |
||
| 621 | 621 | { |
| 622 | 622 | $content = $this->contentResolve($content); |
| 623 | 623 | |
| 624 | - return $this->each(function (HtmlNode $node, $index) use ($content) { |
|
| 625 | - $content->each(function (DOMNode $newNode) use ($node, $index) { |
|
| 624 | + return $this->each(function(HtmlNode $node, $index) use ($content) { |
|
| 625 | + $content->each(function(DOMNode $newNode) use ($node, $index) { |
|
| 626 | 626 | $newNode = $this->newNode($newNode, $index); |
| 627 | 627 | |
| 628 | 628 | $node->after($newNode); |
@@ -655,8 +655,8 @@ discard block |
||
| 655 | 655 | { |
| 656 | 656 | $content = $this->contentResolve($content); |
| 657 | 657 | |
| 658 | - return $this->each(function (HtmlNode $node, $index) use ($content) { |
|
| 659 | - $content->each(function (DOMNode $newNode) use ($node, $index) { |
|
| 658 | + return $this->each(function(HtmlNode $node, $index) use ($content) { |
|
| 659 | + $content->each(function(DOMNode $newNode) use ($node, $index) { |
|
| 660 | 660 | $newNode = $this->newNode($newNode, $index); |
| 661 | 661 | $node->append($newNode); |
| 662 | 662 | }); |
@@ -688,8 +688,8 @@ discard block |
||
| 688 | 688 | { |
| 689 | 689 | $content = $this->contentResolve($content); |
| 690 | 690 | |
| 691 | - return $this->each(function (HtmlNode $node, $index) use ($content) { |
|
| 692 | - $content->each(function (DOMNode $newNode) use ($node, $index) { |
|
| 691 | + return $this->each(function(HtmlNode $node, $index) use ($content) { |
|
| 692 | + $content->each(function(DOMNode $newNode) use ($node, $index) { |
|
| 693 | 693 | $newNode = $this->newNode($newNode, $index); |
| 694 | 694 | $node->prepend($newNode); |
| 695 | 695 | }, true); |
@@ -720,14 +720,14 @@ discard block |
||
| 720 | 720 | public function replaceWith($content) |
| 721 | 721 | { |
| 722 | 722 | $content = $this->contentResolve($content); |
| 723 | - return $this->each(function (DOMNode $node, $index) use ($content) { |
|
| 723 | + return $this->each(function(DOMNode $node, $index) use ($content) { |
|
| 724 | 724 | if (!$node->parentNode) { |
| 725 | 725 | return; |
| 726 | 726 | } |
| 727 | 727 | |
| 728 | 728 | $len = $content->count(); |
| 729 | 729 | $content->each( |
| 730 | - function (DOMNode $newNode) use ($node, $index, $len) { |
|
| 730 | + function(DOMNode $newNode) use ($node, $index, $len) { |
|
| 731 | 731 | $newNode = $this->newNode($newNode, $index); |
| 732 | 732 | |
| 733 | 733 | if ($len === 1) { |
@@ -775,7 +775,7 @@ discard block |
||
| 775 | 775 | return $this; |
| 776 | 776 | } |
| 777 | 777 | |
| 778 | - return $this->each(function (DOMNode $node, $index) use ($newNode) { |
|
| 778 | + return $this->each(function(DOMNode $node, $index) use ($newNode) { |
|
| 779 | 779 | $newNode = $this->newNode($newNode, $index); |
| 780 | 780 | |
| 781 | 781 | $nodes = $this->xpathQuery('descendant::*[last()]', $newNode); |
@@ -805,7 +805,7 @@ discard block |
||
| 805 | 805 | return $this; |
| 806 | 806 | } |
| 807 | 807 | |
| 808 | - return $this->each(function (DOMNode $node, $index) use ($newNode) { |
|
| 808 | + return $this->each(function(DOMNode $node, $index) use ($newNode) { |
|
| 809 | 809 | $newNode = $this->newNode($newNode, $index); |
| 810 | 810 | |
| 811 | 811 | $nodes = $this->xpathQuery('descendant::*[last()]', $newNode); |
@@ -840,7 +840,7 @@ discard block |
||
| 840 | 840 | } |
| 841 | 841 | |
| 842 | 842 | $newNode = $content[0]; |
| 843 | - $this->each(function (DOMNode $node, $index) use ($newNode) { |
|
| 843 | + $this->each(function(DOMNode $node, $index) use ($newNode) { |
|
| 844 | 844 | if ($index === 0) { |
| 845 | 845 | $this->resolve($node)->wrap($newNode); |
| 846 | 846 | } else { |
@@ -872,7 +872,7 @@ discard block |
||
| 872 | 872 | */ |
| 873 | 873 | public function unwrapSelf() |
| 874 | 874 | { |
| 875 | - return $this->each(function (HtmlNode $node) { |
|
| 875 | + return $this->each(function(HtmlNode $node) { |
|
| 876 | 876 | $node->unwrapSelf(); |
| 877 | 877 | }); |
| 878 | 878 | } |