protected function closeAncestor(Tag $tag)
	{
		if (!empty($this->openTags))
		{
			$tagName   = $tag->getName();
			$tagConfig = $this->tagsConfig[$tagName];

			if (!empty($tagConfig['rules']['closeAncestor']))
			{
				$i = count($this->openTags);

				while (--$i >= 0)
				{
					$ancestor     = $this->openTags[$i];
					$ancestorName = $ancestor->getName();

					if (isset($tagConfig['rules']['closeAncestor'][$ancestorName]))
					{
						++$this->currentFixingCost;

						// We have to close this ancestor. First we reinsert this tag...
						$this->tagStack[] = $tag;

						// ...then we add a new end tag for it with a better priority
						$this->addMagicEndTag($ancestor, $tag->getPos(), $tag->getSortPriority() - 1);

						return true;
					}
				}
			}
		}

		return false;
	}
protected function closeAncestor(Tag $tag)
	{
		if (!empty($this->openTags))
		{
			$tagName   = $tag->getName();
			$tagConfig = $this->tagsConfig[$tagName];

			if (!empty($tagConfig['rules']['closeAncestor']))
			{
				$i = count($this->openTags);

				while (--$i >= 0)
				{
					$ancestor     = $this->openTags[$i];
					$ancestorName = $ancestor->getName();

					if (isset($tagConfig['rules']['closeAncestor'][$ancestorName]))
					{
						++$this->currentFixingCost;

						// We have to close this ancestor. First we reinsert this tag...
						$this->tagStack[] = $tag;

						// ...then we add a new end tag for it with a better priority
						$this->addMagicEndTag($ancestor, $tag->getPos(), $tag->getSortPriority() - 1);

						return true;
					}
				}
			}
		}

		return false;
	}
protected function closeAncestor ( Tag $ tag ) { if ( ! empty ( $ this -> openTags ) ) { $ tagName = $ tag -> getName ( ) ; $ tagConfig = $ this -> tagsConfig [ $ tagName ] ; if ( ! empty ( $ tagConfig [ 'rules' ] [ 'closeAncestor' ] ) ) { $ i = count ( $ this -> openTags ) ; while ( -- $ i >= 0 ) { $ ancestor = $ this -> openTags [ $ i ] ; $ ancestorName = $ ancestor -> getName ( ) ; if ( isset ( $ tagConfig [ 'rules' ] [ 'closeAncestor' ] [ $ ancestorName ] ) ) { ++ $ this -> currentFixingCost ; // We have to close this ancestor. First we reinsert this tag... $ this -> tagStack [ ] = $ tag ; // ...then we add a new end tag for it with a better priority $ this -> addMagicEndTag ( $ ancestor , $ tag -> getPos ( ) , $ tag -> getSortPriority ( ) - 1 ) ; return true ; } } } } return false ; }
Apply closeAncestor rules associated with given tag

@param  Tag  $tag Tag
@return bool      Whether a new tag has been added
Apply closeAncestor rules associated with given tag