public function format(Nodes\Node $node, Document $document) { $boundary = $node->getBoundary(); if (!$boundary->isClosed()) { list($x, $y) = $boundary->getFirstPoint()->toArray(); $attributesSnapshot = $node->getAttributesSnapshot(); $diffWidth = $node->getWidth() - $attributesSnapshot['width']; $width = $node->getWidth(); $x += $width; $yEnd = $y - $node->getHeight(); $boundary->setNext($x, $y)->setNext($x, $yEnd)->setNext($x - $width, $yEnd)->close(); if ($node->hadAutoMargins()) { $node->translate(-$diffWidth / 2, 0); } } }