public function closeUnmatchedBlocks() { while ($this->oldTip !== $this->lastMatchedContainer) { $oldTip = $this->oldTip->parent(); $this->oldTip->finalize($this->context, $this->context->getLineNumber() - 1); $this->oldTip = $oldTip; } }
/** * Finalize the block; mark it closed for modification * * @param ContextInterface $context */ public function finalize(ContextInterface $context) { if (!$this->open) { return; // TODO: Throw AlreadyClosedException? } $this->open = false; if ($context->getLineNumber() > $this->getStartLine()) { $this->endLine = $context->getLineNumber() - 1; } else { $this->endLine = $context->getLineNumber(); } $context->setTip($context->getTip()->getParent()); }
/** * @param ContextInterface $context * @param Cursor $cursor */ private function setAndPropagateLastLineBlank(ContextInterface $context, $cursor) { if ($cursor->isBlank() && ($lastChild = $context->getContainer()->lastChild())) { if ($lastChild instanceof AbstractBlock) { $lastChild->setLastLineBlank(true); } } $container = $context->getContainer(); $lastLineBlank = $container->shouldLastLineBeBlank($cursor, $context->getLineNumber()); // Propagate lastLineBlank up through parents: while ($container) { $container->setLastLineBlank($lastLineBlank); $container = $container->parent(); } }