RemexHtml
Fast HTML 5 parser
Loading...
Searching...
No Matches
Wikimedia\RemexHtml\TreeBuilder\CachingStack Class Reference

An implementation of the "stack of open elements" which includes a cache of elements currently in the various kinds of scope. More...

+ Inheritance diagram for Wikimedia\RemexHtml\TreeBuilder\CachingStack:

Public Member Functions

 push (Element $elt)
 Push an element.
 
 pop ()
 Pop an element from the stack.
 
 replace (Element $oldElt, Element $elt)
 Replace an element which is on the stack with another element of the same type (i.e.
 
 remove (Element $elt)
 Remove an element, potentially from the middle of the stack.
 
 isInScope ( $name)
 Is there an element in (default) scope which is in the HTML namespace and has the given tag name?
 
 isElementInScope (Element $elt)
 Is the given element in (default) scope?
 
 isOneOfSetInScope ( $names)
 Is there any element in the (default) scope which is in the HTML namespace and has one of the given tag names?
 
 isInListScope ( $name)
 Is there an element in list scope which is an HTML element with the given name?
 
 isInButtonScope ( $name)
 Is there an element in button scope which is an HTML element with the given name?
 
 isInTableScope ( $name)
 Is there an element in table scope which is an HTML element with the given name?
 
 isInSelectScope ( $name)
 Is there an element in select scope which is an HTML element with the given name?
 
 item ( $idx)
 Get an element from the stack, where 0 is the first element inserted, and $this->length() - 1 is the most recently inserted element.
 
 length ()
 Get the number of elements in the stack.
 
 hasTemplate ()
 Is there a template element in the stack of open elements?
 
 dump ()
 Get a string representation of the stack for debugging purposes.
 

Additional Inherited Members

- Public Attributes inherited from Wikimedia\RemexHtml\TreeBuilder\Stack
 $current
 

Detailed Description

An implementation of the "stack of open elements" which includes a cache of elements currently in the various kinds of scope.

It presumably has good worst-case performance at the expense of somewhat slower updates.

Member Function Documentation

◆ dump()

Wikimedia\RemexHtml\TreeBuilder\CachingStack::dump ( )

Get a string representation of the stack for debugging purposes.

Returns
string

Reimplemented from Wikimedia\RemexHtml\TreeBuilder\Stack.

◆ hasTemplate()

Wikimedia\RemexHtml\TreeBuilder\CachingStack::hasTemplate ( )

Is there a template element in the stack of open elements?

Returns
bool

Reimplemented from Wikimedia\RemexHtml\TreeBuilder\Stack.

◆ isElementInScope()

Wikimedia\RemexHtml\TreeBuilder\CachingStack::isElementInScope ( Element $elt)

Is the given element in (default) scope?

Parameters
Element$elt
Returns
bool

Reimplemented from Wikimedia\RemexHtml\TreeBuilder\Stack.

◆ isInButtonScope()

Wikimedia\RemexHtml\TreeBuilder\CachingStack::isInButtonScope ( $name)

Is there an element in button scope which is an HTML element with the given name?

Parameters
string$name
Returns
bool

Reimplemented from Wikimedia\RemexHtml\TreeBuilder\Stack.

◆ isInListScope()

Wikimedia\RemexHtml\TreeBuilder\CachingStack::isInListScope ( $name)

Is there an element in list scope which is an HTML element with the given name?

Parameters
string$name
Returns
bool

Reimplemented from Wikimedia\RemexHtml\TreeBuilder\Stack.

◆ isInScope()

Wikimedia\RemexHtml\TreeBuilder\CachingStack::isInScope ( $name)

Is there an element in (default) scope which is in the HTML namespace and has the given tag name?

Parameters
string$name
Returns
bool

Reimplemented from Wikimedia\RemexHtml\TreeBuilder\Stack.

◆ isInSelectScope()

Wikimedia\RemexHtml\TreeBuilder\CachingStack::isInSelectScope ( $name)

Is there an element in select scope which is an HTML element with the given name?

Parameters
string$name
Returns
bool

Reimplemented from Wikimedia\RemexHtml\TreeBuilder\Stack.

◆ isInTableScope()

Wikimedia\RemexHtml\TreeBuilder\CachingStack::isInTableScope ( $name)

Is there an element in table scope which is an HTML element with the given name?

Parameters
string$name
Returns
bool

Reimplemented from Wikimedia\RemexHtml\TreeBuilder\Stack.

◆ isOneOfSetInScope()

Wikimedia\RemexHtml\TreeBuilder\CachingStack::isOneOfSetInScope ( $names)

Is there any element in the (default) scope which is in the HTML namespace and has one of the given tag names?

Parameters
array<string,mixed>$names An array with the tag names in the keys, the value arbitrary
Returns
bool

Reimplemented from Wikimedia\RemexHtml\TreeBuilder\Stack.

◆ item()

Wikimedia\RemexHtml\TreeBuilder\CachingStack::item ( $idx)

Get an element from the stack, where 0 is the first element inserted, and $this->length() - 1 is the most recently inserted element.

This will raise a PHP notice if the index is out of range.

Parameters
int$idx
Returns
Element|null

Reimplemented from Wikimedia\RemexHtml\TreeBuilder\Stack.

◆ length()

Wikimedia\RemexHtml\TreeBuilder\CachingStack::length ( )

Get the number of elements in the stack.

Returns
int

Reimplemented from Wikimedia\RemexHtml\TreeBuilder\Stack.

◆ pop()

Wikimedia\RemexHtml\TreeBuilder\CachingStack::pop ( )

Pop an element from the stack.

Returns
Element|null

Reimplemented from Wikimedia\RemexHtml\TreeBuilder\Stack.

◆ push()

Wikimedia\RemexHtml\TreeBuilder\CachingStack::push ( Element $elt)

Push an element.

Parameters
Element$elt

Reimplemented from Wikimedia\RemexHtml\TreeBuilder\Stack.

◆ remove()

Wikimedia\RemexHtml\TreeBuilder\CachingStack::remove ( Element $elt)

Remove an element, potentially from the middle of the stack.

Parameters
Element$elt

Reimplemented from Wikimedia\RemexHtml\TreeBuilder\Stack.

◆ replace()

Wikimedia\RemexHtml\TreeBuilder\CachingStack::replace ( Element $old,
Element $new )

Replace an element which is on the stack with another element of the same type (i.e.

with the same tag name).

Parameters
Element$oldThe element to be removed
Element$newThe element to be inserted

Reimplemented from Wikimedia\RemexHtml\TreeBuilder\Stack.


The documentation for this class was generated from the following file: