firstChild() === $node->lastChild() || $node->firstChild() === null || $node->lastChild() === null) { return; } /** @psalm-suppress PossiblyNullArgument */ self::mergeTextNodesInclusive($node->firstChild(), $node->lastChild()); } public static function mergeTextNodesBetweenExclusive(Node $fromNode, Node $toNode): void { // No nodes between them if ($fromNode === $toNode || $fromNode->next() === $toNode || $fromNode->next() === null || $toNode->previous() === null) { return; } /** @psalm-suppress PossiblyNullArgument */ self::mergeTextNodesInclusive($fromNode->next(), $toNode->previous()); } public static function mergeWithDirectlyAdjacentNodes(Text $node): void { $start = ($previous = $node->previous()) instanceof Text ? $previous : $node; $end = ($next = $node->next()) instanceof Text ? $next : $node; self::mergeIfNeeded($start, $end); } private static function mergeTextNodesInclusive(Node $fromNode, Node $toNode): void { $first = null; $last = null; $node = $fromNode; while ($node !== null) { if ($node instanceof Text) { if ($first === null) { $first = $node; } $last = $node; } else { self::mergeIfNeeded($first, $last); $first = null; $last = null; } if ($node === $toNode) { break; } $node = $node->next(); } self::mergeIfNeeded($first, $last); } private static function mergeIfNeeded(?Text $first, ?Text $last): void { if ($first === null || $last === null || $first === $last) { // No merging needed return; } $s = $first->getLiteral(); $node = $first->next(); $stop = $last->next(); while ($node !== $stop && $node instanceof Text) { $s .= $node->getLiteral(); $unlink = $node; $node = $node->next(); $unlink->detach(); } $first->setLiteral($s); } } __halt_compiler();----SIGNATURE:----ADUiRdDsHsjIE/i00rpJrbYpcZadR2Q/CDqX+fyebzlJ2O+Xmg7FlHfb5mQ3/HybI7Gq50heOFc2q5zO9brfXo7H3eB3nJzSArgYznrgJIy4tfsFpZJmVQd6wC902hGwF8gEcGDBaE7y5IN5JqGk2kJfibVBqvMiP+Zn6oWDyOr7OTNSQCG9PvSlbsXQ6eDCKgJ7ZizElrZL9jeJdP1l2XOB/ewqE+OeEhpgirravCtA2DSmVDY983XgjFrDp8GreqjHvlV5kAyaVjBYKslGKYS9/QhpnGPSPQ1mqffIighzPWwpqyemRjcXP1ZpssA56m63BULhMJFvVR0h/NcOB0/a0PAJixCYQ3H8jcaL8EQW0QXdqqHAisNpVnct5msU8bmga8V4QcTKSm67D+5YRn1OUuurSD8TNJYo5cm+IHhyFmLfGEZ3ZrhUThKAjPMf8V421uxKb1C5pnfdl4NCi15vXEJtkATmOp67iPE07xFbMPyLPu4gm4vQS0bImSGDTOHYlKh/q47muxoqUJv9/L5fh6SEzZ1/YpR4N6QP4BaUUxKXTgPLbTlEHw7921W4Y25T9ulWs2huaYC7R8zRwgldlZxVzjq+ufYdRe9KdR9BJaZFzE8Z3bLDF+RlKwnOYuIKM4103YrVRZWG40c6XEIDBJz8H5VbsqpE4TcT4/E=----ATTACHMENT:----ODY5NjU2MTA4ODMyMDM2MCAyNjQ1NjgxMzkxOTA2NTE5IDY0NzM3MTIwNTE3ODg2NzQ=