package and depencies
This commit is contained in:
@@ -23,41 +23,26 @@ namespace Symfony\Component\CssSelector\XPath\Extension;
|
||||
*/
|
||||
abstract class AbstractExtension implements ExtensionInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getNodeTranslators(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCombinationTranslators(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFunctionTranslators(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPseudoClassTranslators(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAttributeMatchingTranslators(): array
|
||||
{
|
||||
return [];
|
||||
|
@@ -26,20 +26,17 @@ use Symfony\Component\CssSelector\XPath\XPathExpr;
|
||||
*/
|
||||
class AttributeMatchingExtension extends AbstractExtension
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAttributeMatchingTranslators(): array
|
||||
{
|
||||
return [
|
||||
'exists' => [$this, 'translateExists'],
|
||||
'=' => [$this, 'translateEquals'],
|
||||
'~=' => [$this, 'translateIncludes'],
|
||||
'|=' => [$this, 'translateDashMatch'],
|
||||
'^=' => [$this, 'translatePrefixMatch'],
|
||||
'$=' => [$this, 'translateSuffixMatch'],
|
||||
'*=' => [$this, 'translateSubstringMatch'],
|
||||
'!=' => [$this, 'translateDifferent'],
|
||||
'exists' => $this->translateExists(...),
|
||||
'=' => $this->translateEquals(...),
|
||||
'~=' => $this->translateIncludes(...),
|
||||
'|=' => $this->translateDashMatch(...),
|
||||
'^=' => $this->translatePrefixMatch(...),
|
||||
'$=' => $this->translateSuffixMatch(...),
|
||||
'*=' => $this->translateSubstringMatch(...),
|
||||
'!=' => $this->translateDifferent(...),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -109,9 +106,6 @@ class AttributeMatchingExtension extends AbstractExtension
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return 'attribute-matching';
|
||||
|
@@ -25,16 +25,13 @@ use Symfony\Component\CssSelector\XPath\XPathExpr;
|
||||
*/
|
||||
class CombinationExtension extends AbstractExtension
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCombinationTranslators(): array
|
||||
{
|
||||
return [
|
||||
' ' => [$this, 'translateDescendant'],
|
||||
'>' => [$this, 'translateChild'],
|
||||
'+' => [$this, 'translateDirectAdjacent'],
|
||||
'~' => [$this, 'translateIndirectAdjacent'],
|
||||
' ' => $this->translateDescendant(...),
|
||||
'>' => $this->translateChild(...),
|
||||
'+' => $this->translateDirectAdjacent(...),
|
||||
'~' => $this->translateIndirectAdjacent(...),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -61,9 +58,6 @@ class CombinationExtension extends AbstractExtension
|
||||
return $xpath->join('/following-sibling::', $combinedXpath);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return 'combination';
|
||||
|
@@ -30,18 +30,15 @@ use Symfony\Component\CssSelector\XPath\XPathExpr;
|
||||
*/
|
||||
class FunctionExtension extends AbstractExtension
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFunctionTranslators(): array
|
||||
{
|
||||
return [
|
||||
'nth-child' => [$this, 'translateNthChild'],
|
||||
'nth-last-child' => [$this, 'translateNthLastChild'],
|
||||
'nth-of-type' => [$this, 'translateNthOfType'],
|
||||
'nth-last-of-type' => [$this, 'translateNthLastOfType'],
|
||||
'contains' => [$this, 'translateContains'],
|
||||
'lang' => [$this, 'translateLang'],
|
||||
'nth-child' => $this->translateNthChild(...),
|
||||
'nth-last-child' => $this->translateNthLastChild(...),
|
||||
'nth-of-type' => $this->translateNthOfType(...),
|
||||
'nth-last-of-type' => $this->translateNthLastOfType(...),
|
||||
'contains' => $this->translateContains(...),
|
||||
'lang' => $this->translateLang(...),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -161,9 +158,6 @@ class FunctionExtension extends AbstractExtension
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return 'function';
|
||||
|
@@ -36,30 +36,24 @@ class HtmlExtension extends AbstractExtension
|
||||
->setFlag(NodeExtension::ATTRIBUTE_NAME_IN_LOWER_CASE, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPseudoClassTranslators(): array
|
||||
{
|
||||
return [
|
||||
'checked' => [$this, 'translateChecked'],
|
||||
'link' => [$this, 'translateLink'],
|
||||
'disabled' => [$this, 'translateDisabled'],
|
||||
'enabled' => [$this, 'translateEnabled'],
|
||||
'selected' => [$this, 'translateSelected'],
|
||||
'invalid' => [$this, 'translateInvalid'],
|
||||
'hover' => [$this, 'translateHover'],
|
||||
'visited' => [$this, 'translateVisited'],
|
||||
'checked' => $this->translateChecked(...),
|
||||
'link' => $this->translateLink(...),
|
||||
'disabled' => $this->translateDisabled(...),
|
||||
'enabled' => $this->translateEnabled(...),
|
||||
'selected' => $this->translateSelected(...),
|
||||
'invalid' => $this->translateInvalid(...),
|
||||
'hover' => $this->translateHover(...),
|
||||
'visited' => $this->translateVisited(...),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFunctionTranslators(): array
|
||||
{
|
||||
return [
|
||||
'lang' => [$this, 'translateLang'],
|
||||
'lang' => $this->translateLang(...),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -177,9 +171,6 @@ class HtmlExtension extends AbstractExtension
|
||||
return $xpath->addCondition('0');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return 'html';
|
||||
|
@@ -31,7 +31,7 @@ class NodeExtension extends AbstractExtension
|
||||
public const ATTRIBUTE_NAME_IN_LOWER_CASE = 2;
|
||||
public const ATTRIBUTE_VALUE_IN_LOWER_CASE = 4;
|
||||
|
||||
private $flags;
|
||||
private int $flags;
|
||||
|
||||
public function __construct(int $flags = 0)
|
||||
{
|
||||
@@ -41,7 +41,7 @@ class NodeExtension extends AbstractExtension
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setFlag(int $flag, bool $on): self
|
||||
public function setFlag(int $flag, bool $on): static
|
||||
{
|
||||
if ($on && !$this->hasFlag($flag)) {
|
||||
$this->flags += $flag;
|
||||
@@ -59,21 +59,18 @@ class NodeExtension extends AbstractExtension
|
||||
return (bool) ($this->flags & $flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getNodeTranslators(): array
|
||||
{
|
||||
return [
|
||||
'Selector' => [$this, 'translateSelector'],
|
||||
'CombinedSelector' => [$this, 'translateCombinedSelector'],
|
||||
'Negation' => [$this, 'translateNegation'],
|
||||
'Function' => [$this, 'translateFunction'],
|
||||
'Pseudo' => [$this, 'translatePseudo'],
|
||||
'Attribute' => [$this, 'translateAttribute'],
|
||||
'Class' => [$this, 'translateClass'],
|
||||
'Hash' => [$this, 'translateHash'],
|
||||
'Element' => [$this, 'translateElement'],
|
||||
'Selector' => $this->translateSelector(...),
|
||||
'CombinedSelector' => $this->translateCombinedSelector(...),
|
||||
'Negation' => $this->translateNegation(...),
|
||||
'Function' => $this->translateFunction(...),
|
||||
'Pseudo' => $this->translatePseudo(...),
|
||||
'Attribute' => $this->translateAttribute(...),
|
||||
'Class' => $this->translateClass(...),
|
||||
'Hash' => $this->translateHash(...),
|
||||
'Element' => $this->translateElement(...),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -182,9 +179,6 @@ class NodeExtension extends AbstractExtension
|
||||
return $xpath;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return 'node';
|
||||
|
@@ -26,20 +26,17 @@ use Symfony\Component\CssSelector\XPath\XPathExpr;
|
||||
*/
|
||||
class PseudoClassExtension extends AbstractExtension
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPseudoClassTranslators(): array
|
||||
{
|
||||
return [
|
||||
'root' => [$this, 'translateRoot'],
|
||||
'first-child' => [$this, 'translateFirstChild'],
|
||||
'last-child' => [$this, 'translateLastChild'],
|
||||
'first-of-type' => [$this, 'translateFirstOfType'],
|
||||
'last-of-type' => [$this, 'translateLastOfType'],
|
||||
'only-child' => [$this, 'translateOnlyChild'],
|
||||
'only-of-type' => [$this, 'translateOnlyOfType'],
|
||||
'empty' => [$this, 'translateEmpty'],
|
||||
'root' => $this->translateRoot(...),
|
||||
'first-child' => $this->translateFirstChild(...),
|
||||
'last-child' => $this->translateLastChild(...),
|
||||
'first-of-type' => $this->translateFirstOfType(...),
|
||||
'last-of-type' => $this->translateLastOfType(...),
|
||||
'only-child' => $this->translateOnlyChild(...),
|
||||
'only-of-type' => $this->translateOnlyOfType(...),
|
||||
'empty' => $this->translateEmpty(...),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -112,9 +109,6 @@ class PseudoClassExtension extends AbstractExtension
|
||||
return $xpath->addCondition('not(*) and not(string-length())');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return 'pseudo-class';
|
||||
|
28
vendor/symfony/css-selector/XPath/Translator.php
vendored
28
vendor/symfony/css-selector/XPath/Translator.php
vendored
@@ -30,23 +30,23 @@ use Symfony\Component\CssSelector\Parser\ParserInterface;
|
||||
*/
|
||||
class Translator implements TranslatorInterface
|
||||
{
|
||||
private $mainParser;
|
||||
private ParserInterface $mainParser;
|
||||
|
||||
/**
|
||||
* @var ParserInterface[]
|
||||
*/
|
||||
private $shortcutParsers = [];
|
||||
private array $shortcutParsers = [];
|
||||
|
||||
/**
|
||||
* @var Extension\ExtensionInterface[]
|
||||
*/
|
||||
private $extensions = [];
|
||||
private array $extensions = [];
|
||||
|
||||
private $nodeTranslators = [];
|
||||
private $combinationTranslators = [];
|
||||
private $functionTranslators = [];
|
||||
private $pseudoClassTranslators = [];
|
||||
private $attributeMatchingTranslators = [];
|
||||
private array $nodeTranslators = [];
|
||||
private array $combinationTranslators = [];
|
||||
private array $functionTranslators = [];
|
||||
private array $pseudoClassTranslators = [];
|
||||
private array $attributeMatchingTranslators = [];
|
||||
|
||||
public function __construct(ParserInterface $parser = null)
|
||||
{
|
||||
@@ -87,9 +87,6 @@ class Translator implements TranslatorInterface
|
||||
return sprintf('concat(%s)', implode(', ', $parts));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function cssToXPath(string $cssExpr, string $prefix = 'descendant-or-self::'): string
|
||||
{
|
||||
$selectors = $this->parseSelectors($cssExpr);
|
||||
@@ -106,9 +103,6 @@ class Translator implements TranslatorInterface
|
||||
return implode(' | ', $selectors);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function selectorToXPath(SelectorNode $selector, string $prefix = 'descendant-or-self::'): string
|
||||
{
|
||||
return ($prefix ?: '').$this->nodeToXPath($selector);
|
||||
@@ -117,7 +111,7 @@ class Translator implements TranslatorInterface
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function registerExtension(Extension\ExtensionInterface $extension): self
|
||||
public function registerExtension(Extension\ExtensionInterface $extension): static
|
||||
{
|
||||
$this->extensions[$extension->getName()] = $extension;
|
||||
|
||||
@@ -145,7 +139,7 @@ class Translator implements TranslatorInterface
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function registerParserShortcut(ParserInterface $shortcut): self
|
||||
public function registerParserShortcut(ParserInterface $shortcut): static
|
||||
{
|
||||
$this->shortcutParsers[] = $shortcut;
|
||||
|
||||
@@ -220,7 +214,7 @@ class Translator implements TranslatorInterface
|
||||
foreach ($this->shortcutParsers as $shortcut) {
|
||||
$tokens = $shortcut->parse($css);
|
||||
|
||||
if (!empty($tokens)) {
|
||||
if ($tokens) {
|
||||
return $tokens;
|
||||
}
|
||||
}
|
||||
|
14
vendor/symfony/css-selector/XPath/XPathExpr.php
vendored
14
vendor/symfony/css-selector/XPath/XPathExpr.php
vendored
@@ -23,9 +23,9 @@ namespace Symfony\Component\CssSelector\XPath;
|
||||
*/
|
||||
class XPathExpr
|
||||
{
|
||||
private $path;
|
||||
private $element;
|
||||
private $condition;
|
||||
private string $path;
|
||||
private string $element;
|
||||
private string $condition;
|
||||
|
||||
public function __construct(string $path = '', string $element = '*', string $condition = '', bool $starPrefix = false)
|
||||
{
|
||||
@@ -46,7 +46,7 @@ class XPathExpr
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function addCondition(string $condition): self
|
||||
public function addCondition(string $condition): static
|
||||
{
|
||||
$this->condition = $this->condition ? sprintf('(%s) and (%s)', $this->condition, $condition) : $condition;
|
||||
|
||||
@@ -61,7 +61,7 @@ class XPathExpr
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function addNameTest(): self
|
||||
public function addNameTest(): static
|
||||
{
|
||||
if ('*' !== $this->element) {
|
||||
$this->addCondition('name() = '.Translator::getXpathLiteral($this->element));
|
||||
@@ -74,7 +74,7 @@ class XPathExpr
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function addStarPrefix(): self
|
||||
public function addStarPrefix(): static
|
||||
{
|
||||
$this->path .= '*/';
|
||||
|
||||
@@ -86,7 +86,7 @@ class XPathExpr
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function join(string $combiner, self $expr): self
|
||||
public function join(string $combiner, self $expr): static
|
||||
{
|
||||
$path = $this->__toString().$combiner;
|
||||
|
||||
|
Reference in New Issue
Block a user