@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | /** |
55 | 55 | * @param string|NodeList|\DOMNode $input |
56 | 56 | * |
57 | - * @return NodeList |
|
57 | + * @return \DOMWrap\NodeList |
|
58 | 58 | */ |
59 | 59 | protected function inputAsNodeList($input): NodeList { |
60 | 60 | $nodes = $this->inputPrepareAsTraversable($input); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | /** |
87 | 87 | * @param string $html |
88 | 88 | * |
89 | - * @return NodeList |
|
89 | + * @return \DOMWrap\NodeList |
|
90 | 90 | */ |
91 | 91 | protected function nodesFromHtml($html): NodeList { |
92 | 92 | $class = get_class($this->document()); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | /** |
122 | 122 | * @param string|null $selector |
123 | 123 | * |
124 | - * @return NodeList |
|
124 | + * @return \DOMWrap\NodeList |
|
125 | 125 | */ |
126 | 126 | public function detach(string $selector = null): NodeList { |
127 | 127 | if (!is_null($selector)) { |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | } |
469 | 469 | |
470 | 470 | /** |
471 | - * @param Element $node |
|
471 | + * @param \DOMWrap\Element $node |
|
472 | 472 | * |
473 | 473 | * @return \SplStack |
474 | 474 | */ |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | } |
489 | 489 | |
490 | 490 | /** |
491 | - * @param Element $node |
|
491 | + * @param \DOMWrap\Element $node |
|
492 | 492 | * |
493 | 493 | * @return \SplStack |
494 | 494 | */ |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare(strict_types=1); |
|
1 | +<?php declare(strict_types = 1); |
|
2 | 2 | |
3 | 3 | namespace DOMWrap\Traits; |
4 | 4 | |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | * @return mixed |
26 | 26 | */ |
27 | 27 | public function __call(string $name, array $arguments) { |
28 | - if (!method_exists($this, '_' . $name)) { |
|
29 | - throw new \BadMethodCallException("Call to undefined method " . get_class($this) . '::' . $name . "()"); |
|
28 | + if (!method_exists($this, '_'.$name)) { |
|
29 | + throw new \BadMethodCallException("Call to undefined method ".get_class($this).'::'.$name."()"); |
|
30 | 30 | } |
31 | 31 | |
32 | - return call_user_func_array([$this, '_' . $name], $arguments); |
|
32 | + return call_user_func_array([$this, '_'.$name], $arguments); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | * @return string |
187 | 187 | */ |
188 | 188 | public function getText(): string { |
189 | - return (string)$this->collection()->reduce(function($carry, $node) { |
|
190 | - return $carry . $node->textContent; |
|
189 | + return (string) $this->collection()->reduce(function($carry, $node) { |
|
190 | + return $carry.$node->textContent; |
|
191 | 191 | }, ''); |
192 | 192 | } |
193 | 193 | |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | * @return bool |
322 | 322 | */ |
323 | 323 | public function hasAttr(string $name): bool { |
324 | - return (bool)$this->collection()->reduce(function($carry, $node) use ($name) { |
|
324 | + return (bool) $this->collection()->reduce(function($carry, $node) use ($name) { |
|
325 | 325 | if ($node->hasAttribute($name)) { |
326 | 326 | return true; |
327 | 327 | } |
@@ -454,10 +454,10 @@ discard block |
||
454 | 454 | * @return bool |
455 | 455 | */ |
456 | 456 | public function hasClass(string $class): bool { |
457 | - return (bool)$this->collection()->reduce(function($carry, $node) use ($class) { |
|
457 | + return (bool) $this->collection()->reduce(function($carry, $node) use ($class) { |
|
458 | 458 | $attr = $node->getAttr('class'); |
459 | 459 | |
460 | - return array_reduce(explode(' ', (string)$attr), function($carry, $item) use ($class) { |
|
460 | + return array_reduce(explode(' ', (string) $attr), function($carry, $item) use ($class) { |
|
461 | 461 | if (strcasecmp($item, $class) == 0) { |
462 | 462 | return true; |
463 | 463 | } |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | */ |
638 | 638 | public function getHtml(): string { |
639 | 639 | return $this->collection()->first()->children()->reduce(function($carry, $node) { |
640 | - return $carry . $this->document()->saveHTML($node); |
|
640 | + return $carry.$this->document()->saveHTML($node); |
|
641 | 641 | }, ''); |
642 | 642 | } |
643 | 643 |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | /** |
20 | 20 | * @param iterable $nodes |
21 | 21 | * |
22 | - * @return NodeList |
|
22 | + * @return \DOMWrap\NodeList |
|
23 | 23 | */ |
24 | 24 | public function newNodeList(iterable $nodes = null): NodeList { |
25 | 25 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @param string $selector |
39 | 39 | * @param string $prefix |
40 | 40 | * |
41 | - * @return NodeList |
|
41 | + * @return \DOMWrap\NodeList |
|
42 | 42 | */ |
43 | 43 | public function find(string $selector, string $prefix = 'descendant::'): NodeList { |
44 | 44 | $converter = new CssSelectorConverter(); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | /** |
50 | 50 | * @param string $xpath |
51 | 51 | * |
52 | - * @return NodeList |
|
52 | + * @return \DOMWrap\NodeList |
|
53 | 53 | */ |
54 | 54 | public function findXPath(string $xpath): NodeList { |
55 | 55 | $results = $this->newNodeList(); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @param string|NodeList|\DOMNode|callable $input |
74 | 74 | * @param bool $matchType |
75 | 75 | * |
76 | - * @return NodeList |
|
76 | + * @return \DOMWrap\NodeList |
|
77 | 77 | */ |
78 | 78 | protected function getNodesMatchingInput($input, bool $matchType = true): NodeList { |
79 | 79 | if ($input instanceof NodeList || $input instanceof \DOMNode) { |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | /** |
123 | 123 | * @param string|NodeList|\DOMNode|callable $input |
124 | 124 | * |
125 | - * @return NodeList |
|
125 | + * @return \DOMWrap\NodeList |
|
126 | 126 | */ |
127 | 127 | public function not($input): NodeList { |
128 | 128 | return $this->getNodesMatchingInput($input, false); |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | /** |
132 | 132 | * @param string|NodeList|\DOMNode|callable $input |
133 | 133 | * |
134 | - * @return NodeList |
|
134 | + * @return \DOMWrap\NodeList |
|
135 | 135 | */ |
136 | 136 | public function filter($input): NodeList { |
137 | 137 | return $this->getNodesMatchingInput($input); |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | /** |
141 | 141 | * @param string|NodeList|\DOMNode|callable $input |
142 | 142 | * |
143 | - * @return NodeList |
|
143 | + * @return \DOMWrap\NodeList |
|
144 | 144 | */ |
145 | 145 | public function has($input): NodeList { |
146 | 146 | if ($input instanceof NodeList || $input instanceof \DOMNode) { |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | /** |
188 | 188 | * @param string|NodeList|\DOMNode|callable $selector |
189 | 189 | * |
190 | - * @return NodeList |
|
190 | + * @return \DOMWrap\NodeList |
|
191 | 191 | */ |
192 | 192 | public function precedingAll($selector = null): NodeList { |
193 | 193 | return $this->precedingUntil(null, $selector); |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * @param string|NodeList|\DOMNode|callable $input |
198 | 198 | * @param string|NodeList|\DOMNode|callable $selector |
199 | 199 | * |
200 | - * @return NodeList |
|
200 | + * @return \DOMWrap\NodeList |
|
201 | 201 | */ |
202 | 202 | public function precedingUntil($input = null, $selector = null): NodeList { |
203 | 203 | return $this->_walkPathUntil('previousSibling', $input, $selector); |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | /** |
216 | 216 | * @param string|NodeList|\DOMNode|callable $selector |
217 | 217 | * |
218 | - * @return NodeList |
|
218 | + * @return \DOMWrap\NodeList |
|
219 | 219 | */ |
220 | 220 | public function followingAll($selector = null): NodeList { |
221 | 221 | return $this->followingUntil(null, $selector); |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * @param string|NodeList|\DOMNode|callable $input |
226 | 226 | * @param string|NodeList|\DOMNode|callable $selector |
227 | 227 | * |
228 | - * @return NodeList |
|
228 | + * @return \DOMWrap\NodeList |
|
229 | 229 | */ |
230 | 230 | public function followingUntil($input = null, $selector = null): NodeList { |
231 | 231 | return $this->_walkPathUntil('nextSibling', $input, $selector); |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | /** |
235 | 235 | * @param string|NodeList|\DOMNode|callable $selector |
236 | 236 | * |
237 | - * @return NodeList |
|
237 | + * @return \DOMWrap\NodeList |
|
238 | 238 | */ |
239 | 239 | public function siblings($selector = null): NodeList { |
240 | 240 | $results = $this->collection()->reduce(function($carry, $node) use ($selector) { |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | /** |
252 | 252 | * NodeList is only array like. Removing items using foreach() has undesired results. |
253 | 253 | * |
254 | - * @return NodeList |
|
254 | + * @return \DOMWrap\NodeList |
|
255 | 255 | */ |
256 | 256 | public function children(): NodeList { |
257 | 257 | $results = $this->collection()->reduce(function($carry, $node) { |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | /** |
291 | 291 | * @param string $selector |
292 | 292 | * |
293 | - * @return NodeList |
|
293 | + * @return \DOMWrap\NodeList |
|
294 | 294 | */ |
295 | 295 | public function parents(string $selector = null): NodeList { |
296 | 296 | return $this->parentsUntil(null, $selector); |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * @param string|NodeList|\DOMNode|callable $input |
301 | 301 | * @param string|NodeList|\DOMNode|callable $selector |
302 | 302 | * |
303 | - * @return NodeList |
|
303 | + * @return \DOMWrap\NodeList |
|
304 | 304 | */ |
305 | 305 | public function parentsUntil($input = null, $selector = null): NodeList { |
306 | 306 | return $this->_walkPathUntil('parentNode', $input, $selector); |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | /** |
344 | 344 | * NodeList is only array like. Removing items using foreach() has undesired results. |
345 | 345 | * |
346 | - * @return NodeList |
|
346 | + * @return \DOMWrap\NodeList |
|
347 | 347 | */ |
348 | 348 | public function contents(): NodeList { |
349 | 349 | $results = $this->collection()->reduce(function($carry, $node) { |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | /** |
361 | 361 | * @param string|NodeList|\DOMNode $input |
362 | 362 | * |
363 | - * @return NodeList |
|
363 | + * @return \DOMWrap\NodeList |
|
364 | 364 | */ |
365 | 365 | public function add($input): NodeList { |
366 | 366 | $nodes = $this->inputAsNodeList($input); |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | * @param string|NodeList|\DOMNode|callable $selector |
386 | 386 | * @param int $matchType |
387 | 387 | * |
388 | - * @return NodeList |
|
388 | + * @return \DOMWrap\NodeList |
|
389 | 389 | */ |
390 | 390 | protected function _buildNodeListUntil(\DOMNode $baseNode, string $property, $input = null, $selector = null, int $matchType = null): NodeList { |
391 | 391 | $resultNodes = $this->newNodeList(); |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | /** |
421 | 421 | * @param iterable $nodeLists |
422 | 422 | * |
423 | - * @return NodeList |
|
423 | + * @return \DOMWrap\NodeList |
|
424 | 424 | */ |
425 | 425 | protected function _uniqueNodes(iterable $nodeLists): NodeList { |
426 | 426 | $resultNodes = $this->newNodeList(); |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | * @param string|NodeList|\DOMNode|callable $selector |
447 | 447 | * @param int $matchType |
448 | 448 | * |
449 | - * @return NodeList |
|
449 | + * @return \DOMWrap\NodeList |
|
450 | 450 | */ |
451 | 451 | protected function _walkPathUntil(string $property, $input = null, $selector = null, int $matchType = null): NodeList { |
452 | 452 | $nodeLists = []; |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare(strict_types=1); |
|
1 | +<?php declare(strict_types = 1); |
|
2 | 2 | |
3 | 3 | namespace DOMWrap\Traits; |
4 | 4 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | }; |
98 | 98 | |
99 | 99 | } else { |
100 | - throw new \InvalidArgumentException('Unexpected input value of type "' . gettype($input) . '"'); |
|
100 | + throw new \InvalidArgumentException('Unexpected input value of type "'.gettype($input).'"'); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | // Build a list of matching nodes. |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | $fn = $input; |
170 | 170 | |
171 | 171 | } else { |
172 | - throw new \InvalidArgumentException('Unexpected input value of type "' . gettype($input) . '"'); |
|
172 | + throw new \InvalidArgumentException('Unexpected input value of type "'.gettype($input).'"'); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | return $this->getNodesMatchingInput($fn); |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | */ |
348 | 348 | public function contents(): NodeList { |
349 | 349 | $results = $this->collection()->reduce(function($carry, $node) { |
350 | - if($node->isRemoved()) |
|
350 | + if ($node->isRemoved()) |
|
351 | 351 | return $this->newNodeList(); |
352 | 352 | return $carry->merge( |
353 | 353 | $node->newNodeList($node->childNodes) |
@@ -347,8 +347,9 @@ |
||
347 | 347 | */ |
348 | 348 | public function contents(): NodeList { |
349 | 349 | $results = $this->collection()->reduce(function($carry, $node) { |
350 | - if($node->isRemoved()) |
|
351 | - return $this->newNodeList(); |
|
350 | + if($node->isRemoved()) { |
|
351 | + return $this->newNodeList(); |
|
352 | + } |
|
352 | 353 | return $carry->merge( |
353 | 354 | $node->newNodeList($node->childNodes) |
354 | 355 | ); |
@@ -1,4 +1,4 @@ |
||
1 | -<?php declare(strict_types=1); |
|
1 | +<?php declare(strict_types = 1); |
|
2 | 2 | |
3 | 3 | namespace DOMWrap; |
4 | 4 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare(strict_types=1); |
|
1 | +<?php declare(strict_types = 1); |
|
2 | 2 | |
3 | 3 | namespace DOMWrap; |
4 | 4 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | $html = mb_convert_encoding($html, 'UTF-8', $charset); |
117 | 117 | } |
118 | 118 | |
119 | - $this->loadHTML('<?xml encoding="utf-8"?>' . $html); |
|
119 | + $this->loadHTML('<?xml encoding="utf-8"?>'.$html); |
|
120 | 120 | |
121 | 121 | libxml_use_internal_errors($internalErrors); |
122 | 122 | libxml_disable_entity_loader($disableEntities); |
@@ -1,4 +1,4 @@ |
||
1 | -<?php declare(strict_types=1); |
|
1 | +<?php declare(strict_types = 1); |
|
2 | 2 | |
3 | 3 | namespace DOMWrap\Traits; |
4 | 4 |
@@ -1,4 +1,4 @@ |
||
1 | -<?php declare(strict_types=1); |
|
1 | +<?php declare(strict_types = 1); |
|
2 | 2 | |
3 | 3 | namespace DOMWrap\Collections; |
4 | 4 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare(strict_types=1); |
|
1 | +<?php declare(strict_types = 1); |
|
2 | 2 | |
3 | 3 | namespace DOMWrap; |
4 | 4 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $result = $this->__manipulationCall($name, $arguments); |
48 | 48 | } catch (\BadMethodCallException $e) { |
49 | 49 | if (!method_exists($this->first(), $name)) { |
50 | - throw new \BadMethodCallException("Call to undefined method " . get_class($this) . '::' . $name . "()"); |
|
50 | + throw new \BadMethodCallException("Call to undefined method ".get_class($this).'::'.$name."()"); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | $result = call_user_func_array([$this->first(), $name], $arguments); |
@@ -1,4 +1,4 @@ |
||
1 | -<?php declare(strict_types=1); |
|
1 | +<?php declare(strict_types = 1); |
|
2 | 2 | |
3 | 3 | namespace DOMWrap; |
4 | 4 |
@@ -1,4 +1,4 @@ |
||
1 | -<?php declare(strict_types=1); |
|
1 | +<?php declare(strict_types = 1); |
|
2 | 2 | |
3 | 3 | namespace DOMWrap; |
4 | 4 |