class Optimizer extends IRProcessor

Constants

XMLNS_XSL

XSL namespace

Properties

protected DOMXPath $xpath from  IRProcessor

Methods

appendElement(DOMElement $parentNode, string $name, string $value = '')

Create and append an element to given node in the IR

void
createXPath(DOMDocument $dom)

Create and store an instance of DOMXPath for given document

mixed
evaluate(string $expr, DOMNode|null $node = null)

Evaluate an XPath expression and return its result

query(string $query, DOMNode|null $node = null)

Run an XPath query and return its result

void
optimize(DOMDocument $ir)

Optimize an IR

void
cloneCloseTagElementsIntoSwitch()

Clone closeTag elements that follow a switch into said switch

void
cloneCloseTagElementsOutOfSwitch()

Clone closeTag elements from the head of a switch's cases before said switch

void
mergeConsecutiveLiteralOutputElements()

Merge consecutive literal outputs

bool
nextSiblingIsLiteralOutput(DOMElement $node, string $disableOutputEscaping)

Test whether the next sibling of an element is a literal output element with matching escaping

void
optimizeCloseTagElements()

Optimize closeTags elements

void
removeCloseTagSiblings()

Remove redundant closeTag siblings after a switch

void
removeContentFromVoidElements()

Remove content from void elements

void
removeEmptyDefaultCases()

Remove empty default cases (no test and no descendants)

void
removeNodes(string $query, DOMNode|null $contextNode = null)

Remove all nodes that match given XPath query

void
removeRedundantCloseTagElements()

Remove redundant closeTag elements from the tail of a switch's cases

void
removeRedundantCloseTagElementsInSwitch()

Remove redundant closeTag elements from the tail of a switch's cases

Details

in IRProcessor at line 35
protected DOMElement appendElement(DOMElement $parentNode, string $name, string $value = '')

Create and append an element to given node in the IR

Parameters

DOMElement $parentNode

Parent node of the element

string $name

Tag name of the element

string $value

Value of the element

Return Value

DOMElement

The created element

in IRProcessor at line 46
protected void createXPath(DOMDocument $dom)

Create and store an instance of DOMXPath for given document

Parameters

DOMDocument $dom

Return Value

void

in IRProcessor at line 58
protected mixed evaluate(string $expr, DOMNode|null $node = null)

Evaluate an XPath expression and return its result

Parameters

string $expr

XPath expression

DOMNode|null $node

Context node

Return Value

mixed

in IRProcessor at line 70
protected DOMNodeList query(string $query, DOMNode|null $node = null)

Run an XPath query and return its result

Parameters

string $query

XPath query

DOMNode|null $node

Context node

Return Value

DOMNodeList

at line 22
void optimize(DOMDocument $ir)

Optimize an IR

Parameters

DOMDocument $ir

Return Value

void

at line 55
protected void cloneCloseTagElementsIntoSwitch()

Clone closeTag elements that follow a switch into said switch

If there's a right after a , clone the at the end of the every that does not end with a

Return Value

void

at line 79
protected void cloneCloseTagElementsOutOfSwitch()

Clone closeTag elements from the head of a switch's cases before said switch

If there's a at the beginning of every , clone it and insert it right before the unless there's already one

Return Value

void

at line 94
protected void mergeConsecutiveLiteralOutputElements()

Merge consecutive literal outputs

Return Value

void

at line 114
protected bool nextSiblingIsLiteralOutput(DOMElement $node, string $disableOutputEscaping)

Test whether the next sibling of an element is a literal output element with matching escaping

Parameters

DOMElement $node
string $disableOutputEscaping

Return Value

bool

at line 124
protected void optimizeCloseTagElements()

Optimize closeTags elements

Return Value

void

at line 139
protected void removeCloseTagSiblings()

Remove redundant closeTag siblings after a switch

If all branches of a switch have a closeTag we can remove any closeTag siblings of the switch

Return Value

void

at line 153
protected void removeContentFromVoidElements()

Remove content from void elements

For each void element, we find whichever elements close it and remove everything after

Return Value

void

at line 169
protected void removeEmptyDefaultCases()

Remove empty default cases (no test and no descendants)

Return Value

void

at line 182
protected void removeNodes(string $query, DOMNode|null $contextNode = null)

Remove all nodes that match given XPath query

Parameters

string $query
DOMNode|null $contextNode

Return Value

void

at line 201
protected void removeRedundantCloseTagElements()

Remove redundant closeTag elements from the tail of a switch's cases

For each remove duplicate nodes that are either siblings or descendants of a sibling

Return Value

void

at line 220
protected void removeRedundantCloseTagElementsInSwitch()

Remove redundant closeTag elements from the tail of a switch's cases

If there's a right after a , remove all nodes at the end of every

Return Value

void