protected function pushContext(Tag $tag)
	{
		$tagName   = $tag->getName();
		$tagFlags  = $tag->getFlags();
		$tagConfig = $this->tagsConfig[$tagName];

		++$this->cntTotal[$tagName];

		// If this is a self-closing tag, the context remains the same
		if ($tag->isSelfClosingTag())
		{
			return;
		}

		// Recompute the allowed tags
		$allowed = [];
		if ($tagFlags & self::RULE_IS_TRANSPARENT)
		{
			foreach ($this->context['allowed'] as $k => $v)
			{
				$allowed[] = $tagConfig['allowed'][$k] & $v;
			}
		}
		else
		{
			foreach ($this->context['allowed'] as $k => $v)
			{
				$allowed[] = $tagConfig['allowed'][$k] & (($v & 0xFF00) | ($v >> 8));
			}
		}

		// Use this tag's flags as a base for this context and add inherited rules
		$flags = $tagFlags | ($this->context['flags'] & self::RULES_INHERITANCE);

		// RULE_DISABLE_AUTO_BR turns off RULE_ENABLE_AUTO_BR
		if ($flags & self::RULE_DISABLE_AUTO_BR)
		{
			$flags &= ~self::RULE_ENABLE_AUTO_BR;
		}

		++$this->cntOpen[$tagName];
		$this->openTags[] = $tag;
		$this->context = [
			'allowed'       => $allowed,
			'flags'         => $flags,
			'inParagraph'   => false,
			'parentContext' => $this->context
		];
	}
protected function pushContext(Tag $tag)
	{
		$tagName   = $tag->getName();
		$tagFlags  = $tag->getFlags();
		$tagConfig = $this->tagsConfig[$tagName];

		++$this->cntTotal[$tagName];

		// If this is a self-closing tag, the context remains the same
		if ($tag->isSelfClosingTag())
		{
			return;
		}

		// Recompute the allowed tags
		$allowed = [];
		if ($tagFlags & self::RULE_IS_TRANSPARENT)
		{
			foreach ($this->context['allowed'] as $k => $v)
			{
				$allowed[] = $tagConfig['allowed'][$k] & $v;
			}
		}
		else
		{
			foreach ($this->context['allowed'] as $k => $v)
			{
				$allowed[] = $tagConfig['allowed'][$k] & (($v & 0xFF00) | ($v >> 8));
			}
		}

		// Use this tag's flags as a base for this context and add inherited rules
		$flags = $tagFlags | ($this->context['flags'] & self::RULES_INHERITANCE);

		// RULE_DISABLE_AUTO_BR turns off RULE_ENABLE_AUTO_BR
		if ($flags & self::RULE_DISABLE_AUTO_BR)
		{
			$flags &= ~self::RULE_ENABLE_AUTO_BR;
		}

		++$this->cntOpen[$tagName];
		$this->openTags[] = $tag;
		$this->context = [
			'allowed'       => $allowed,
			'flags'         => $flags,
			'inParagraph'   => false,
			'parentContext' => $this->context
		];
	}
protected function pushContext ( Tag $ tag ) { $ tagName = $ tag -> getName ( ) ; $ tagFlags = $ tag -> getFlags ( ) ; $ tagConfig = $ this -> tagsConfig [ $ tagName ] ; ++ $ this -> cntTotal [ $ tagName ] ; // If this is a self-closing tag, the context remains the same if ( $ tag -> isSelfClosingTag ( ) ) { return ; } // Recompute the allowed tags $ allowed = [ ] ; if ( $ tagFlags & self :: RULE_IS_TRANSPARENT ) { foreach ( $ this -> context [ 'allowed' ] as $ k => $ v ) { $ allowed [ ] = $ tagConfig [ 'allowed' ] [ $ k ] & $ v ; } } else { foreach ( $ this -> context [ 'allowed' ] as $ k => $ v ) { $ allowed [ ] = $ tagConfig [ 'allowed' ] [ $ k ] & ( ( $ v & 0xFF00 ) | ( $ v >> 8 ) ) ; } } // Use this tag's flags as a base for this context and add inherited rules $ flags = $ tagFlags | ( $ this -> context [ 'flags' ] & self :: RULES_INHERITANCE ) ; // RULE_DISABLE_AUTO_BR turns off RULE_ENABLE_AUTO_BR if ( $ flags & self :: RULE_DISABLE_AUTO_BR ) { $ flags &= ~ self :: RULE_ENABLE_AUTO_BR ; } ++ $ this -> cntOpen [ $ tagName ] ; $ this -> openTags [ ] = $ tag ; $ this -> context = [ 'allowed' => $ allowed , 'flags' => $ flags , 'inParagraph' => false , 'parentContext' => $ this -> context ] ; }
Update counters and replace current context with a new context based on given tag

If given tag is a self-closing tag, the context won't change

@param  Tag  $tag Start tag (including self-closing)
@return void
Update counters and replace current context with a new context based on given tag