Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 12 |
CRAP | |
0.00% |
0 / 1 |
| DestructTracer | |
0.00% |
0 / 12 |
|
0.00% |
0 / 12 |
156 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| startDocument | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| endDocument | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| characters | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| insertElement | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| endTag | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| doctype | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| comment | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| error | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| mergeAttributes | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| removeNode | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| reparentChildren | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | declare( strict_types = 1 ); |
| 3 | |
| 4 | namespace Wikimedia\RemexHtml\TreeBuilder; |
| 5 | |
| 6 | use Wikimedia\RemexHtml\Tokenizer\Attributes; |
| 7 | |
| 8 | /** |
| 9 | * A debugging helper which calls a callback function with a descriptive message |
| 10 | * each time an Element node is destroyed. |
| 11 | */ |
| 12 | class DestructTracer implements TreeHandler { |
| 13 | /** @var callable */ |
| 14 | private $callback; |
| 15 | |
| 16 | /** |
| 17 | * @param callable $callback |
| 18 | */ |
| 19 | public function __construct( $callback ) { |
| 20 | $this->callback = $callback; |
| 21 | } |
| 22 | |
| 23 | /** @inheritDoc */ |
| 24 | public function startDocument( $fragmentNamespace, $fragmentName ) { |
| 25 | } |
| 26 | |
| 27 | /** @inheritDoc */ |
| 28 | public function endDocument( $pos ) { |
| 29 | } |
| 30 | |
| 31 | /** @inheritDoc */ |
| 32 | public function characters( $preposition, $ref, $text, $start, $length, |
| 33 | $sourceStart, $sourceLength |
| 34 | ) { |
| 35 | } |
| 36 | |
| 37 | /** @inheritDoc */ |
| 38 | public function insertElement( $preposition, $ref, Element $element, $void, |
| 39 | $sourceStart, $sourceLength |
| 40 | ) { |
| 41 | $element->userData = new DestructTracerNode( $this->callback, $element->getDebugTag() ); |
| 42 | } |
| 43 | |
| 44 | /** @inheritDoc */ |
| 45 | public function endTag( Element $element, $sourceStart, $sourceLength ) { |
| 46 | } |
| 47 | |
| 48 | /** @inheritDoc */ |
| 49 | public function doctype( $name, $public, $system, $quirks, $sourceStart, $sourceLength ) { |
| 50 | } |
| 51 | |
| 52 | /** @inheritDoc */ |
| 53 | public function comment( $preposition, $ref, $text, $sourceStart, $sourceLength ) { |
| 54 | } |
| 55 | |
| 56 | /** @inheritDoc */ |
| 57 | public function error( $text, $pos ) { |
| 58 | } |
| 59 | |
| 60 | /** @inheritDoc */ |
| 61 | public function mergeAttributes( Element $element, Attributes $attrs, $sourceStart ) { |
| 62 | } |
| 63 | |
| 64 | /** @inheritDoc */ |
| 65 | public function removeNode( Element $element, $sourceStart ) { |
| 66 | } |
| 67 | |
| 68 | /** @inheritDoc */ |
| 69 | public function reparentChildren( Element $element, Element $newParent, $sourceStart ) { |
| 70 | $newParent->userData = new DestructTracerNode( $this->callback, $newParent->getDebugTag() ); |
| 71 | } |
| 72 | } |