@@ -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 | |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | public function outerHtml() |
| 36 | 36 | { |
| 37 | - return $this->mapFirst(function (DOMNode $node) { |
|
| 37 | + return $this->mapFirst(function(DOMNode $node) { |
|
| 38 | 38 | return $this->doc->saveHTML($node); |
| 39 | 39 | }); |
| 40 | 40 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public function getHtml() |
| 65 | 65 | { |
| 66 | - return $this->mapFirst(function (DOMNode $node) { |
|
| 66 | + return $this->mapFirst(function(DOMNode $node) { |
|
| 67 | 67 | $content = ''; |
| 68 | 68 | foreach (iterator_to_array($node->childNodes) as $childNode) { |
| 69 | 69 | $content .= $this->doc->saveHTML($childNode); |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | { |
| 85 | 85 | $this->empty(); |
| 86 | 86 | |
| 87 | - $this->each(function (DOMNode $node) { |
|
| 87 | + $this->each(function(DOMNode $node) { |
|
| 88 | 88 | $node->nodeValue = ''; |
| 89 | 89 | }); |
| 90 | 90 | |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | public function getText() |
| 122 | 122 | { |
| 123 | - return $this->mapFirst(function (DOMNode $node) { |
|
| 123 | + return $this->mapFirst(function(DOMNode $node) { |
|
| 124 | 124 | return $node->textContent; |
| 125 | 125 | }); |
| 126 | 126 | } |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | public function setText(string $text) |
| 136 | 136 | { |
| 137 | - return $this->each(function (DOMNode $node) use ($text) { |
|
| 137 | + return $this->each(function(DOMNode $node) use ($text) { |
|
| 138 | 138 | return $node->nodeValue = $text; |
| 139 | 139 | }); |
| 140 | 140 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | public function empty() |
| 148 | 148 | { |
| 149 | - return $this->each(function (DOMNode $node) { |
|
| 149 | + return $this->each(function(DOMNode $node) { |
|
| 150 | 150 | $node->nodeValue = ''; |
| 151 | 151 | }); |
| 152 | 152 | } |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | if (!is_null($selector)) { |
| 165 | 165 | $this->filter($selector)->remove(); |
| 166 | 166 | } else { |
| 167 | - $this->each(function (DOMNode $node) { |
|
| 167 | + $this->each(function(DOMNode $node) { |
|
| 168 | 168 | if ($node->parentNode) { |
| 169 | 169 | $node->parentNode->removeChild($node); |
| 170 | 170 | } |
@@ -185,8 +185,8 @@ discard block |
||
| 185 | 185 | { |
| 186 | 186 | $content = $this->contentResolve($content); |
| 187 | 187 | |
| 188 | - return $this->each(function (DOMNode $node, $index) use ($content) { |
|
| 189 | - $content->each(function (DOMNode $newNode) use ($node, $index) { |
|
| 188 | + return $this->each(function(DOMNode $node, $index) use ($content) { |
|
| 189 | + $content->each(function(DOMNode $newNode) use ($node, $index) { |
|
| 190 | 190 | if ($node->parentNode) { |
| 191 | 191 | $newNode = $index !== $this->count() - 1 |
| 192 | 192 | ? $newNode->cloneNode(true) |
@@ -223,8 +223,8 @@ discard block |
||
| 223 | 223 | { |
| 224 | 224 | $content = $this->contentResolve($content); |
| 225 | 225 | |
| 226 | - return $this->each(function (HtmlQuery $node, $index) use ($content) { |
|
| 227 | - $content->each(function (DOMNode $newNode) use ($node, $index) { |
|
| 226 | + return $this->each(function(HtmlQuery $node, $index) use ($content) { |
|
| 227 | + $content->each(function(DOMNode $newNode) use ($node, $index) { |
|
| 228 | 228 | $newNode = $index !== $this->count() - 1 |
| 229 | 229 | ? $newNode->cloneNode(true) |
| 230 | 230 | : $newNode; |
@@ -263,8 +263,8 @@ discard block |
||
| 263 | 263 | { |
| 264 | 264 | $content = $this->contentResolve($content); |
| 265 | 265 | |
| 266 | - return $this->each(function (DOMNode $node, $index) use ($content) { |
|
| 267 | - $content->each(function (DOMNode $newNode) use ($node, $index) { |
|
| 266 | + return $this->each(function(DOMNode $node, $index) use ($content) { |
|
| 267 | + $content->each(function(DOMNode $newNode) use ($node, $index) { |
|
| 268 | 268 | $newNode = $index !== $this->count() - 1 |
| 269 | 269 | ? $newNode->cloneNode(true) |
| 270 | 270 | : $newNode; |
@@ -299,8 +299,8 @@ discard block |
||
| 299 | 299 | { |
| 300 | 300 | $content = $this->contentResolve($content); |
| 301 | 301 | |
| 302 | - return $this->each(function (DOMNode $node, $index) use ($content) { |
|
| 303 | - $content->each(function (DOMNode $newNode) use ($node, $index) { |
|
| 302 | + return $this->each(function(DOMNode $node, $index) use ($content) { |
|
| 303 | + $content->each(function(DOMNode $newNode) use ($node, $index) { |
|
| 304 | 304 | $newNode = $index !== $this->count() - 1 |
| 305 | 305 | ? $newNode->cloneNode(true) |
| 306 | 306 | : $newNode; |
@@ -338,14 +338,14 @@ discard block |
||
| 338 | 338 | public function replaceWith($content) |
| 339 | 339 | { |
| 340 | 340 | $content = $this->contentResolve($content); |
| 341 | - return $this->each(function (DOMNode $node, $index) use ($content) { |
|
| 341 | + return $this->each(function(DOMNode $node, $index) use ($content) { |
|
| 342 | 342 | if (!$node->parentNode) { |
| 343 | 343 | return; |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | $len = $content->count(); |
| 347 | 347 | $content->each( |
| 348 | - function (DOMNode $newNode) use ($node, $index, $len) { |
|
| 348 | + function(DOMNode $newNode) use ($node, $index, $len) { |
|
| 349 | 349 | $newNode = $index !== $this->count() - 1 |
| 350 | 350 | ? $newNode->cloneNode(true) |
| 351 | 351 | : $newNode; |
@@ -397,7 +397,7 @@ discard block |
||
| 397 | 397 | |
| 398 | 398 | $newNode = $content[0]; |
| 399 | 399 | |
| 400 | - return $this->each(function (DOMNode $node, $index) use ($newNode) { |
|
| 400 | + return $this->each(function(DOMNode $node, $index) use ($newNode) { |
|
| 401 | 401 | $newNode = $index !== $this->count() - 1 |
| 402 | 402 | ? $newNode->cloneNode(true) |
| 403 | 403 | : $newNode; |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | return $this; |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | - return $this->each(function (DOMNode $node, $index) use ($newNode) { |
|
| 432 | + return $this->each(function(DOMNode $node, $index) use ($newNode) { |
|
| 433 | 433 | $newNode = $index !== $this->count() - 1 |
| 434 | 434 | ? $newNode->cloneNode(true) |
| 435 | 435 | : $newNode; |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | $newNode = $content[0]; |
| 469 | - $this->each(function (DOMNode $node, $index) use ($newNode) { |
|
| 469 | + $this->each(function(DOMNode $node, $index) use ($newNode) { |
|
| 470 | 470 | if ($index === 0) { |
| 471 | 471 | $this->resolve($node)->wrap($newNode); |
| 472 | 472 | } else { |
@@ -498,7 +498,7 @@ discard block |
||
| 498 | 498 | */ |
| 499 | 499 | public function unwrapSelf() |
| 500 | 500 | { |
| 501 | - return $this->each(function (DOMNode $node) { |
|
| 501 | + return $this->each(function(DOMNode $node) { |
|
| 502 | 502 | if (!$node->parentNode) { |
| 503 | 503 | return; |
| 504 | 504 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | public function getAttr(string $name) |
| 48 | 48 | { |
| 49 | - return $this->mapFirst(function (DOMNode $node) use ($name) { |
|
| 49 | + return $this->mapFirst(function(DOMNode $node) use ($name) { |
|
| 50 | 50 | if (!($node instanceof DOMElement)) { |
| 51 | 51 | return null; |
| 52 | 52 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | public function setAttr(string $name, string $value) |
| 67 | 67 | { |
| 68 | - return $this->each(function (DOMNode $node) use ($name, $value) { |
|
| 68 | + return $this->each(function(DOMNode $node) use ($name, $value) { |
|
| 69 | 69 | if ($node instanceof DOMElement) { |
| 70 | 70 | $node->setAttribute($name, $value); |
| 71 | 71 | } |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | public function removeAttr(string $attributeName) |
| 83 | 83 | { |
| 84 | - return $this->each(function (DOMNode $node) use ($attributeName) { |
|
| 84 | + return $this->each(function(DOMNode $node) use ($attributeName) { |
|
| 85 | 85 | if ($node instanceof DOMElement) { |
| 86 | 86 | $node->removeAttribute($attributeName); |
| 87 | 87 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | public function removeAllAttrs($except = []) |
| 99 | 99 | { |
| 100 | - return $this->each(function (DOMNode $node) use ($except) { |
|
| 100 | + return $this->each(function(DOMNode $node) use ($except) { |
|
| 101 | 101 | $names = []; |
| 102 | 102 | foreach (iterator_to_array($node->attributes) as $attribute) { |
| 103 | 103 | $names[] = $attribute->name; |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | public function hasAttr(string $attributeName) |
| 122 | 122 | { |
| 123 | 123 | return $this->mapAnyTrue( |
| 124 | - function (DOMNode $node) use ($attributeName) { |
|
| 124 | + function(DOMNode $node) use ($attributeName) { |
|
| 125 | 125 | if (!($node instanceof DOMElement)) { |
| 126 | 126 | return false; |
| 127 | 127 | } |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | { |
| 173 | 173 | if (is_array($name)) { |
| 174 | 174 | $keys = array_keys($name); |
| 175 | - $keys = array_map(function ($value) { |
|
| 175 | + $keys = array_map(function($value) { |
|
| 176 | 176 | return 'data-' . $value; |
| 177 | 177 | }, $keys); |
| 178 | 178 | |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | */ |
| 247 | 247 | public function getVal() |
| 248 | 248 | { |
| 249 | - return $this->mapFirst(function (DOMNode $node) { |
|
| 249 | + return $this->mapFirst(function(DOMNode $node) { |
|
| 250 | 250 | if (!($node instanceof DOMElement)) { |
| 251 | 251 | return null; |
| 252 | 252 | } |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | */ |
| 285 | 285 | public function setVal(string $value) |
| 286 | 286 | { |
| 287 | - return $this->each(function (DOMNode $node) use ($value) { |
|
| 287 | + return $this->each(function(DOMNode $node) use ($value) { |
|
| 288 | 288 | if (!($node instanceof DOMElement)) { |
| 289 | 289 | return; |
| 290 | 290 | } |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | */ |
| 323 | 323 | public function addClass(string $className) |
| 324 | 324 | { |
| 325 | - return $this->each(function (HtmlQuery $node) use ($className) { |
|
| 325 | + return $this->each(function(HtmlQuery $node) use ($className) { |
|
| 326 | 326 | if (!$node->hasAttr('class')) { |
| 327 | 327 | $node->setAttr('class', $className); |
| 328 | 328 | return; |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | public function hasClass(string $className) |
| 353 | 353 | { |
| 354 | 354 | return $this->mapAnyTrue( |
| 355 | - function (HtmlQuery $node) use ($className) { |
|
| 355 | + function(HtmlQuery $node) use ($className) { |
|
| 356 | 356 | if (!$node->hasAttr('class')) { |
| 357 | 357 | return false; |
| 358 | 358 | } |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | */ |
| 376 | 376 | public function removeClass(?string $className = null) |
| 377 | 377 | { |
| 378 | - return $this->each(function (HtmlQuery $node) use ($className) { |
|
| 378 | + return $this->each(function(HtmlQuery $node) use ($className) { |
|
| 379 | 379 | if (!$node->hasAttr('class')) { |
| 380 | 380 | return; |
| 381 | 381 | } |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | */ |
| 412 | 412 | public function toggleClass(string $className, ?bool $state = null) |
| 413 | 413 | { |
| 414 | - return $this->each(function (HtmlQuery $node) use ($className, $state) { |
|
| 414 | + return $this->each(function(HtmlQuery $node) use ($className, $state) { |
|
| 415 | 415 | if (!is_null($state)) { |
| 416 | 416 | if ($state) { |
| 417 | 417 | $node->addClass($className); |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | */ |
| 480 | 480 | public function getCss(string $name) |
| 481 | 481 | { |
| 482 | - return $this->mapFirst(function (HtmlQuery $node) use ($name) { |
|
| 482 | + return $this->mapFirst(function(HtmlQuery $node) use ($name) { |
|
| 483 | 483 | $style = (string) $node->attr('style'); |
| 484 | 484 | $css = Helper::splitCss($style); |
| 485 | 485 | if (!$css) { |
@@ -510,7 +510,7 @@ discard block |
||
| 510 | 510 | */ |
| 511 | 511 | public function setCss(string $name, ?string $value) |
| 512 | 512 | { |
| 513 | - return $this->each(function (HtmlQuery $node) use ($name, $value) { |
|
| 513 | + return $this->each(function(HtmlQuery $node) use ($name, $value) { |
|
| 514 | 514 | if ((string) $value === '') { |
| 515 | 515 | $node->removeCss($name); |
| 516 | 516 | return; |
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | */ |
| 552 | 552 | public function removeCss(string $name) |
| 553 | 553 | { |
| 554 | - return $this->each(function (HtmlQuery $node) use ($name) { |
|
| 554 | + return $this->each(function(HtmlQuery $node) use ($name) { |
|
| 555 | 555 | $style = (string) $node->attr('style'); |
| 556 | 556 | if (!$style) { |
| 557 | 557 | return; |