1 | <?php |
||
13 | class SimpleHtmlDomNode extends \ArrayObject implements SimpleHtmlDomNodeInterface |
||
14 | { |
||
15 | /** |
||
16 | * @param $name |
||
17 | * |
||
18 | * @return string |
||
19 | */ |
||
20 | 2 | public function __get($name) |
|
32 | |||
33 | /** |
||
34 | * alias for "$this->innerHtml()" (added for compatibly-reasons with v1.x) |
||
35 | */ |
||
36 | public function outertext() |
||
40 | |||
41 | /** |
||
42 | * alias for "$this->innerHtml()" (added for compatibly-reasons with v1.x) |
||
43 | */ |
||
44 | public function innertext() |
||
48 | |||
49 | /** |
||
50 | * @param string $selector |
||
51 | * @param int $idx |
||
52 | * |
||
53 | * @return SimpleHtmlDom|SimpleHtmlDomNode|null |
||
54 | */ |
||
55 | public function __invoke($selector, $idx = null) |
||
59 | |||
60 | /** |
||
61 | * @return mixed |
||
62 | */ |
||
63 | public function __toString() |
||
67 | |||
68 | /** |
||
69 | * Find list of nodes with a CSS selector |
||
70 | * |
||
71 | * @param string $selector |
||
72 | * @param int $idx |
||
73 | * |
||
74 | * @return SimpleHtmlDomNode|SimpleHtmlDomNode[]|null |
||
75 | */ |
||
76 | 11 | public function find($selector, $idx = null) |
|
77 | { |
||
78 | 11 | $elements = new self(); |
|
79 | 11 | foreach ($this as $node) { |
|
80 | 11 | foreach ($node->find($selector) as $res) { |
|
81 | 11 | $elements->append($res); |
|
82 | } |
||
83 | } |
||
84 | |||
85 | 11 | if (null === $idx) { |
|
86 | 11 | return $elements; |
|
87 | } else { |
||
88 | if ($idx < 0) { |
||
89 | $idx = count($elements) + $idx; |
||
90 | } |
||
91 | } |
||
92 | |||
93 | return (isset($elements[$idx]) ? $elements[$idx] : null); |
||
94 | } |
||
95 | |||
96 | /** |
||
97 | * Get html of Elements |
||
98 | * |
||
99 | * @return string |
||
100 | */ |
||
101 | 1 | public function innerHtml() |
|
110 | |||
111 | /** |
||
112 | * Get plain text |
||
113 | * |
||
114 | * @return string |
||
115 | */ |
||
116 | 2 | public function text() |
|
125 | } |
||
126 |
PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.
Let’s take a look at an example:
If we look at the
getEmail()
method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:On the hand, if we look at the
setEmail()
, this method _has_ side-effects. In the following case, we could not remove the method call: