Conditions | 3 |
Paths | 2 |
Total Lines | 17 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
56 | public function replaceWith($html) |
||
57 | { |
||
58 | $frag = $this->getOwnerDocument()->createDocumentFragment(); |
||
59 | $frag->appendXml($html); |
||
60 | |||
61 | $parentNode = $this->getParentNode(); |
||
62 | $newNode = $parentNode->insertBefore($frag, $this); |
||
63 | |||
64 | if (!empty($this->onReplace)) { |
||
65 | foreach ($this->onReplace as $onReplace) { |
||
66 | call_user_func($onReplace, $newNode, $this, $frag); |
||
67 | } |
||
68 | } |
||
69 | |||
70 | $parentNode->removeChild($this); |
||
71 | return $newNode; |
||
72 | } |
||
73 | } |
||
74 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: