@@ -46,7 +46,7 @@ |
||
46 | 46 | * node object. |
47 | 47 | * |
48 | 48 | * @param AbstractNode $node |
49 | - * @return array|Collection |
|
49 | + * @return Collection |
|
50 | 50 | */ |
51 | 51 | public function find(AbstractNode $node) |
52 | 52 | { |
@@ -225,8 +225,7 @@ discard block |
||
225 | 225 | try |
226 | 226 | { |
227 | 227 | $child = $node->nextChild($child->id()); |
228 | - } |
|
229 | - catch (ChildNotFoundException $e) |
|
228 | + } catch (ChildNotFoundException $e) |
|
230 | 229 | { |
231 | 230 | // no more children |
232 | 231 | $child = null; |
@@ -253,8 +252,7 @@ discard block |
||
253 | 252 | { |
254 | 253 | $pass = false; |
255 | 254 | } |
256 | - } |
|
257 | - else |
|
255 | + } else |
|
258 | 256 | { |
259 | 257 | if ($rule['key'] != 'plaintext' and |
260 | 258 | is_null($child->getAttribute($rule['key'])) |
@@ -274,8 +272,7 @@ discard block |
||
274 | 272 | { |
275 | 273 | // plaintext search |
276 | 274 | $nodeValue = $child->text(); |
277 | - } |
|
278 | - else |
|
275 | + } else |
|
279 | 276 | { |
280 | 277 | // normal search |
281 | 278 | $nodeValue = $child->getAttribute($rule['key']); |
@@ -310,8 +307,7 @@ discard block |
||
310 | 307 | { |
311 | 308 | // it passed all checks |
312 | 309 | $return[] = $child; |
313 | - } |
|
314 | - else |
|
310 | + } else |
|
315 | 311 | { |
316 | 312 | // this child failed to be matched |
317 | 313 | if ($child->hasChildren()) |
@@ -325,8 +321,7 @@ discard block |
||
325 | 321 | { |
326 | 322 | // get next child |
327 | 323 | $child = $node->nextChild($child->id()); |
328 | - } |
|
329 | - catch (ChildNotFoundException $e) |
|
324 | + } catch (ChildNotFoundException $e) |
|
330 | 325 | { |
331 | 326 | // no more children |
332 | 327 | $child = null; |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * new object. |
62 | 62 | * |
63 | 63 | * @param string $str |
64 | - * @return $this |
|
64 | + * @return Dom |
|
65 | 65 | */ |
66 | 66 | public static function load($str) |
67 | 67 | { |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * new object. |
77 | 77 | * |
78 | 78 | * @param string $file |
79 | - * @return $this |
|
79 | + * @return Dom |
|
80 | 80 | */ |
81 | 81 | public static function loadFromFile($file) |
82 | 82 | { |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @param string $url |
94 | 94 | * @param CurlInterface $curl |
95 | - * @return $this |
|
95 | + * @return Dom |
|
96 | 96 | */ |
97 | 97 | public static function loadFromUrl($url, CurlInterface $curl = null) |
98 | 98 | { |
@@ -26,8 +26,7 @@ |
||
26 | 26 | if (self::$dom instanceof Dom) |
27 | 27 | { |
28 | 28 | return call_user_func_array([self::$dom, $method], $arguments); |
29 | - } |
|
30 | - else |
|
29 | + } else |
|
31 | 30 | { |
32 | 31 | throw new NotLoadedException('The dom is not loaded. Can not call a dom method.'); |
33 | 32 | } |
@@ -231,8 +231,7 @@ |
||
231 | 231 | $nodes[] = $child; |
232 | 232 | $child = $this->nextChild($child->id()); |
233 | 233 | } while ( ! is_null($child)); |
234 | - } |
|
235 | - catch (ChildNotFoundException $e) |
|
234 | + } catch (ChildNotFoundException $e) |
|
236 | 235 | { |
237 | 236 | // we are done looking for children |
238 | 237 | } |
@@ -224,12 +224,10 @@ discard block |
||
224 | 224 | if (is_null($val)) |
225 | 225 | { |
226 | 226 | $return .= ' '.$key; |
227 | - } |
|
228 | - elseif ($info['doubleQuote']) |
|
227 | + } elseif ($info['doubleQuote']) |
|
229 | 228 | { |
230 | 229 | $return .= ' '.$key.'="'.$val.'"'; |
231 | - } |
|
232 | - else |
|
230 | + } else |
|
233 | 231 | { |
234 | 232 | $return .= ' '.$key.'=\''.$val.'\''; |
235 | 233 | } |
@@ -238,8 +236,7 @@ discard block |
||
238 | 236 | if ($this->selfClosing) |
239 | 237 | { |
240 | 238 | return $return.' />'; |
241 | - } |
|
242 | - else |
|
239 | + } else |
|
243 | 240 | { |
244 | 241 | return $return.'>'; |
245 | 242 | } |
@@ -36,8 +36,7 @@ discard block |
||
36 | 36 | if ($node instanceof AbstractNode) |
37 | 37 | { |
38 | 38 | return call_user_func_array([$node, $method], $arguments); |
39 | - } |
|
40 | - else |
|
39 | + } else |
|
41 | 40 | { |
42 | 41 | throw new EmptyCollectionException('The collection does not contain any Nodes.'); |
43 | 42 | } |
@@ -57,8 +56,7 @@ discard block |
||
57 | 56 | if ($node instanceof AbstractNode) |
58 | 57 | { |
59 | 58 | return $node->$key; |
60 | - } |
|
61 | - else |
|
59 | + } else |
|
62 | 60 | { |
63 | 61 | throw new EmptyCollectionException('The collection does not contain any Nodes.'); |
64 | 62 | } |
@@ -77,8 +75,7 @@ discard block |
||
77 | 75 | if ($node instanceof AbstractNode) |
78 | 76 | { |
79 | 77 | return (string)$node; |
80 | - } |
|
81 | - else |
|
78 | + } else |
|
82 | 79 | { |
83 | 80 | throw new EmptyCollectionException('The collection does not contain any Nodes.'); |
84 | 81 | } |
@@ -115,8 +112,7 @@ discard block |
||
115 | 112 | if (is_null($offset)) |
116 | 113 | { |
117 | 114 | $this->collection[] = $value; |
118 | - } |
|
119 | - else |
|
115 | + } else |
|
120 | 116 | { |
121 | 117 | $this->collection[$offset] = $value; |
122 | 118 | } |
@@ -68,8 +68,7 @@ |
||
68 | 68 | $this->convertedText = $text; |
69 | 69 | |
70 | 70 | return $text; |
71 | - } |
|
72 | - else |
|
71 | + } else |
|
73 | 72 | { |
74 | 73 | return $this->text; |
75 | 74 | } |
@@ -82,12 +82,10 @@ discard block |
||
82 | 82 | if ($child instanceof TextNode) |
83 | 83 | { |
84 | 84 | $string .= $child->text(); |
85 | - } |
|
86 | - elseif ($child instanceof HtmlNode) |
|
85 | + } elseif ($child instanceof HtmlNode) |
|
87 | 86 | { |
88 | 87 | $string .= $child->outerHtml(); |
89 | - } |
|
90 | - else |
|
88 | + } else |
|
91 | 89 | { |
92 | 90 | throw new UnknownChildTypeException('Unknown child type "'.get_class($child).'" found in node'); |
93 | 91 | } |
@@ -95,8 +93,7 @@ discard block |
||
95 | 93 | try |
96 | 94 | { |
97 | 95 | $child = $this->nextChild($child->id()); |
98 | - } |
|
99 | - catch (ChildNotFoundException $e) |
|
96 | + } catch (ChildNotFoundException $e) |
|
100 | 97 | { |
101 | 98 | // no more children |
102 | 99 | $child = null; |
@@ -164,8 +161,7 @@ discard block |
||
164 | 161 | // we already know the results. |
165 | 162 | return $this->textWithChildren; |
166 | 163 | } |
167 | - } |
|
168 | - elseif ( ! is_null($this->text)) |
|
164 | + } elseif ( ! is_null($this->text)) |
|
169 | 165 | { |
170 | 166 | // we already know the results. |
171 | 167 | return $this->text; |
@@ -180,8 +176,7 @@ discard block |
||
180 | 176 | if ($node instanceof TextNode) |
181 | 177 | { |
182 | 178 | $text .= $child['node']->text; |
183 | - } |
|
184 | - elseif ($lookInChildren and |
|
179 | + } elseif ($lookInChildren and |
|
185 | 180 | $node instanceof HtmlNode |
186 | 181 | ) |
187 | 182 | { |
@@ -193,8 +188,7 @@ discard block |
||
193 | 188 | if ($lookInChildren) |
194 | 189 | { |
195 | 190 | $this->textWithChildren = $text; |
196 | - } |
|
197 | - else |
|
191 | + } else |
|
198 | 192 | { |
199 | 193 | $this->text = $text; |
200 | 194 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | { |
179 | 179 | $this->options = new Options; |
180 | 180 | $this->options->setOptions($this->globalOptions) |
181 | - ->setOptions($option); |
|
181 | + ->setOptions($option); |
|
182 | 182 | |
183 | 183 | $this->rawSize = strlen($str); |
184 | 184 | $this->raw = $str; |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | { |
501 | 501 | // end tag |
502 | 502 | $tag = $this->content->fastForward(1) |
503 | - ->copyByToken('slash', true); |
|
503 | + ->copyByToken('slash', true); |
|
504 | 504 | // move to end of tag |
505 | 505 | $this->content->copyUntil('>'); |
506 | 506 | $this->content->fastForward(1); |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | { |
555 | 555 | $attr = []; |
556 | 556 | $this->content->fastForward(1) |
557 | - ->skipByToken('blank'); |
|
557 | + ->skipByToken('blank'); |
|
558 | 558 | switch ($this->content->char()) |
559 | 559 | { |
560 | 560 | case '"': |
@@ -464,8 +464,7 @@ discard block |
||
464 | 464 | { |
465 | 465 | $activeNode = $node; |
466 | 466 | } |
467 | - } |
|
468 | - else if ($this->options->whitespaceTextNode or |
|
467 | + } else if ($this->options->whitespaceTextNode or |
|
469 | 468 | trim($str) != '' |
470 | 469 | ) |
471 | 470 | { |
@@ -512,8 +511,7 @@ discard block |
||
512 | 511 | $return['status'] = true; |
513 | 512 | |
514 | 513 | return $return; |
515 | - } |
|
516 | - else |
|
514 | + } else |
|
517 | 515 | { |
518 | 516 | $return['status'] = true; |
519 | 517 | $return['closing'] = true; |
@@ -589,8 +587,7 @@ discard block |
||
589 | 587 | $node->getTag()->$name = $attr; |
590 | 588 | break; |
591 | 589 | } |
592 | - } |
|
593 | - else |
|
590 | + } else |
|
594 | 591 | { |
595 | 592 | // no value attribute |
596 | 593 | if ($this->options->strict) |
@@ -616,8 +613,7 @@ discard block |
||
616 | 613 | // self closing tag |
617 | 614 | $node->getTag()->selfClosing(); |
618 | 615 | $this->content->fastForward(1); |
619 | - } |
|
620 | - elseif (in_array($tag, $this->selfClosing)) |
|
616 | + } elseif (in_array($tag, $this->selfClosing)) |
|
621 | 617 | { |
622 | 618 | |
623 | 619 | // Should be a self closing tag, check if we are strict |
@@ -152,13 +152,11 @@ |
||
152 | 152 | |
153 | 153 | $found = true; |
154 | 154 | } |
155 | - } |
|
156 | - elseif ($char) |
|
155 | + } elseif ($char) |
|
157 | 156 | { |
158 | 157 | $position = strcspn($this->content, $string, $this->pos); |
159 | 158 | $position += $this->pos; |
160 | - } |
|
161 | - else |
|
159 | + } else |
|
162 | 160 | { |
163 | 161 | $position = strpos($this->content, $string, $this->pos); |
164 | 162 | } |