mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-12-02 21:19:58 +09:00
Dependency updates and update version number
This commit is contained in:
@@ -43,38 +43,17 @@ class AttributeMatchingExtension extends AbstractExtension
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
* @param string $attribute
|
||||
* @param string $value
|
||||
*
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateExists(XPathExpr $xpath, $attribute, $value)
|
||||
public function translateExists(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr
|
||||
{
|
||||
return $xpath->addCondition($attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
* @param string $attribute
|
||||
* @param string $value
|
||||
*
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateEquals(XPathExpr $xpath, $attribute, $value)
|
||||
public function translateEquals(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr
|
||||
{
|
||||
return $xpath->addCondition(sprintf('%s = %s', $attribute, Translator::getXpathLiteral($value)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
* @param string $attribute
|
||||
* @param string $value
|
||||
*
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateIncludes(XPathExpr $xpath, $attribute, $value)
|
||||
public function translateIncludes(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr
|
||||
{
|
||||
return $xpath->addCondition($value ? sprintf(
|
||||
'%1$s and contains(concat(\' \', normalize-space(%1$s), \' \'), %2$s)',
|
||||
@@ -83,14 +62,7 @@ class AttributeMatchingExtension extends AbstractExtension
|
||||
) : '0');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
* @param string $attribute
|
||||
* @param string $value
|
||||
*
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateDashMatch(XPathExpr $xpath, $attribute, $value)
|
||||
public function translateDashMatch(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr
|
||||
{
|
||||
return $xpath->addCondition(sprintf(
|
||||
'%1$s and (%1$s = %2$s or starts-with(%1$s, %3$s))',
|
||||
@@ -100,14 +72,7 @@ class AttributeMatchingExtension extends AbstractExtension
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
* @param string $attribute
|
||||
* @param string $value
|
||||
*
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translatePrefixMatch(XPathExpr $xpath, $attribute, $value)
|
||||
public function translatePrefixMatch(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr
|
||||
{
|
||||
return $xpath->addCondition($value ? sprintf(
|
||||
'%1$s and starts-with(%1$s, %2$s)',
|
||||
@@ -116,14 +81,7 @@ class AttributeMatchingExtension extends AbstractExtension
|
||||
) : '0');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
* @param string $attribute
|
||||
* @param string $value
|
||||
*
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateSuffixMatch(XPathExpr $xpath, $attribute, $value)
|
||||
public function translateSuffixMatch(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr
|
||||
{
|
||||
return $xpath->addCondition($value ? sprintf(
|
||||
'%1$s and substring(%1$s, string-length(%1$s)-%2$s) = %3$s',
|
||||
@@ -133,14 +91,7 @@ class AttributeMatchingExtension extends AbstractExtension
|
||||
) : '0');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
* @param string $attribute
|
||||
* @param string $value
|
||||
*
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateSubstringMatch(XPathExpr $xpath, $attribute, $value)
|
||||
public function translateSubstringMatch(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr
|
||||
{
|
||||
return $xpath->addCondition($value ? sprintf(
|
||||
'%1$s and contains(%1$s, %2$s)',
|
||||
@@ -149,14 +100,7 @@ class AttributeMatchingExtension extends AbstractExtension
|
||||
) : '0');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
* @param string $attribute
|
||||
* @param string $value
|
||||
*
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateDifferent(XPathExpr $xpath, $attribute, $value)
|
||||
public function translateDifferent(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr
|
||||
{
|
||||
return $xpath->addCondition(sprintf(
|
||||
$value ? 'not(%1$s) or %1$s != %2$s' : '%s != %s',
|
||||
|
||||
@@ -28,7 +28,7 @@ class CombinationExtension extends AbstractExtension
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCombinationTranslators()
|
||||
public function getCombinationTranslators(): array
|
||||
{
|
||||
return array(
|
||||
' ' => array($this, 'translateDescendant'),
|
||||
@@ -41,7 +41,7 @@ class CombinationExtension extends AbstractExtension
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateDescendant(XPathExpr $xpath, XPathExpr $combinedXpath)
|
||||
public function translateDescendant(XPathExpr $xpath, XPathExpr $combinedXpath): XPathExpr
|
||||
{
|
||||
return $xpath->join('/descendant-or-self::*/', $combinedXpath);
|
||||
}
|
||||
|
||||
@@ -46,16 +46,9 @@ class FunctionExtension extends AbstractExtension
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
* @param FunctionNode $function
|
||||
* @param bool $last
|
||||
* @param bool $addNameTest
|
||||
*
|
||||
* @return XPathExpr
|
||||
*
|
||||
* @throws ExpressionErrorException
|
||||
*/
|
||||
public function translateNthChild(XPathExpr $xpath, FunctionNode $function, $last = false, $addNameTest = true)
|
||||
public function translateNthChild(XPathExpr $xpath, FunctionNode $function, bool $last = false, bool $addNameTest = true): XPathExpr
|
||||
{
|
||||
try {
|
||||
list($a, $b) = Parser::parseSeries($function->getArguments());
|
||||
@@ -110,28 +103,20 @@ class FunctionExtension extends AbstractExtension
|
||||
// -1n+6 means elements 6 and previous
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateNthLastChild(XPathExpr $xpath, FunctionNode $function)
|
||||
public function translateNthLastChild(XPathExpr $xpath, FunctionNode $function): XPathExpr
|
||||
{
|
||||
return $this->translateNthChild($xpath, $function, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateNthOfType(XPathExpr $xpath, FunctionNode $function)
|
||||
public function translateNthOfType(XPathExpr $xpath, FunctionNode $function): XPathExpr
|
||||
{
|
||||
return $this->translateNthChild($xpath, $function, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*
|
||||
* @throws ExpressionErrorException
|
||||
*/
|
||||
public function translateNthLastOfType(XPathExpr $xpath, FunctionNode $function)
|
||||
public function translateNthLastOfType(XPathExpr $xpath, FunctionNode $function): XPathExpr
|
||||
{
|
||||
if ('*' === $xpath->getElement()) {
|
||||
throw new ExpressionErrorException('"*:nth-of-type()" is not implemented.');
|
||||
@@ -141,11 +126,9 @@ class FunctionExtension extends AbstractExtension
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*
|
||||
* @throws ExpressionErrorException
|
||||
*/
|
||||
public function translateContains(XPathExpr $xpath, FunctionNode $function)
|
||||
public function translateContains(XPathExpr $xpath, FunctionNode $function): XPathExpr
|
||||
{
|
||||
$arguments = $function->getArguments();
|
||||
foreach ($arguments as $token) {
|
||||
@@ -164,11 +147,9 @@ class FunctionExtension extends AbstractExtension
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*
|
||||
* @throws ExpressionErrorException
|
||||
*/
|
||||
public function translateLang(XPathExpr $xpath, FunctionNode $function)
|
||||
public function translateLang(XPathExpr $xpath, FunctionNode $function): XPathExpr
|
||||
{
|
||||
$arguments = $function->getArguments();
|
||||
foreach ($arguments as $token) {
|
||||
|
||||
@@ -33,21 +33,15 @@ class NodeExtension extends AbstractExtension
|
||||
|
||||
private $flags;
|
||||
|
||||
/**
|
||||
* @param int $flags
|
||||
*/
|
||||
public function __construct($flags = 0)
|
||||
public function __construct(int $flags = 0)
|
||||
{
|
||||
$this->flags = $flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $flag
|
||||
* @param bool $on
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setFlag($flag, $on)
|
||||
public function setFlag(int $flag, bool $on)
|
||||
{
|
||||
if ($on && !$this->hasFlag($flag)) {
|
||||
$this->flags += $flag;
|
||||
@@ -60,12 +54,7 @@ class NodeExtension extends AbstractExtension
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $flag
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasFlag($flag)
|
||||
public function hasFlag(int $flag): bool
|
||||
{
|
||||
return (bool) ($this->flags & $flag);
|
||||
}
|
||||
@@ -88,26 +77,17 @@ class NodeExtension extends AbstractExtension
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateSelector(Node\SelectorNode $node, Translator $translator)
|
||||
public function translateSelector(Node\SelectorNode $node, Translator $translator): XPathExpr
|
||||
{
|
||||
return $translator->nodeToXPath($node->getTree());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateCombinedSelector(Node\CombinedSelectorNode $node, Translator $translator)
|
||||
public function translateCombinedSelector(Node\CombinedSelectorNode $node, Translator $translator): XPathExpr
|
||||
{
|
||||
return $translator->addCombination($node->getCombinator(), $node->getSelector(), $node->getSubSelector());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateNegation(Node\NegationNode $node, Translator $translator)
|
||||
public function translateNegation(Node\NegationNode $node, Translator $translator): XPathExpr
|
||||
{
|
||||
$xpath = $translator->nodeToXPath($node->getSelector());
|
||||
$subXpath = $translator->nodeToXPath($node->getSubSelector());
|
||||
@@ -120,30 +100,21 @@ class NodeExtension extends AbstractExtension
|
||||
return $xpath->addCondition('0');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateFunction(Node\FunctionNode $node, Translator $translator)
|
||||
public function translateFunction(Node\FunctionNode $node, Translator $translator): XPathExpr
|
||||
{
|
||||
$xpath = $translator->nodeToXPath($node->getSelector());
|
||||
|
||||
return $translator->addFunction($xpath, $node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translatePseudo(Node\PseudoNode $node, Translator $translator)
|
||||
public function translatePseudo(Node\PseudoNode $node, Translator $translator): XPathExpr
|
||||
{
|
||||
$xpath = $translator->nodeToXPath($node->getSelector());
|
||||
|
||||
return $translator->addPseudoClass($xpath, $node->getIdentifier());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateAttribute(Node\AttributeNode $node, Translator $translator)
|
||||
public function translateAttribute(Node\AttributeNode $node, Translator $translator): XPathExpr
|
||||
{
|
||||
$name = $node->getAttribute();
|
||||
$safe = $this->isSafeName($name);
|
||||
@@ -168,30 +139,21 @@ class NodeExtension extends AbstractExtension
|
||||
return $translator->addAttributeMatching($xpath, $node->getOperator(), $attribute, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateClass(Node\ClassNode $node, Translator $translator)
|
||||
public function translateClass(Node\ClassNode $node, Translator $translator): XPathExpr
|
||||
{
|
||||
$xpath = $translator->nodeToXPath($node->getSelector());
|
||||
|
||||
return $translator->addAttributeMatching($xpath, '~=', '@class', $node->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateHash(Node\HashNode $node, Translator $translator)
|
||||
public function translateHash(Node\HashNode $node, Translator $translator): XPathExpr
|
||||
{
|
||||
$xpath = $translator->nodeToXPath($node->getSelector());
|
||||
|
||||
return $translator->addAttributeMatching($xpath, '=', '@id', $node->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateElement(Node\ElementNode $node)
|
||||
public function translateElement(Node\ElementNode $node): XPathExpr
|
||||
{
|
||||
$element = $node->getElement();
|
||||
|
||||
@@ -228,14 +190,7 @@ class NodeExtension extends AbstractExtension
|
||||
return 'node';
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if given name is safe.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isSafeName($name)
|
||||
private function isSafeName(string $name): bool
|
||||
{
|
||||
return 0 < preg_match('~^[a-zA-Z_][a-zA-Z0-9_.-]*$~', $name);
|
||||
}
|
||||
|
||||
67
vendor/symfony/css-selector/XPath/Translator.php
vendored
67
vendor/symfony/css-selector/XPath/Translator.php
vendored
@@ -61,12 +61,7 @@ class Translator implements TranslatorInterface
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $element
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getXpathLiteral($element)
|
||||
public static function getXpathLiteral(string $element): string
|
||||
{
|
||||
if (false === strpos($element, "'")) {
|
||||
return "'".$element."'";
|
||||
@@ -95,7 +90,7 @@ class Translator implements TranslatorInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function cssToXPath($cssExpr, $prefix = 'descendant-or-self::')
|
||||
public function cssToXPath(string $cssExpr, string $prefix = 'descendant-or-self::'): string
|
||||
{
|
||||
$selectors = $this->parseSelectors($cssExpr);
|
||||
|
||||
@@ -114,17 +109,12 @@ class Translator implements TranslatorInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function selectorToXPath(SelectorNode $selector, $prefix = 'descendant-or-self::')
|
||||
public function selectorToXPath(SelectorNode $selector, string $prefix = 'descendant-or-self::'): string
|
||||
{
|
||||
return ($prefix ?: '').$this->nodeToXPath($selector);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an extension.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function registerExtension(Extension\ExtensionInterface $extension)
|
||||
public function registerExtension(Extension\ExtensionInterface $extension): self
|
||||
{
|
||||
$this->extensions[$extension->getName()] = $extension;
|
||||
|
||||
@@ -138,13 +128,9 @@ class Translator implements TranslatorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return Extension\ExtensionInterface
|
||||
*
|
||||
* @throws ExpressionErrorException
|
||||
*/
|
||||
public function getExtension($name)
|
||||
public function getExtension(string $name): Extension\ExtensionInterface
|
||||
{
|
||||
if (!isset($this->extensions[$name])) {
|
||||
throw new ExpressionErrorException(sprintf('Extension "%s" not registered.', $name));
|
||||
@@ -153,12 +139,7 @@ class Translator implements TranslatorInterface
|
||||
return $this->extensions[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a shortcut parser.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function registerParserShortcut(ParserInterface $shortcut)
|
||||
public function registerParserShortcut(ParserInterface $shortcut): self
|
||||
{
|
||||
$this->shortcutParsers[] = $shortcut;
|
||||
|
||||
@@ -166,11 +147,9 @@ class Translator implements TranslatorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*
|
||||
* @throws ExpressionErrorException
|
||||
*/
|
||||
public function nodeToXPath(NodeInterface $node)
|
||||
public function nodeToXPath(NodeInterface $node): XPathExpr
|
||||
{
|
||||
if (!isset($this->nodeTranslators[$node->getNodeName()])) {
|
||||
throw new ExpressionErrorException(sprintf('Node "%s" not supported.', $node->getNodeName()));
|
||||
@@ -180,15 +159,9 @@ class Translator implements TranslatorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $combiner
|
||||
* @param NodeInterface $xpath
|
||||
* @param NodeInterface $combinedXpath
|
||||
*
|
||||
* @return XPathExpr
|
||||
*
|
||||
* @throws ExpressionErrorException
|
||||
*/
|
||||
public function addCombination($combiner, NodeInterface $xpath, NodeInterface $combinedXpath)
|
||||
public function addCombination(string $combiner, NodeInterface $xpath, NodeInterface $combinedXpath): XPathExpr
|
||||
{
|
||||
if (!isset($this->combinationTranslators[$combiner])) {
|
||||
throw new ExpressionErrorException(sprintf('Combiner "%s" not supported.', $combiner));
|
||||
@@ -198,11 +171,9 @@ class Translator implements TranslatorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return XPathExpr
|
||||
*
|
||||
* @throws ExpressionErrorException
|
||||
*/
|
||||
public function addFunction(XPathExpr $xpath, FunctionNode $function)
|
||||
public function addFunction(XPathExpr $xpath, FunctionNode $function): XPathExpr
|
||||
{
|
||||
if (!isset($this->functionTranslators[$function->getName()])) {
|
||||
throw new ExpressionErrorException(sprintf('Function "%s" not supported.', $function->getName()));
|
||||
@@ -212,14 +183,9 @@ class Translator implements TranslatorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
* @param string $pseudoClass
|
||||
*
|
||||
* @return XPathExpr
|
||||
*
|
||||
* @throws ExpressionErrorException
|
||||
*/
|
||||
public function addPseudoClass(XPathExpr $xpath, $pseudoClass)
|
||||
public function addPseudoClass(XPathExpr $xpath, string $pseudoClass): XPathExpr
|
||||
{
|
||||
if (!isset($this->pseudoClassTranslators[$pseudoClass])) {
|
||||
throw new ExpressionErrorException(sprintf('Pseudo-class "%s" not supported.', $pseudoClass));
|
||||
@@ -229,16 +195,9 @@ class Translator implements TranslatorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
* @param string $operator
|
||||
* @param string $attribute
|
||||
* @param string $value
|
||||
*
|
||||
* @return XPathExpr
|
||||
*
|
||||
* @throws ExpressionErrorException
|
||||
*/
|
||||
public function addAttributeMatching(XPathExpr $xpath, $operator, $attribute, $value)
|
||||
public function addAttributeMatching(XPathExpr $xpath, string $operator, string $attribute, $value): XPathExpr
|
||||
{
|
||||
if (!isset($this->attributeMatchingTranslators[$operator])) {
|
||||
throw new ExpressionErrorException(sprintf('Attribute matcher operator "%s" not supported.', $operator));
|
||||
@@ -248,11 +207,9 @@ class Translator implements TranslatorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $css
|
||||
*
|
||||
* @return SelectorNode[]
|
||||
*/
|
||||
private function parseSelectors($css)
|
||||
private function parseSelectors(string $css)
|
||||
{
|
||||
foreach ($this->shortcutParsers as $shortcut) {
|
||||
$tokens = $shortcut->parse($css);
|
||||
|
||||
@@ -27,21 +27,11 @@ interface TranslatorInterface
|
||||
{
|
||||
/**
|
||||
* Translates a CSS selector to an XPath expression.
|
||||
*
|
||||
* @param string $cssExpr
|
||||
* @param string $prefix
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function cssToXPath($cssExpr, $prefix = 'descendant-or-self::');
|
||||
public function cssToXPath(string $cssExpr, string $prefix = 'descendant-or-self::'): string;
|
||||
|
||||
/**
|
||||
* Translates a parsed selector node to an XPath expression.
|
||||
*
|
||||
* @param SelectorNode $selector
|
||||
* @param string $prefix
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function selectorToXPath(SelectorNode $selector, $prefix = 'descendant-or-self::');
|
||||
public function selectorToXPath(SelectorNode $selector, string $prefix = 'descendant-or-self::'): string;
|
||||
}
|
||||
|
||||
47
vendor/symfony/css-selector/XPath/XPathExpr.php
vendored
47
vendor/symfony/css-selector/XPath/XPathExpr.php
vendored
@@ -27,13 +27,7 @@ class XPathExpr
|
||||
private $element;
|
||||
private $condition;
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param string $element
|
||||
* @param string $condition
|
||||
* @param bool $starPrefix
|
||||
*/
|
||||
public function __construct($path = '', $element = '*', $condition = '', $starPrefix = false)
|
||||
public function __construct(string $path = '', string $element = '*', string $condition = '', bool $starPrefix = false)
|
||||
{
|
||||
$this->path = $path;
|
||||
$this->element = $element;
|
||||
@@ -44,38 +38,24 @@ class XPathExpr
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getElement()
|
||||
public function getElement(): string
|
||||
{
|
||||
return $this->element;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $condition
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addCondition($condition)
|
||||
public function addCondition(string $condition): self
|
||||
{
|
||||
$this->condition = $this->condition ? sprintf('%s and (%s)', $this->condition, $condition) : $condition;
|
||||
$this->condition = $this->condition ? sprintf('(%s) and (%s)', $this->condition, $condition) : $condition;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCondition()
|
||||
public function getCondition(): string
|
||||
{
|
||||
return $this->condition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function addNameTest()
|
||||
public function addNameTest(): self
|
||||
{
|
||||
if ('*' !== $this->element) {
|
||||
$this->addCondition('name() = '.Translator::getXpathLiteral($this->element));
|
||||
@@ -85,10 +65,7 @@ class XPathExpr
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function addStarPrefix()
|
||||
public function addStarPrefix(): self
|
||||
{
|
||||
$this->path .= '*/';
|
||||
|
||||
@@ -98,12 +75,9 @@ class XPathExpr
|
||||
/**
|
||||
* Joins another XPathExpr with a combiner.
|
||||
*
|
||||
* @param string $combiner
|
||||
* @param XPathExpr $expr
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function join($combiner, XPathExpr $expr)
|
||||
public function join(string $combiner, self $expr): self
|
||||
{
|
||||
$path = $this->__toString().$combiner;
|
||||
|
||||
@@ -118,10 +92,7 @@ class XPathExpr
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
$path = $this->path.$this->element;
|
||||
$condition = null === $this->condition || '' === $this->condition ? '' : '['.$this->condition.']';
|
||||
|
||||
Reference in New Issue
Block a user